# Optimize function over unit ball

1. Aug 11, 2011

### Inertigratus

1. The problem statement, all variables and given/known data
Find the maximum and minimum value of the function, defined over x2 + y2 + z2 $\leq$ 1.
x $\geq$ 0, y $\geq$ 0, y $\geq$ 0.

2. Relevant equations
f(x,y,z) = xy(z+1)

3. The attempt at a solution
$\nabla$f = (y(z+1), x(z+1), xy) = 0
Gets me (0, y, -1), (x, 0, -1), (0, 0, z) and they all result in f(x,y,z) = 0.
Then I wasn't sure how to find the values on the sphere.
What I did was I switched to spherical coordinates with r = 1 and plugged them into the eq.
f($\theta$, $\varphi$) = sin2$\theta$(cos$\theta$ + 1)cos$\varphi$sin$\varphi$.
Then it's rather obvious that to get max, $\theta$ = +-$\pi$/2 and $\varphi$ = $\pi$/4.
Plugging that back into the cartesian coordinates and into the function gives +- 1/2.
Maximum is supposed to be 16/27 and minimum 0.

By the way, this problem comes before the problems that are about optimizing functions with constraints. So no need to use the lagrange multiplier.

Any ideas? :)

2. Aug 11, 2011

### jbunniii

To do it in cartesian coordinates, try substituting $z = \sqrt{1 - x^2 - y^2}$ into the formula for $f$ and maximizing with respect to $x$ and $y$.

Your spherical coordinate formula is right, but you didn't maximize it correctly.

Last edited: Aug 11, 2011
3. Aug 11, 2011

### Ray Vickson

Look at f(x,y,z). For x , y and z >= 0, all its factors are >= 0, so f >= 0. Since you can have f = 0 (for example, by taking x=0 or y=0, etc.) the minimum value is f = 0. The gradient of f need not be zero at these minimizing points. Now consider the case f(x0,y0,z0) > 0 (so x0 > 0, y0 > 0 and z0 < -1). If x0^2 + y0^2 + z0^2 < 1 we can set x = c*x0, y = c*y0 and z = z0 to get f(cx0,cy0,z0) = c^2*f(x0,y0,z0) > f(x0,y0,z0) if c > 1. Increase c until we have c^2(x0^2 + y0^2) + z0^2 = 1, and the resulting point (x,y,z) will have a larger f-value than (x0,y0,z0). In other words, the solution to the max f problem must *always* lie on the boundary x^2 + y^2 + z^2 = 1.

RGV

4. Aug 12, 2011

### Inertigratus

I think I understand, but how does that help us find the point at which maximum occurs?
My problem is, I don't know how to analyze the border when the border is a surface.

I tried substituting for $z = \sqrt{1 - x^2 - y^2}$ but that makes it kinda complicated, is there no faster/easier way?

When you say maximizing with respect to $x$ and $y$, do you mean setting the gradient of $f(x, y, h(x, y))$ to 0? where $h(x, y) = \sqrt{1 - x^2 - y^2}$.

5. Aug 12, 2011

### Inertigratus

Substitution and then setting gradient to 0 got me (x, y) = (+- 1, +- 1) for which z = sqrt(-1)...

6. Aug 12, 2011

### HallsofIvy

Staff Emeritus
For the surface, I would use a Lagrange multiplier method: you want to maximize f(x,y,z)= xy(z+ 1) subject to the condition that $g(x,y,z)= x^2+ y^2+ z^2= 1$
That will happen the two gradient vectors are parallel- when $\nabla f= \lambda \nabla g$ for some constant $\lambda$.

7. Aug 12, 2011

### Ray Vickson

Yes, exactly, since you are not yet "allowed" to use Lagrange multipliers.

RGV

8. Aug 12, 2011

### jbunniii

What is your expression for the gradient?

For

$$g(x,y) = f(x,y,\sqrt{1-x^2-y^2}) = xy(\sqrt{1-x^2-y^2} + 1)$$

I get

$$\frac{\partial g}{\partial x} = y\left(\sqrt{1-x^2-y^2} + 1 - \frac{x^2}{\sqrt{1 - x^2 - y^2}}\right)$$

and a similar expression for $\partial g/\partial y$:

$$\frac{\partial g}{\partial y} = x\left(\sqrt{1-x^2-y^2} + 1 - \frac{y^2}{\sqrt{1 - x^2 - y^2}}\right)$$

If $(x,y)$ is a critical point, and $x$ and $y$ are nonzero, then the expressions in parentheses must be zero.

I'll let you fill in the details. After a bit of manipulation, you can show that $x^2 = y^2$, and then substituting this into each equation yields one equation that depends only on x, and another that depends only on y. I ended up getting $(x,y) = (\pm 2/3, \pm 2/3)$.

Last edited: Aug 12, 2011
9. Aug 12, 2011

### Inertigratus

Oh, yes I got that too... but I think I forgot the " + 1" on the partial derivatives, which changed it all.

Right..., I tried the Lagrange multiplier and got that the right answer. Was just going to write how I did it, because I did something wrong at first and got something else. It's crazy how many mistakes I do sometimes...

Thanks all, now I understand it better!

I just hope I won't be keep making these "minor" mistakes on the exam...