# Finding maximum and minimum values of 3 dimensional function

1. Oct 31, 2015

### Inveritatem

1. The problem statement, all variables and given/known data
Find the maximum and minimum values of f(x,y,z) = x^2 - 2x + y^2 - 4y + z^2 - 4z in the region x^2 + y^2 + z^2 <= 36.

2. Relevant equations
Lagrange multipliers
<Fx, Fy, Fz> = lambda<Gx, Gy, Gz>

Test for local extrema
If Determinant D(x,y) < 0 it is a saddle point
If D(x,y) > 0:
If Fxx > 0, then it is a local minimum
If Fxx < 0, then it's a local maximum

3. The attempt at a solution
Tried to solve for system of equations that result in 4 equations

2x-2 = lambda * 2x
2y-4 = lambda * 2y
2z-4 = lambda * 2z
X^2 + y^2 + z^2 = 36

I solved for lambda = 1/2 or 3/2 by solving for x y and z and substituting into the 4th equation.
I got (2,4,4) =0 and (-2,-4,-4) =72. BUT the minimum was actually (1,2,2) = -9 because I was supposed to "check the interior of the sphere". Am I just supposed to account for the possibility that lambda = 0?

2. Oct 31, 2015

### Staff: Mentor

For the minimum you don't need Lagrange multipliers. Setting them to zero seems to work as well.

3. Oct 31, 2015

### Ray Vickson

For either the max or the min, the solution will either be in the interior or on the boundary. The interior stationary point is a global min in $\mathbb{R}^3$ and obeys the constraint, so is the global min of the constrained problem. (The second-order test implies that the unconstrained stationary point is a min, but you do not need such a fancy test: just use the fact that f = sum of squares + linear to give the result automatically.)

For the way you wrote the Lagrangian equations, a positive lagrange multiplier is a necessary condition for a MAXIMUM, so both of your candidate boundary points satisfy the first-order necessary conditions for a constrained maximum. The second-order *sufficient* conditions for a max are much trickier than you may think, because you have a point on a boundary of an inequality constraint. Basically, you need to project the Hessian of the *Lagrangian* (not the function f!) down to the tangent space of the constraint, and determine if it is negative definite in that subspace.

However, in this case you can by-pass all that because you have both possible points, so can just take the one with the larger f-value.

Last edited: Oct 31, 2015
4. Nov 1, 2015

### HallsofIvy

Staff Emeritus
In the interior of the sphere, $\nabla f= (2x- 2)\vec{i}+ (2y- 4)\vec{j}+ (2z- 4)\vec{k}$. Set that equal to 0 and solve for x, y, and z to find any critical points in the interior of the sphere. Your Lagrange multiplier method will solve for max or min among points that satisfy the equation x^2+ y^2+ z^2= 36, on the surface of the sphere. Another way to do that is to use parametric equations for the sphere: $x= 6cos(\theta)sin(\phi)$, $y= 6 sin(\theta)sin(\phi)$, $z= 6 cos(\phi)$. Putting those into the function, $f(\theta, \phi)= 36- 12cos(\theta)sin(\phi)- 24sin(\theta)si(\phi)- 24 cos(\phi)$. Set the gradient of that two variable function to 0 to find any critical points on the surface of the sphere. Find the value of the function at each critical point to determine the absolute max and min.

5. Nov 1, 2015

### Inveritatem

Sorry for the late reply. How does using the fact that the sum of the squares + linear establish that (1,2,2) is the global min? We were told to use geometry to show what the min and max are because we do not use advanced calculus to prove these mins and maxes? How can we use geometry/equations to prove these are the min and max values?

6. Nov 1, 2015

### Ray Vickson

The surface $w = x^2 - 2x + y^2 - 4y + z^2 - 4z$ is a bit hard to visualize, because it is a 3-dimensional object lying in 4 dimensions.

To gain insight, drop $z$ and look at the 2-dimensional surface $w = x^2 - 2x + y^2 - 4y$ in 3-dimensional $(x,y,w)$-space. This surface is cup-shaped, opening up as we go farther and farther out in the $(x,y)$ plane; you could fashion it out of sheet metal and it would very nicely hold rainwater. Its bottom is where all derivatives = 0, and there is only one such point. Now just imagine doing the same in a higher dimension.

Alternatively, you can re-write $f(x,y,z)$ by "completing the squares"; that will show the geometry very plainly.

BTW: I did not assume you would follow my remarks about Hessians projected down into tangent subspaces and the like; I just wanted to de-rail any thoughts you might have had about looking at the second derivatives in the way you did. In this case that works for the minimum (because the minimum is the same in the unconstrained problem and the constrained problem---that is, the constraint does not affect the minimum in this case), but those simple tests would lead you very far astray in the maximization case! They would also lead you astray in other cases of minimization where the constraint is active at the solution.

Last edited: Nov 1, 2015