# Maximum and minimum of f(x,y) within a confined domain

1. May 11, 2012

### Mathoholic!

1. The problem statement, all variables and given/known data

f(x,y)=2x3-2y3-3x2

K={(x,y)$\in$ℝ2:x2+y2≤5,y≤0}

Find the maximum and minum of f(x,y) within K.

2. Relevant equations

∇f(x,y)=(6x2-6x,-6y)

Hess(f)=diag(12x-6,-6) (relevant?)

3. The attempt at a solution

What I've done so far was calculate the pair(s) (x,y) that make ∇f(x,y)=(0,0).
It gave me: (0,0) and (1,0).
Now, both these points belong to K (a semicircle), thus, I would assume them to be good candidates but they're not.

The solution to the problem is: (√5,0) and (-√5,0).

Am I doing something wrong? How do I proceed about when presented with maxima and minima confined to a limited region of space?

2. May 11, 2012

### cjc0117

You're not considering points on the boundary of K. Just like endpoints can be absolute max/mins when we are dealing with functions of single variables, so too boundary points can be absolute max/mins when dealing with multivariable functions.

K in our case happens to be the portion of the circle x2+y2≤5 on and below the y-axis (y≤0). The equation of the two curves that close this set are thus $y=-\sqrt{5-x^{2}}$ and $y=0$

Thus, $f(x,y)=f(x,-\sqrt{5-x^{2}})=2x^{3}-2(-\sqrt{5-x^{2}})^{3}-3x^{2}$ on the boundary of the semicircle. Use techniques of single variable calculus to find the critical points of this function.
Also, don't forget the line y=0, which is also a boundary of K. Here, $f(x,y)=f(x,0)=2x^{3}-3x^{2}$. Again, use techniques of single variable calculus to find critical points.

After finding all critical points, evaluate f(x,y) at each critical point to find the absolute max/min values.

EDIT: As HallsofIvy pointed out, the endpoints of those single variable functions $f(x,-\sqrt{5-x^{2}})$ and $f(x,0)$ are also possible max/mins for f(x,y). In both cases, $-\sqrt{5}≤x≤\sqrt{5}$.

Last edited: May 11, 2012
3. May 11, 2012

### HallsofIvy

Theorem: A continuous function takes on both max and min values on a closed and bounded set. Further, if the max or min occur on the interior of the set, then the partial derivatives are all 0 at that point.

So to find such max and min you first look for places in the interior where the partial derivatives are 0, (0, 0) and (1, 0). However, then you must look on the boundary, which, here, is the circle with center at (0, 0) and radius 5. Since that boundary is a one dimensional curve we can write it it terms of a single parameter. The simplest thing to do is to use polar coordinates- the curve is given by $x= 5 cos(\theta)$ and $y= 5 sin(\theta)$ with. On that circle the f(x,y) becomes $f(\theta)= 250 cos^3(\theta)- 250 sin^3(\theta)- 75 cos^2(\theta)$ with $-\pi< \theta< 0$. Another part of the boundary is the "base", y= 0, where $f(x,y)= f(x, 0)= 2x^3- 3x^2$. To find max and min on the interior of those curves, set the derivatives equal to 0. Finally, you will need to check the boundaries of those, the endpoints, (5, 0) and (-5, 0).
That is, find all points, in the interior of the set, where $f_x= f_y= 0$, all points on the two curves where $f_\theta= 0$ or $f_x= 0$, and, finally, the two points (5, 0) and (-5, 0). Check the values of the function at each of those points.

Last edited by a moderator: May 11, 2012
4. May 11, 2012

### cjc0117

@HallsOfIvy

The radius of the semicircle is $\sqrt{5}$, not 5.

5. May 11, 2012

### HallsofIvy

Yes, thanks.

6. May 11, 2012

### Mathoholic!

So, let's see if I got this right:

I have a function f(x,y) with its graph in space: (x,y,2x3-2y3-3x2). If they hadn't give me the restriction K, the only two candidates to maximum and minimum would have been the (x,y) pairs for which ∇f(x,y)=(0,0), which are (0,0) and (1,0).

When they give a set K and tell me to find a maximum and a minimum in that region defined by K, not only do I have to consider if the previously found critical points fit K but I have to check the boundaries of K (as I would, similarly, check the endpoints of a single variable function).

Having all the (x,y) pairs: (0,0);(1,0);(-√5,0);(√5,0);(2,-1), I only need to evaluate the f(x,y):

f(0,0)=0
f(1,0)=-1
f(-√5,0)=-15-10√5
f(√5,0)=-15+10√5>0
f(2,-1)=6<f(√5,0)

Therefore, I can conclude that f(√5,0) is the maximum and f(-√5,0) is the minimum.

Is this right?

7. May 11, 2012

### cjc0117

Yes.

8. May 11, 2012

### Ray Vickson

In general, derivatives need not vanish at optima that lie on the boundary. The simplest example of this is: max or min f(x) = x, subject to 0 ≤ x ≤ 1. The min is at x=0, and the max is at x=1, but f'(x) = +1 at both those points. Have you taken the Karush-Kuhn-Tucker conditions yet? They are what would apply to your problem.

RGV

9. May 11, 2012

### Mathoholic!

No, I haven't. I'm at the first year of physics degree. I have no idea of when I'll learn KKT conditions .-.

10. May 11, 2012

### Ray Vickson

OK, here is how they would look. Your problem is max/min f(x,y) = 2x^3-2y^3-3x^2. subject to g(x,y) <= 0 and y <= 0, where g(x,y) = x^2 + y^2 - 5.

Say we want the maximizing point (x*,y*). Here are some obvious facts: (1) either g(x*,y*) < 0 or g(x*,y*) = 0; and (2) either y* < 0 or y* = 0.

We form a Lagrangian L = f(x,y) - u*g(x,y), u >= 0. [Note the sign!] For a max problem with an inequality constraint, the Lagrangian should be better than (or at least as good as) the objective at feasible points, so it should have the form f -(negative) > f; thus, if g < 0 we need to subtract u*g, with u >= 0. Here, u is a Lagrange multiplier---often denoted as λ---but u is easier to type. Then, at a maximizing point (x*,y*) we have:
(1) ∂L/∂x = 0 (because x did not have a sign restriction); (2) ∂L/∂y ≥ 0, and either y = 0 or ∂L/∂y = 0; (3) g ≤ 0, u ≥ 0 and either g = 0 or u = 0.

Unfortunately, getting the solution can involve a number of cases, corresponding to the "either-or" statements above. It is usually easier to try to first gain some insights into the nature of a solution, so that one can (hopefully) make the correct choices in the either-or conditions. That still leaves the question of how one does second-order tests for a max (or a min) in such cases. I will leave that question for now.

For the min problem, you could either change the Lagrangian to L = f + u*g, with u >= 0), or keep the same Lagrangian L= f - u*g as above, but change the sign condition to u <= 0. In either case the y-derivative conditions would change to ∂L/∂y ≤ 0, and either this = 0 or y = 0.

For your problem I would suggest you solve two problems: (1) max(or min) f(x,0) subject to g(x,0) <= 0 (this takes y = 0); it is a univariate maximization, and the x-constraint is a simple interval restriction -sqrt(5) <= x <= sqrt(5). (2) max (or min) f(x,y), subject to g(x,y) = 0, which can be attacked by various methods (the simplest being a change to polar coordinates x = sqrt(5)*cos(t), y = -sqrt(5)*sin(t), with 0 <= t ,= pi). You can think about why solving these two cases covers all the possibilities.

RGV