MATH 209, Lab 5 - University of Albertarms8/Teaching/Lab5.pdf · Therefore, the values of xand...

8
MATH 209, Lab 5 Richard M. Slevinsky * Problems 1. Say the temperature T at any point (x, y, z ) in space is given by T =4 xyz 2 . Find the hottest point on the sphere F = x 2 + y 2 + z 2 - 100 = 0; We equate gradients: T = λF, 4hyz 2 ,xz 2 , 2 xyz i = λh2 x, 2 y, 2 z i, giving us three equations for four unknowns. Adding the constraint F =0, we have four equations for four unknowns: 4 yz 2 =2 λ x, 4 xz 2 =2 λy, 8 xyz =2 λz, x 2 + y 2 + z 2 = 100. Simplifying by substituting the constraint equation, we find: 4 y(100 - x 2 - y 2 )=2 λ x, 4 x(100 - x 2 - y 2 )=2 λy, 8 xy =2 λ. Again for λ: 4 y(100 - x 2 - y 2 )=8 x 2 y, 4 x(100 - x 2 - y 2 )=8 xy 2 . And: 100 - x 2 - y 2 =2 x 2 , 100 - x 2 - y 2 =2 y 2 . Or: 100 - 3 x 2 - y 2 =0, 100 - x 2 - 3 y 2 =0. * Contact: [email protected] 1

Transcript of MATH 209, Lab 5 - University of Albertarms8/Teaching/Lab5.pdf · Therefore, the values of xand...

Page 1: MATH 209, Lab 5 - University of Albertarms8/Teaching/Lab5.pdf · Therefore, the values of xand ymust solve the above system. By subtraction, we find x= 5 and y= 5. At these values,

MATH 209, Lab 5

Richard M. Slevinsky∗

Problems

1. Say the temperature T at any point (x, y, z) in space is given by T = 4x y z2. Find the hottest pointon the sphere F = x2 + y2 + z2 − 100 = 0;

We equate gradients:

∇T = λ∇F,4〈y z2, x z2, 2x y z〉 = λ〈2x, 2 y, 2 z〉,

giving us three equations for four unknowns. Adding the constraint F = 0, we have four equations forfour unknowns:

4 y z2 = 2λx,

4x z2 = 2λ y,

8x y z = 2λ z,

x2 + y2 + z2 = 100.

Simplifying by substituting the constraint equation, we find:

4 y(100− x2 − y2) = 2λx,

4x(100− x2 − y2) = 2λ y,

8x y = 2λ.

Again for λ:

4 y(100− x2 − y2) = 8x2 y,

4x(100− x2 − y2) = 8x y2.

And:

100− x2 − y2 = 2x2,

100− x2 − y2 = 2 y2.

Or:

100− 3x2 − y2 = 0,

100− x2 − 3 y2 = 0.

∗Contact: [email protected]

1

Page 2: MATH 209, Lab 5 - University of Albertarms8/Teaching/Lab5.pdf · Therefore, the values of xand ymust solve the above system. By subtraction, we find x= 5 and y= 5. At these values,

Therefore, the values of x and y must solve the above system. By subtraction, we find x = ±5 andy = ±5. At these values, 25 + 25 + z2 = 100, or z2 = 50, and z = ±5

√2. The hottest point occurs

when T at the highest value of T (±5,±5,±5√2). This occurs when the signs of the x and y values are

the same. Therefore, the hottest points are located at (x, y, z) = (5, 5,±5√2) and (−5,−5,±5

√2).

2. Show that the product of the angles of a triangle is largest when the triangle is equilateral;

We seek to:

maximize P = θ1θ2θ3 subject to S = θ1 + θ2 + θ3 − 180 = 0,

θi > 0, i = 1, 2, 3.

Equating gradients, we find:

∇P = λ∇S,〈θ2θ3, θ1θ3, θ1θ2〉 = λ〈1, 1, 1〉.

The four equations we have are:

θ2θ3 = λ,

θ1θ3 = λ,

θ1θ2 = λ,

θ1 + θ2 + θ3 = 180.

The top three equations can be rearranged as:

θ3(θ2 − θ1) = 0,

θ1(θ3 − θ2) = 0,

θ2(θ3 − θ1) = 0,

implying θ1 = θ2 = θ3 = 60 from the angular constraint. This is the equilateral triangle.

3. Let C denote the line of intersection of the planes 3x + 2 y + z = 6 and x − 4 y + 2 z = 8. Find thepoint on C that is closest to the origin;

The point that is closest to the origin minimizes the distance, and also the distance squared, which issimpler to work with. Equating gradients:

∇d2(x, y, z) = λP1 + µP2,

2〈x, y, z〉 = λ〈3, 2, 1〉+ µ〈1,−4, 2〉,

These three equations with the two planes give:

2x− 3λ− µ = 0,

2 y − 2λ+ 4µ = 0,

2 z − λ− 2µ = 0,

3x+ 2 y + z = 6,

x− 4 y + 2 z = 8.

This system of five equations and five unknowns has the solution (check) x = 11657 , y = −44

57 , z = 8257 ,

λ = 2019 , µ = 52

57 . The closest point is therefore: (x, y, z) = 157(116,−44, 82).

2

Page 3: MATH 209, Lab 5 - University of Albertarms8/Teaching/Lab5.pdf · Therefore, the values of xand ymust solve the above system. By subtraction, we find x= 5 and y= 5. At these values,

4. A container is constructed in the shape of a cylinder with a top and a bottom (e.g. a beer can). If thesurface area of the container has a fixed value S, find the radius and height of the container that willmaximize the enclosed volume.

The volume of a cylinder is V = πr2h, while the surface area is S = 2πrh+ 2πr2. Therefore, we wishto:

maximize V = πr2h subject to S = 2πrh+ 2πr2.

Equating gradients, we find:

∇V = λ∇S,π〈2 r h, r2〉 = 2πλ〈h+ 2 r, r〉.

These two equations are:

2π r h = 2πλ(h+ 2 r),

π r2 = 2πλ r.

The second equation gives r = 0 or λ = r2 . Since r = 0 won’t maximize anything, inserting the second

possibility into the first equation above:

2π r h = 2πr

2(h+ 2 r),

2h = h+ 2 r,

h = 2 r.

Therefore, the height is twice the size of the radius.

Exercises

1. Find the maximum value of f(x, y, z) = x+ y + z on the sphere x2 + y2 + z2 = 25;

Equating gradients:

∇f = λ∇F,〈1, 1, 1〉 = λ〈2x, 2 y, 2 z〉,

giving us three equations for four unknowns. Adding the constraint F = 0, we have four equations forfour unknowns:

1 = 2λx,

1 = 2λ y,

1 = 2λ z,

x2 + y2 + z2 = 25.

Simplifying by substituting into the constraint equation, we find:(1

)2

+

(1

)2

+

(1

)2

= 25,

3

4= 25λ2,

3

Page 4: MATH 209, Lab 5 - University of Albertarms8/Teaching/Lab5.pdf · Therefore, the values of xand ymust solve the above system. By subtraction, we find x= 5 and y= 5. At these values,

or λ = ±√3/10. Choosing only the positive branch for the position (otherwise we actually find the

minimum value of f), we find x = y = z = 5/√3. Therefore, the maximum value of f on the sphere is

f(5/√3, 5/√3, 5/√3) = 5

√3.

2. Let C be the curve of intersection of the surface y2−z2 = 1 and the plane x−y = 1. Find the minimumvalue of f(x, y, z) = x2 + y2 + z2 on C;

Letting g1(x, y, z) = y2 − z2 − 1 = 0 and g2(x, y, z) = x− y − 1 = 0, we equate gradients:

∇f = λ∇g1 + µ∇g2,〈2x, 2 y, 2 z〉 = λ〈0, 2 y,−2 z〉+ µ〈1,−1, 0〉.

These three equations with the two surfaces gives five equations for five unknowns:

2x− µ = 0,

2 y − λ2 y + µ = 0,

2 z + λ2 z = 0,

y2 − z2 = 1,

x− y = 1.

From the last and first equations x = 1 + y and therefore µ = 2(1 + y). Inserting this into the secondequation and simplifying:

4 y − λ2 y = −2,z + λz = 0,

y2 − z2 = 1.

Therefore, from this middle equation, either z = 0 or λ = −1. If z = 0, then y = ±1 from the bottomequation and x = 1 ± 1 = 2, 0 from above. Therefore, f(x, y, z) = 02 + (±1)2 + (1 ± 1)2 = 3 ± 2. Ifλ = −1, then y = −1/3. However, if −1 < y < 1, then from the bottom equation z ∈ C and thereforethe point is not on both curves. The minimum value is f(0,−1, 0) = 1.

3. What is the volume of the largest rectangular box (with edges parallel to the axes) which can be

inscribed in the ellipsoidx2

36+y2

9+z2

16= 1?

Since x, y, and z are the coordinate lengths, the volumes of the rectangular boxes with edges parallelto the axes is V = 2x2 y2 z = 8x y z. Therefore, equating gradients:

∇V = λ∇E,

8〈y z, x z, x y〉 = λ

⟨x

18,2 y

9,z

8

⟩.

With the ellipsoidal constraint:

8 y z − λx

18= 0,

8x z − 2λy

9= 0,

8x y − λz

8= 0,

x2

36+y2

9+z2

16= 1.

4

Page 5: MATH 209, Lab 5 - University of Albertarms8/Teaching/Lab5.pdf · Therefore, the values of xand ymust solve the above system. By subtraction, we find x= 5 and y= 5. At these values,

From the first equation λ = 144 y zx . Therefore:

8x z − 288 y2z

9x= 0,

8x y − 144 y z2

8x= 0,

x2

36+y2

9+z2

16= 1.

Simplifying the top two equations:

x2 − 4 y2 = 0,

4x2 − 9 z2 = 0,

x2

36+y2

9+z2

16= 1.

Solving the top two equations for y2 and z2 and inserting in the ellipsoidal equation, we have:

y2 =x2

4,

z2 =4x2

9,

x2

36+x2

36+x2

36= 1.

Therefore, x2 = 12, or x = ±2√3, y = ±

√3, and z = ±4/

√3. Taking only the positive points, the

largest box has the volume V (2√3,√3, 4/√3) = 64

√3.

4. Find the point on the plane z = 4x+ 9 y which is closest to the point (1, 1, 2).

We seek to minimize the distance (squared) from the point to the plane:

minimize d2P = (x− 1)2 + (y − 1)2 + (z − 2)2 subject to S = 4x+ 9 y − z = 0.

Equating gradients, we find:

∇d2P = λ∇S,2〈x− 1, y − 1, z − 2〉 = λ〈4, 9,−1〉.

With the planar constraint:

2(x− 1)− 4λ = 0,

2(y − 1)− 9λ = 0,

2(z − 1) + λ = 0,

4x+ 9 y − z = 0.

This system of four equations and four unknowns has the solution (check) x = 5049 , y = − 5

49 , z = 5549 ,

and λ = −1249 .

5

Page 6: MATH 209, Lab 5 - University of Albertarms8/Teaching/Lab5.pdf · Therefore, the values of xand ymust solve the above system. By subtraction, we find x= 5 and y= 5. At these values,

This week, we will find the global minimum of the function:

f(x, y) = esin(50x) + sin(60 ey) + sin(70 sin(x)) + sin(sin(80 y))− sin(10(x+ y)) +x2 + y2

4.

This is problem 4 in The SIAM 100-Digit Challenge [1]. For x and y large, f(x, y) is dominated by theparaboloid x2+y2

4 , since the values of the other terms lie in the intervals [1/e, e], [−1, 1], [−1, 1], [− sin 1, sin 1],and [−1, 1], respectively. Therefore, we know the minimum will be reasonably near the origin. However,what is reasonable? We can break the problem down into three steps:

1. Find a bounded region that contains the minimum;

2. Identify the rough location of the lowest point in that region;

3. Zoom in closer to pinpoint the minimum to high precision.

Part I

We evaluate the function on the 2601 values of x and y from −0.25 to 0.25 in steps of 0.01. The function canbe as small as −3.24. Outside the circle of radius 1, the function is at least e−1−1−1−sin 1−1+ 1

4 > −3.23.Therefore, the minimum must be inside the circle of radius 1.

Part II

Many animals and insects interact with eachother, whether this may be for the purposes of protection frompredators, or for cooperation in hunting, finding shelter, or otherwise [2]. Bees, ants, birds, and fish havebeen studied in particular because they are all relatively easy to study. For example, bee hives host around5,000-10,000 bees, which is few enough to be individually counted and monitored. Insects can communicatewith one another by releasing pheromones into the environment. These pheromones can indicate the sourceand quality of food, or a threat.

PSO seeks to use simple algorithmic rules from the insect interactions, apply them to agents with randommotion, and hope to derive meaningful global information of the problem the agents are trying to solve. Forbees and ants that are harvesting food, they may look like [2]:

1. Wander to find food;

6

Page 7: MATH 209, Lab 5 - University of Albertarms8/Teaching/Lab5.pdf · Therefore, the values of xand ymust solve the above system. By subtraction, we find x= 5 and y= 5. At these values,

2. When I find food, harvest it and lay a trail of pheromones back to hive/hill;

3. If I find a trail, follow it, harvest food, and reinforce the shortest trail with pheromones to hive/hill.

Bees and ants have become the prototype species for PSO and Ant-Colony Optimization (ACO). While theyare similar, the ACO is very similar to the simple rules above, while the PSO takes advantage of the abilityof bees to fly. This results in the Particle Swarm Optimization algorithm [3]:

1. Initialization of agents i = 1, . . . , N , with random positions ~xi and speeds ~vi;

Loop over all agents

2. Evaluate the function f(~xi);

3. Compare the value of the function f(~xi) with the best value of the agent. Let this be the vector ~p. If thecurrent value is the best, replace it;

4. Identify the agent with the best value ~p. Let this be the vector ~g representing the entire swarm’s bestvalue;

5. Update the agents’ positions and velocities as:

~vi ← ω~vi + φpU(0, 1)⊗ (~pi − ~xi) + φgU(0, 1)⊗ (~pg − ~xi),~xi ← ~xi + ~vi. (1)

6. Terminate when the optimal value (to an error tolerance) is obtained.

End loop

In (1), 0 < ω < 1 is an inertial term, −2 < φp < 2, −2 < φg < 2, ⊗ denotes component-wise multiplication,and U(0, 1) denotes a uniformly distributed random variable on the interval [0, 1].

Part III

To get really high precision result, we need something that converges very quickly. Remember the Newton-Raphson method? Suppose we want to find the solution to:

min f(x) =⇒ f ′(x) = 0. (2)

Using the linear approximation to f ′(xi), we have:

L(x) = f ′(xi) + (x− xi)f ′′(xi). (3)

Setting the linear approximation to 0, we solve:

0 = f ′(xi) + (xi+1 − xi)f ′′(xi), (4)

for xi+1 as:

xi+1 = xi −f ′(xi)

f ′′(xi). (5)

Suppose, now we have two variables:

min f(x, y) =⇒ ∇f(x, y) = 0. (6)

7

Page 8: MATH 209, Lab 5 - University of Albertarms8/Teaching/Lab5.pdf · Therefore, the values of xand ymust solve the above system. By subtraction, we find x= 5 and y= 5. At these values,

But setting the gradient to 0 is actually a system of two equations:

fx(x, y) = 0, (7)

fy(x, y) = 0, (8)

with two unknowns x and y. Fortunately, we can form the tangent plane approximation (the generalizationof the linear approximation) to both equations:

Tfx(x, y) = fx(xi, yi) + (x− xi)fxx(xi, yi) + (y − yi)fxy(xi, yi), (9)

Tfy(x, y) = fy(xi, yi) + (x− xi)fxy(xi, yi) + (y − yi)fyy(xi, yi), (10)

Setting both equations simultaneously to 0 at the new iterate (xi+1, yi+1), we have:[fxx(xi, yi) fxy(xi, yi)

fxy(xi, yi) fyy(xi, yi)

][xi+1 − xiyi+1 − yi

]= −

[fx(xi, yi)

fy(xi, yi)

]. (11)

This is a familiar system of two equations for two unknowns. We can solve this![xi+1

yi+1

]=

[xiyi

]−

[fxx(xi, yi) fxy(xi, yi)

fxy(xi, yi) fyy(xi, yi)

]−1 [fx(xi, yi)

fy(xi, yi)

]. (12)

References[1] F. Bornemann et al. Think Globally, Act Locally in The SIAM 100-Digit Challenge, SIAM, 4:77–100,

2004.[2] M. Beekman et al. Biological Foundations of Swarm Intelligence in Swarm Intelligence, Springer-Verlag,

1:3–41, 2008.[3] J. Kennedy and R.C. Eberhart Particle swarm optimization, Proceedings of the IEEE international

conference on neural networks IV, 1942–1948, 1995.

8