Maximizing a multivariate function under a constraint

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 5K views
Bipolarity
Messages
773
Reaction score
2

Homework Statement




Consider [itex]f(x,y) = \frac{1}{x} - \frac{1}{y}[/itex]

You need to maximize [itex]f(x,y)[/itex] given the constraint:
[itex]x + y = 11[/itex]


Homework Equations


I have never solved a problem like this before. In fact I made up a problem a few minutes ago.


The Attempt at a Solution


I can only imagine graphing f(x,y) on the x,y plane and seeing the maximum point of intersection with the plane of constraint. Actually I am not even sure if that is right.

BiP
 
Physics news on Phys.org
Bipolarity said:

Homework Statement



Consider [itex]f(x,y) = \frac{1}{x} - \frac{1}{y}[/itex]

You need to maximize [itex]f(x,y)[/itex] given the constraint:
[itex]x + y = 11[/itex]

Homework Equations


I have never solved a problem like this before. In fact I made up a problem a few minutes ago.

The Attempt at a Solution


I can only imagine graphing f(x,y) on the x,y plane and seeing the maximum point of intersection with the plane of constraint. Actually I am not even sure if that is right.

BiP

Homework Statement



Homework Equations



The Attempt at a Solution

Solve for y: [itex]x + y = 11[/itex] .

Plug that into [itex]\displaystyle f(x,y) = \frac{1}{x} - \frac{1}{y}[/itex], so that you have a function of x only.
 
SammyS said:
Solve for y: [itex]x + y = 11[/itex] .

Plug that into [itex]\displaystyle f(x,y) = \frac{1}{x} - \frac{1}{y}[/itex], so that you have a function of x only.

I see. The single-variate function of x that is obtained once I do that: what is its visual relationship to the graphs of f(x,y) and x+y=11 ?

Is it their intersection? It would be helpful to have a visual reference for each step so I can clearly understand what's going on.

BiP
 
Bipolarity said:
I see. The single-variate function of x that is obtained once I do that: what is its visual relationship to the graphs of f(x,y) and x+y=11 ?

Is it their intersection? It would be helpful to have a visual reference for each step so I can clearly understand what's going on.

BiP

Say you have a problem of the form max f(x,y), subject to g(x,y) = 0, with both f and g at least once continuously differentiable. In your case
[tex]f(x,y) = \frac{1}{x} - \frac{1}{y} \text{ and } g(x,y) = x+y-11[/tex]
but the basic idea is more general. The constraint g=0 gives a curve C in the (x,y)-plane from which we want to select the point (x,y) giving the largest f. What conditions must hold at the optimal solution p* = (x*,y*) (assuming there IS a finite solution)? Basically, the gradient vectors [itex]Df =\nabla f[/itex] and [itex]Dg = \nabla g[/itex] must be parallel or antiparallel at p*. The reason is this: if [itex]Df[/itex] and [itex]Dg[/itex] point along different lines, there is a nonzero component of [itex]Df[/itex] that is perpendicular to [itex]Dg[/itex], so is tangent to C at the point p*; and that means that by going away from p* (but staying in C), we can make f go up a bit. That would mean that f(p*) is not the maximum. Therefore, to prevent this from happening we need the two gradient vectors to point along the same line (but maybe in opposite directions).

If you imagine a plot of "level curves" of f and g (like the constant-altitude contours in a hiker's area map), then at the point p* the level curves of f and g are parallel---that is, they have the same tangent line.

The geometric property above can be expressed by saying that at p* there is a scalar λ such that [itex]\nabla f = \lambda \nabla g[/itex]. The scalar is usually called the Lagrange Multiplier, and the optimization rule amounts to saying that the so-called Lagrangian
[itex]L = f - \lambda g[/itex] must be stationary at p*; that is, we need [itex]\nabla L = 0[/itex] at p* = (x*,y*). Note that λ is not a function of x or y.

So, let's do this for your problem:
[tex]L = \frac{1}{x}-\frac{1}{y} - \lambda(x+y-11).[/tex]
We have
[tex]\frac{\partial L}{\partial x} = 0 \longrightarrow -\frac{1}{x^2} - \lambda = 0,\\<br /> \frac{\partial L}{\partial y} = 0 \longrightarrow +\frac{1}{y^2} - \lambda = 0.[/tex]
From this, we see that [itex]x^2 = -y^2[/itex] at [itex]x = x^*,\, y = y^*,[/itex] and that can only happen if [itex]x^* = y^* = 0.[/itex] But f(0,0) is not defined, so there is no optimal solution. You can also see that this is the case by substituting y = 11-x into f and looking at a plot of the result.

A nicer example would be to take [tex]f = \frac{1}{x} + \frac{2}{y}[/tex] and keeping the same g as before. Now you would get [tex]L = \frac{1}{x} + \frac{2}{y} - \lambda (x+y-11),[/tex] and so
[tex]\frac{\partial L}{\partial x} = -\frac{1}{x^2} - \lambda = 0,\\<br /> \frac{\partial L}{\partial y} = -\frac{2}{y^2} - \lambda = 0,\\<br /> x+y=11,[/tex]
so either (1)
[tex]x = 11\sqrt{2}-11, \; y = 22 - 11\sqrt{2}, \; \lambda = -\frac{3+2\sqrt{2}}{121},[/tex]
or (2)
[tex]x = -11 - 11 \sqrt{2}, \; y = 22 + 11\sqrt{2}, \; \lambda = -\frac{3 - 2\sqrt{2}}{121}.[/tex]

It turns out that point (1) is a maximum while point (2) is a minimum. In general we would need to perform second-order tests to check whether a point is a max or a min (or neither), because just looking at gradients equal to zero does not tell us whether the point is a max or a min. However, in this case we can just evaluate f at the two points to see which is which.

Note: by max and min above, we mean local max and min, not global. In this case there are no global max or min values, because we can have [itex]f \rightarrow + \infty[/itex] by letting x go to zero from above (keeping y = 11-x), or letting x go to 11 from below (so y goes to zero from above). Similarly, we can have [itex]f \rightarrow -\infty[/itex] by letting x go to zero from below or go to 11 from above.

RGV
 
Last edited: