MATH 209, Lab 5
MATH 209, Lab 5
MATH 209, Lab 5
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
<strong>MATH</strong> <strong>209</strong>, <strong>Lab</strong> 5<br />
Richard M. Slevinsky ∗<br />
Problems<br />
1. Say the temperature T at any point (x, y, z) in space is given by T = 4 x y z 2 . Find the hottest point<br />
on the sphere F = x 2 + y 2 + z 2 − 100 = 0;<br />
We equate gradients:<br />
∇T = λ∇F,<br />
4〈y z 2 , x z 2 , 2 x y z〉 = λ〈2 x, 2 y, 2 z〉,<br />
giving us three equations for four unknowns. Adding the constraint F = 0, we have four equations for<br />
four unknowns:<br />
4 y z 2 = 2 λ x,<br />
4 x z 2 = 2 λ y,<br />
8 x y z = 2 λ z,<br />
x 2 + y 2 + z 2 = 100.<br />
Simplifying by substituting the constraint equation, we find:<br />
Again for λ:<br />
And:<br />
Or:<br />
∗ Contact: rms8@ualberta.ca<br />
4 y(100 − x 2 − y 2 ) = 2 λ x,<br />
4 x(100 − x 2 − y 2 ) = 2 λ y,<br />
8 x y = 2 λ.<br />
4 y(100 − x 2 − y 2 ) = 8 x 2 y,<br />
4 x(100 − x 2 − y 2 ) = 8 x y 2 .<br />
100 − x 2 − y 2 = 2 x 2 ,<br />
100 − x 2 − y 2 = 2 y 2 .<br />
100 − 3 x 2 − y 2 = 0,<br />
100 − x 2 − 3 y 2 = 0.<br />
1
Therefore, the values of x and y must solve the above system. By subtraction, we find x = ±5 and<br />
y = ±5. At these values, 25 + 25 + z 2 = 100, or z 2 = 50, and z = ±5 √ 2. The hottest point occurs<br />
when T at the highest value of T (±5, ±5, ±5 √ 2). This occurs when the signs of the x and y values are<br />
the same. Therefore, the hottest points are located at (x, y, z) = (5, 5, ±5 √ 2) and (−5, −5, ±5 √ 2).<br />
2. Show that the product of the angles of a triangle is largest when the triangle is equilateral;<br />
We seek to:<br />
Equating gradients, we find:<br />
The four equations we have are:<br />
maximize P = θ 1 θ 2 θ 3 subject to S = θ 1 + θ 2 + θ 3 − 180 = 0,<br />
The top three equations can be rearranged as:<br />
∇P = λ∇S,<br />
〈θ 2 θ 3 , θ 1 θ 3 , θ 1 θ 2 〉 = λ〈1, 1, 1〉.<br />
θ 2 θ 3 = λ,<br />
θ 1 θ 3 = λ,<br />
θ 1 θ 2 = λ,<br />
θ 1 + θ 2 + θ 3 = 180.<br />
θ 3 (θ 2 − θ 1 ) = 0,<br />
θ 1 (θ 3 − θ 2 ) = 0,<br />
θ 2 (θ 3 − θ 1 ) = 0,<br />
θ i > 0, i = 1, 2, 3.<br />
implying θ 1 = θ 2 = θ 3 = 60 from the angular constraint. This is the equilateral triangle.<br />
3. Let C denote the line of intersection of the planes 3 x + 2 y + z = 6 and x − 4 y + 2 z = 8. Find the<br />
point on C that is closest to the origin;<br />
The point that is closest to the origin minimizes the distance, and also the distance squared, which is<br />
simpler to work with. Equating gradients:<br />
∇d 2 (x, y, z) = λP 1 + µP 2 ,<br />
2〈x, y, z〉 = λ〈3, 2, 1〉 + µ〈1, −4, 2〉,<br />
These three equations with the two planes give:<br />
2 x − 3λ − µ = 0,<br />
2 y − 2λ + 4µ = 0,<br />
2 z − λ − 2µ = 0,<br />
3 x + 2 y + z = 6,<br />
x − 4 y + 2 z = 8.<br />
This system of five equations and five unknowns has the solution (check) x = 116<br />
57 , y = − 44<br />
57 , z = 82<br />
λ = 20<br />
19 , µ = 52<br />
1<br />
57<br />
. The closest point is therefore: (x, y, z) =<br />
57<br />
(116, −44, 82).<br />
57 ,<br />
2
4. A container is constructed in the shape of a cylinder with a top and a bottom (e.g. a beer can). If the<br />
surface area of the container has a fixed value S, find the radius and height of the container that will<br />
maximize the enclosed volume.<br />
The volume of a cylinder is V = πr 2 h, while the surface area is S = 2πrh + 2πr 2 . Therefore, we wish<br />
to:<br />
maximize V = πr 2 h subject to S = 2πrh + 2πr 2 .<br />
Exercises<br />
Equating gradients, we find:<br />
These two equations are:<br />
∇V = λ∇S,<br />
π〈2 r h, r 2 〉 = 2πλ〈h + 2 r, r〉.<br />
2π r h = 2πλ(h + 2 r),<br />
π r 2 = 2πλ r.<br />
The second equation gives r = 0 or λ = r 2<br />
. Since r = 0 won’t maximize anything, inserting the second<br />
possibility into the first equation above:<br />
2π r h = 2π r (h + 2 r),<br />
2<br />
2 h = h + 2 r,<br />
h = 2 r.<br />
Therefore, the height is twice the size of the radius.<br />
1. Find the maximum value of f(x, y, z) = x + y + z on the sphere x 2 + y 2 + z 2 = 25;<br />
Equating gradients:<br />
∇f = λ∇F,<br />
〈1, 1, 1〉 = λ〈2 x, 2 y, 2 z〉,<br />
giving us three equations for four unknowns. Adding the constraint F = 0, we have four equations for<br />
four unknowns:<br />
1 = 2 λ x,<br />
1 = 2 λ y,<br />
1 = 2 λ z,<br />
x 2 + y 2 + z 2 = 25.<br />
Simplifying by substituting into the constraint equation, we find:<br />
( ) 1 2 ( ) 1 2 ( ) 1 2<br />
+ + = 25,<br />
2 λ 2 λ 2 λ<br />
3<br />
4 = 25λ2 ,<br />
3
or λ = ± √ 3/10. Choosing only the positive branch for the position (otherwise we actually find the<br />
minimum value of f), we find x = y = z = 5/ √ 3. Therefore, the maximum value of f on the sphere is<br />
f(5/ √ 3, 5/ √ 3, 5/ √ 3) = 5 √ 3.<br />
2. Let C be the curve of intersection of the surface y 2 −z 2 = 1 and the plane x−y = 1. Find the minimum<br />
value of f(x, y, z) = x 2 + y 2 + z 2 on C;<br />
Letting g 1 (x, y, z) = y 2 − z 2 − 1 = 0 and g 2 (x, y, z) = x − y − 1 = 0, we equate gradients:<br />
∇f = λ∇g 1 + µ∇g 2 ,<br />
〈2 x, 2 y, 2 z〉 = λ〈0, 2 y, −2 z〉 + µ〈1, −1, 0〉.<br />
These three equations with the two surfaces gives five equations for five unknowns:<br />
2 x − µ = 0,<br />
2 y − λ2 y + µ = 0,<br />
2 z + λ2 z = 0,<br />
y 2 − z 2 = 1,<br />
x − y = 1.<br />
From the last and first equations x = 1 + y and therefore µ = 2(1 + y). Inserting this into the second<br />
equation and simplifying:<br />
4 y − λ2 y = −2,<br />
z + λz = 0,<br />
y 2 − z 2 = 1.<br />
Therefore, from this middle equation, either z = 0 or λ = −1. If z = 0, then y = ±1 from the bottom<br />
equation and x = 1 ± 1 = 2, 0 from above. Therefore, f(x, y, z) = 0 2 + (±1) 2 + (1 ± 1) 2 = 3 ± 2. If<br />
λ = −1, then y = −1/3. However, if −1 < y < 1, then from the bottom equation z ∈ C and therefore<br />
the point is not on both curves. The minimum value is f(0, −1, 0) = 1.<br />
3. What is the volume of the largest rectangular box (with edges parallel to the axes) which can be<br />
inscribed in the ellipsoid x2<br />
36 + y2<br />
9 + z2<br />
16 = 1?<br />
Since x, y, and z are the coordinate lengths, the volumes of the rectangular boxes with edges parallel<br />
to the axes is V = 2 x2 y2 z = 8 x y z. Therefore, equating gradients:<br />
With the ellipsoidal constraint:<br />
∇V = λ∇E,<br />
〈 x<br />
8〈y z, x z, x y〉 = λ<br />
18 , 2 y<br />
9 , z 〉<br />
.<br />
8<br />
8 y z − λx<br />
18 = 0,<br />
8 x z − 2λy<br />
9 = 0,<br />
8 x y − λz<br />
8 = 0,<br />
x 2<br />
36 + y2<br />
9 + z2<br />
16 = 1.<br />
4
From the first equation λ = 144 y z<br />
x<br />
. Therefore:<br />
Simplifying the top two equations:<br />
8 x z − 288 y2 z<br />
= 0,<br />
9 x<br />
144 y z2<br />
8 x y − = 0,<br />
8 x<br />
x 2<br />
36 + y2<br />
9 + z2<br />
16 = 1.<br />
x 2 − 4 y 2 = 0,<br />
4 x 2 − 9 z 2 = 0,<br />
x 2<br />
36 + y2<br />
9 + z2<br />
16 = 1.<br />
Solving the top two equations for y 2 and z 2 and inserting in the ellipsoidal equation, we have:<br />
y 2 = x2<br />
4 ,<br />
z 2 = 4 x2<br />
9 ,<br />
x 2<br />
36 + x2<br />
36 + x2<br />
36 = 1.<br />
Therefore, x 2 = 12, or x = ±2 √ 3, y = ± √ 3, and z = ±4/ √ 3. Taking only the positive points, the<br />
largest box has the volume V (2 √ 3, √ 3, 4/ √ 3) = 64 √ 3.<br />
4. Find the point on the plane z = 4 x + 9 y which is closest to the point (1, 1, 2).<br />
We seek to minimize the distance (squared) from the point to the plane:<br />
minimize d 2 P = (x − 1) 2 + (y − 1) 2 + (z − 2) 2 subject to S = 4 x + 9 y − z = 0.<br />
Equating gradients, we find:<br />
With the planar constraint:<br />
∇d 2 P = λ∇S,<br />
2〈x − 1, y − 1, z − 2〉 = λ〈4, 9, −1〉.<br />
2(x − 1) − 4λ = 0,<br />
2(y − 1) − 9λ = 0,<br />
2(z − 1) + λ = 0,<br />
4 x + 9 y − z = 0.<br />
This system of four equations and four unknowns has the solution (check) x = 50<br />
49 , y = − 5<br />
49 , z = 55<br />
49 ,<br />
and λ = − 12<br />
49 . 5
This week, we will find the global minimum of the function:<br />
f(x, y) = e sin(50 x) + sin(60 e y ) + sin(70 sin(x)) + sin(sin(80 y)) − sin(10(x + y)) + x2 + y 2<br />
.<br />
4<br />
This is problem 4 in The SIAM 100-Digit Challenge [1]. For x and y large, f(x, y) is dominated by the<br />
paraboloid x2 +y 2<br />
4<br />
, since the values of the other terms lie in the intervals [1/e, e], [−1, 1], [−1, 1], [− sin 1, sin 1],<br />
and [−1, 1], respectively. Therefore, we know the minimum will be reasonably near the origin. However,<br />
what is reasonable? We can break the problem down into three steps:<br />
1. Find a bounded region that contains the minimum;<br />
2. Identify the rough location of the lowest point in that region;<br />
3. Zoom in closer to pinpoint the minimum to high precision.<br />
Part I<br />
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 can<br />
be 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.<br />
Therefore, the minimum must be inside the circle of radius 1.<br />
Part II<br />
Many animals and insects interact with eachother, whether this may be for the purposes of protection from<br />
predators, or for cooperation in hunting, finding shelter, or otherwise [2]. Bees, ants, birds, and fish have<br />
been studied in particular because they are all relatively easy to study. For example, bee hives host around<br />
5,000-10,000 bees, which is few enough to be individually counted and monitored. Insects can communicate<br />
with one another by releasing pheromones into the environment. These pheromones can indicate the source<br />
and quality of food, or a threat.<br />
PSO seeks to use simple algorithmic rules from the insect interactions, apply them to agents with random<br />
motion, and hope to derive meaningful global information of the problem the agents are trying to solve. For<br />
bees and ants that are harvesting food, they may look like [2]:<br />
1. Wander to find food;<br />
6
2. When I find food, harvest it and lay a trail of pheromones back to hive/hill;<br />
3. If I find a trail, follow it, harvest food, and reinforce the shortest trail with pheromones to hive/hill.<br />
Bees and ants have become the prototype species for PSO and Ant-Colony Optimization (ACO). While they<br />
are similar, the ACO is very similar to the simple rules above, while the PSO takes advantage of the ability<br />
of bees to fly. This results in the Particle Swarm Optimization algorithm [3]:<br />
1. Initialization of agents i = 1, . . . , N, with random positions ⃗x i and speeds ⃗v i ;<br />
Loop over all agents<br />
2. Evaluate the function f(⃗x i );<br />
3. Compare the value of the function f(⃗x i ) with the best value of the agent. Let this be the vector ⃗p. If the<br />
current value is the best, replace it;<br />
4. Identify the agent with the best value ⃗p. Let this be the vector ⃗g representing the entire swarm’s best<br />
value;<br />
5. Update the agents’ positions and velocities as:<br />
⃗v i ← ω⃗v i + φ p U(0, 1) ⊗ (⃗p i − ⃗x i ) + φ g U(0, 1) ⊗ (⃗p g − ⃗x i ),<br />
⃗x i ← ⃗x i + ⃗v i . (1)<br />
6. Terminate when the optimal value (to an error tolerance) is obtained.<br />
End loop<br />
In (1), 0 < ω < 1 is an inertial term, −2 < φ p < 2, −2 < φ g < 2, ⊗ denotes component-wise multiplication,<br />
and U(0, 1) denotes a uniformly distributed random variable on the interval [0, 1].<br />
Part III<br />
To get really high precision result, we need something that converges very quickly. Remember the Newton-<br />
Raphson method? Suppose we want to find the solution to:<br />
Using the linear approximation to f ′ (x i ), we have:<br />
Setting the linear approximation to 0, we solve:<br />
min f(x) =⇒ f ′ (x) = 0. (2)<br />
L(x) = f ′ (x i ) + (x − x i )f ′′ (x i ). (3)<br />
0 = f ′ (x i ) + (x i+1 − x i )f ′′ (x i ), (4)<br />
for x i+1 as:<br />
Suppose, now we have two variables:<br />
x i+1 = x i − f ′ (x i )<br />
f ′′ (x i ) . (5)<br />
min f(x, y) =⇒ ∇f(x, y) = 0. (6)<br />
7
But setting the gradient to 0 is actually a system of two equations:<br />
f x (x, y) = 0, (7)<br />
f y (x, y) = 0, (8)<br />
with two unknowns x and y. Fortunately, we can form the tangent plane approximation (the generalization<br />
of the linear approximation) to both equations:<br />
T fx (x, y) = f x (x i , y i ) + (x − x i )f xx (x i , y i ) + (y − y i )f xy (x i , y i ), (9)<br />
T fy (x, y) = f y (x i , y i ) + (x − x i )f xy (x i , y i ) + (y − y i )f yy (x i , y i ), (10)<br />
Setting both equations simultaneously to 0 at the new iterate (x i+1 , y i+1 ), we have:<br />
[<br />
] [ ] [ ]<br />
f xx (x i , y i ) f xy (x i , y i ) x i+1 − x i f x (x i , y i )<br />
= −<br />
. (11)<br />
f xy (x i , y i ) f yy (x i , y i ) y i+1 − y i f y (x i , y i )<br />
This is a familiar system of two equations for two unknowns. We can solve this!<br />
[<br />
] [<br />
x i+1<br />
=<br />
y i+1<br />
] [<br />
x i<br />
−<br />
y i<br />
f xx (x i , y i ) f xy (x i , y i )<br />
f xy (x i , y i ) f yy (x i , y i )<br />
] −1 [<br />
f x (x i , y i )<br />
f y (x i , y i )<br />
]<br />
. (12)<br />
References<br />
[1] F. Bornemann et al. Think Globally, Act Locally in The SIAM 100-Digit Challenge, SIAM, 4:77–100,<br />
2004.<br />
[2] M. Beekman et al. Biological Foundations of Swarm Intelligence in Swarm Intelligence, Springer-Verlag,<br />
1:3–41, 2008.<br />
[3] J. Kennedy and R.C. Eberhart Particle swarm optimization, Proceedings of the IEEE international<br />
conference on neural networks IV, 1942–1948, 1995.<br />
8