Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: Optimize function over unit ball

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

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

    3. The attempt at a solution
    [itex]\nabla[/itex]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([itex]\theta[/itex], [itex]\varphi[/itex]) = sin2[itex]\theta[/itex](cos[itex]\theta[/itex] + 1)cos[itex]\varphi[/itex]sin[itex]\varphi[/itex].
    Then it's rather obvious that to get max, [itex]\theta[/itex] = +-[itex]\pi[/itex]/2 and [itex]\varphi[/itex] = [itex]\pi[/itex]/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. jcsd
  3. Aug 11, 2011 #2


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

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

    Your spherical coordinate formula is right, but you didn't maximize it correctly.
    Last edited: Aug 11, 2011
  4. Aug 11, 2011 #3

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

    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.

  5. Aug 12, 2011 #4
    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 [itex]z = \sqrt{1 - x^2 - y^2}[/itex] but that makes it kinda complicated, is there no faster/easier way?

    When you say maximizing with respect to [itex]x[/itex] and [itex]y[/itex], do you mean setting the gradient of [itex]f(x, y, h(x, y))[/itex] to 0? where [itex]h(x, y) = \sqrt{1 - x^2 - y^2}[/itex].
  6. Aug 12, 2011 #5
    Substitution and then setting gradient to 0 got me (x, y) = (+- 1, +- 1) for which z = sqrt(-1)...
  7. Aug 12, 2011 #6


    User Avatar
    Science Advisor

    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 [itex]g(x,y,z)= x^2+ y^2+ z^2= 1[/itex]
    That will happen the two gradient vectors are parallel- when [itex]\nabla f= \lambda \nabla g[/itex] for some constant [itex]\lambda[/itex].
  8. Aug 12, 2011 #7

    Ray Vickson

    User Avatar
    Science Advisor
    Homework Helper

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

  9. Aug 12, 2011 #8


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    What is your expression for the gradient?


    [tex]g(x,y) = f(x,y,\sqrt{1-x^2-y^2}) = xy(\sqrt{1-x^2-y^2} + 1)[/tex]

    I get

    [tex]\frac{\partial g}{\partial x} = y\left(\sqrt{1-x^2-y^2} + 1 - \frac{x^2}{\sqrt{1 - x^2 - y^2}}\right)[/tex]

    and a similar expression for [itex]\partial g/\partial y[/itex]:

    [tex]\frac{\partial g}{\partial y} = x\left(\sqrt{1-x^2-y^2} + 1 - \frac{y^2}{\sqrt{1 - x^2 - y^2}}\right)[/tex]

    If [itex](x,y)[/itex] is a critical point, and [itex]x[/itex] and [itex]y[/itex] 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 [itex]x^2 = y^2[/itex], 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 [itex](x,y) = (\pm 2/3, \pm 2/3)[/itex].
    Last edited: Aug 12, 2011
  10. Aug 12, 2011 #9
    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...
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook