Each student will get individual data for the assignment.

Here is the problem:

Theoretical results imply that the function f(x,y,z) = x^{2}+x+3yz has a maximum and a minimum on the (solid) ball defined by g(x,y,z) = x^{2}+y^{2}+z^{2}≤ 1. Find these maximum and minimum values by

- examining critical points in the interior of the ball, and
- using Lagrange multipliers to find maximum and minimum values on the boundary of the ball.

We first discuss the problem of finding critical points of the objective
function and determining whether or not they are relevant to our problem.
A critical point of f(x,y,z) is determined by the condition
∇f(x,y,z) = 0. Since our objective function is quadratic
the resulting equations will be linear and will have a unique solution (or,
in general, possibly an infinite number of solutions, but the latter case
will not occur for data in this lab). In our example
∇f(x,y,z) = <2x+1,3z,3y>, so that the equations to be
solved are 2x+1 = 0, 3z = 0, and 3y = 0.

Here is one way to get `Maple` to solve
these (rather trivial, in this example) equations and to test the resulting
critical point.

> f:=x^2+x+3*y*z; f := x^{2}+ x + 3 y z > g:=x^2+y^2+z^2; g := x^{2}+ y^{2}+ z^{2}> CPeqx:=diff(f,x)=0; CPeqx := 2 x + 1 = 0 > CPeqy:=diff(f,y)=0; CPeqy := 3 z = 0 > CPeqz:=diff(f,z)=0; CPeqz := 3 y = 0 > CPsol:=solve({CPeqx,CPeqy,CPeqz}); CPsol := { x = -1/2, y = 0, z = 0 } > CPgvalue:=subs(CPsol,g); CPgvalue := 1/4 > CPfvalue:=subs(CPsol,f); CPfvalue := -1/4

** In this case, because the value of g at the critical point is less
than 1, the critical point lies inside the domain of interest, and CPfvalue is a candidate for an extreme value
of the objective function.**

To appreciate the method of Lagrange multipliers it is helpful to visualize
the constraint surface together with surfaces on which the objective
function is constant: f(x,y,z) = C. The first picture on the
right shows the sphere together with the surface on which f = C
with C = 1; the latter surface is a
*hyperboloid of one sheet*. The choice C = 1 is not
significant here; it shows a typical situation. The hyperboloid divides
the sphere into two pieces. On one piece of the sphere, the function
f(x,y,z) has values larger than 1, and on the other piece the values of the
function are less than 1. Clearly 1 is not an extreme value.

The second picture shows the sphere together with the surface
f(x,y,z) = 2 (again a hyperboloid of one sheet). Now the
hyperboloid does not cut the sphere into two pieces; it just touches it
tangentially at a single point. The value of f(x,y,z) at any points other
than that point of tangency must be less than 2, so that 2 must be the maximum
value of f(x,y,z) on the sphere.

The first picture above was drawn with the following `Maple` commands (similar commands were used for
the second picture and other pictures below):

*
pg:=implicitplot3d(x^2+y^2+z^2=1,x=-2..2,y=-2..2,z=-2..2,axes=none,numpoints=1800,color=blue):
p1:=implicitplot3d(x ^{2}+x+3*y*z=.5,x=-2..2,y=-2..2,z=-2..2,axes=none,numpoints=1800,color=green);
pt1:=textplot3d([-1.0,2.5,-2,typeset(f(x,y,z)=1)],font=[Helvetica,16],axes=none):
display3d(pg,p1,pt1,orientation=[50,20,0]);*

Here the ` implicitplot3d` commands
create the pictures of the two surfaces, the

∇f(x,y,z)=λ∇g(x,y,z)

Here λ is a real number, and the equality indicates that the tangent planes are parallel because the normal vectors are pointing in the same direction. This one vector equation is three scalar equations.

g(x,y,z)=1

This guarantees that the solutions we seek will be on the constraint surface.

In this specific case, we want to solve these equations

2x+1= λ(2x)

3z=λ(2y)

3y=λ(2z)

1=x^{2}+y^{2}+z^{2}

> with(RealDomain): > LMeqx:=diff(f,x)=L*diff(g,x); LMeqx := 2 x + 1 = 2 L x > LMeqy:=diff(f,y)=L*diff(g,y); LMeqy := 3 z = 2 L y > LMeqz:=diff(f,z)=L*diff(g,z); LMeqz := 3 y = 2 L z > LMsols:=solve({LMeqx,LMeqy,LMeqz,g=1}); LMsols := { L = 3/2, x = 1, y = 0, z = 0 }, { L = 1/2, x = -1, y = 0, z = 0 }, { L = -3/2, x = -1/5, y = -2 √3 / 5, z = 2 √3 / 5 }, { L = -3/2, x = -1/5, y = -2 √3 / 5, z = 2 √3 / 5 }, > LMvalues:=seq(subs(LMsols[j],f),j=1..nops({LMsols})); LMvalues := 2, 0, -8/5, -8/5

- The picture of the the constraint surface, together with the surface f(x,y,z) = 2 corresponding to the maximum value of the objective function, was shown and discussed above.
- The first picture on the right shows the constraint surface together
with with the level surface f(x,y,z) = C with
C = −8/5, the minimum value of the objective function. Now
the surface f = −8/5 is a
*hyperboloid of two sheets*. Each sheet has a point of tangency with the sphere, these points correspond to the two solutions of the equations which give the same, minimum, value of f(x,y,z). - The second picture immediately above shows the constraint surface
together with with the level surface f(x,y,z) = C with
C = 0; this is the value that f(x,y,z) takes at the second
solution of the Lagrange multiplier equations found above. The two
surfaces do indeed have a point of tangency, as follows from the Lagrange
multiplier equations, but they also intersect transversely at other points,
corresponding to the fact that both positive and negative values of
f(x,y,z) occur on the sphere.
The graph on the right shows a close-up picture of the point of tangency between the sphere and the surface f(x,y,z) = 0. (This is not quite true, because the picture was actually obtained from the objective function x+3xy, but this makes no essential difference.) One can see there how the two surfaces have a point of tangency as well as points where they cross transversely. The objective function, restricted to the surface of the sphere, has a saddle behavior.

−1/4at the critical point itself. The Lagrange multiplier equations gave us three candidate values:

2, 0, and −8/5,By inspection of these four values we conclude that the maximum value is 2 and the minimum is −8/5. If the critical point had not fallen inside the domain g ≤ 1 then we would have had to consider only the values from the Lagrange multiplier analysis.

The maximum value of this F on the unit sphere is 1, and this value occurs only at the point (1,0,0). The minimum value is −1, which occurs only at the point (−1,0,0). A picture of the constraint surface and the level surface of the objective function which corresponds to the maximum value, the graph of x+0.5yz=1, is shown to the right.

Algebraically, this is a solution to the Lagrange multiplier equations which has both y=0 and z=0. This sort of solution is exactly one which may be thrown away when people compute "by hand".

Here is a sequence of `Maple` commands
similar to those above done. We only display the results of the last
command. This should give the values of the objective function which
result. The extreme values should be among these "candidates".

The values which> F:=x+0.5*y*z: > g:=x^2+y^2+z^2: > LMeqx:=diff(F,x)=L*diff(g,x): > LMeqy:=diff(F,y)=L*diff(g,y): > LMeqz:=diff(F,z)=L*diff(g,z): > LMsols:=solve({LMeqx,LMeqy,LMeqz,g=1}): > LMvalues:=seq(subs(LMsols[j],x+.5*y*z),j=1..nops({LMsols})); LMvalues := 1., -1., 1.250000000, 1.250000000, -1.250000000, -1.250000000}

To the right is a graph of the unit sphere and the surface
x+0.5yz=1.25, at an angle similar to what was just shown before. **The
surface for the candidate "extreme value" does not seem to touch the
unit sphere! What happened?**

Let's show a bit more information about by looking in detail at the
result of one of the intermediate steps, the ` solve` command.

The third element of> LMsols:=solve({LMeqx,LMeqy,LMeqz,g=1}); LMsols := {z = 0., x = 1., y = 0., L = 0.5000000000}, {z = 0., y = 0., x = -1., L = -0.5000000000}, {x = 2., L = 0.2500000000, z = 1.224744871 I, y = 1.224744871 I}, {x = 2., L = 0.2500000000, z = -1.224744871 I, y = -1.224744871 I}, {x = -2., z = 1.224744871 I, y = -1.224744871 I, L = -0.2500000000}, {x = -2., y = 1.224744871 I, z = -1.224744871 I, L = -0.2500000000}

where

Here is a quote from a `Maple help`
page. It is an important part of the design of `Maple` which should be known to every user:

By default, Maple performs computations under the assumption that the underlying number system is the complex field.

So, for example, we have:

The> solve(x^2+1); I, -I

When the> with(RealDomain): > solve(x^2+1); > LMsols:=solve({eqx,eqy,eqz,g=1}); LMsols := {z = 0., x = 1., y = 0., L = 0.5000000000}, {z = 0., y = 0., x = -1., L = -0.5000000000} > values:=seq(subs(LMsols[j],x+.5*y*z),j=1..nops({LMsols})); values := 1., -1.

** Maintained by the Math 251 guru, currently (Spring
2015) E. Speer,
speer@math.rutgers.edu. Last modified 3/8/2015.
**