# Constrained Optimization with a three variable function

• April 2nd 2010, 03:49 PM
rainer
Constrained Optimization with a three variable function
Hi, I need help maximizing a function of three variables subject to a constraint. I understand how to do this for a function of two variables, but now I need to do it for a function of three variables.

If someone could point me in the right direction, recommend a webpage, etc., that would be great. Cursory googling has not helped.

Thanks
• April 2nd 2010, 04:10 PM
eddie2042
it would help if you post the question...
• April 2nd 2010, 05:43 PM
Anonymous1
Quote:

Originally Posted by rainer
Hi, I need help maximizing a function of three variables subject to a constraint. I understand how to do this for a function of two variables, but now I need to do it for a function of three variables.

If someone could point me in the right direction, recommend a webpage, etc., that would be great. Cursory googling has not helped.

Thanks

Econ, huh?

http://people.ucsc.edu/~rgil/Optimization.pdf

See page 42.
• April 2nd 2010, 06:26 PM
rainer
Quote:

Originally Posted by eddie2042
it would help if you post the question...

Formalizing my question:

I need to maximize $f(x, y, z)$ subject to the constraint $g(x,y,z)=c$

I believe you write this as...

$\underset{\left \{ \left. x,y,z \right \} \right.}{max}\left [ f(x,y,z) \right ]$

$s.t.\: \: \: \: g(x,y,z)=c$

If it's easier to help me if I offer an example problem, here is an example problem:

Maximize $f(x,y,z)=\frac{x}{y+z}$ subject to the constraint $x+y+z=c$

I.e. $\underset{\left \{ \left. x,y,z \right \} \right.}{max}\left [ \frac{x}{y+z} \right ]$

$s.t.\: \: \: \: x+y+z=c$

1) How would I use the substitution method to find the solution? Is it even possible when there are three variables?

2) If I use the Lagrangian method, what do I do after getting my first order conditions?

The Lagrangian is $\Lambda(x,y,z,\lambda )=\frac{x}{y+z}+\lambda(x+y+z-c)$

Here are my first order conditions:

$\frac{\partial \Lambda}{\partial x}=\frac{1}{y+z}+\lambda=0$

$\frac{\partial \Lambda}{\partial y}=\frac{-x}{(y+z)^2}+\lambda=0$

$\frac{\partial \Lambda}{\partial z}=\frac{-x}{(y+z)^2}+\lambda=0$

$\frac{\partial \Lambda}{\partial \lambda }=x+y+z-c=0$

This is as far as I get. I don't know what to do from here.
• April 2nd 2010, 06:29 PM
Anonymous1
Set your first order conditions = 0. Solve for $\lambda$ to get it out of there. Then you solve the system of equations.

Why don't you try and show me where you are stuck.

Note that your solutions x*, y*, and z* are going to be functions of the other two variables.
• April 2nd 2010, 06:52 PM
Anonymous1
You may have to use the fact x+y+z= c => x = c-y-z.

And sub these into your equation before taking the first order conditions.
• April 2nd 2010, 09:31 PM
rainer
Quote:

Originally Posted by Anonymous1
Set your first order conditions = 0. Solve for $\lambda$ to get it out of there. Then you solve the system of equations.

I forgot to add the zeros. Now I've edited them into my last post up there.

Now, I'm not sure what you mean by "solve the system of equations."

I'm guessing you mean I get them all into the same equation by substituting them in for 0?

In the example above, this leads me to:

$\frac{1}{y+z}+\frac{2x}{(y+z)^2}-x-y+c=0$

Is that what you're talking about? And then I just solve for each variable to get its respective maximization formula?

So the maximization formula for c, for example, would be:

$c_{\max}=x+y-\frac{1}{y+z}-\frac{2x}{(y+z)^2}$

Is that right?

By the way thanks for that link. I had already come across it and it is one of the reasons why I have gotten as far as I have. But it does not deal with the three variable case so that is why I am asking here.
• April 2nd 2010, 10:58 PM
Anonymous1
A few things.

$c$ is a constant. Think of $x+y+z=c$ as the budget constraint. $c$ (sometimes denoted by m) is the purchasing power.

We want to maximize $f$ constrained by $x+y+x=c.$ $f$ is your utility function, so the Lagrangian is a function that takes into account both the budget constraint and the utility function.

If we want to maximize a specific variable of the function $\Lambda,$ we take the derivative w.r.t that variable and set it equal to $0.$ Why do we do this? Because the derivative describes the slope of our function at a point. And when the slope $= 0,$ we are at the zenith, $i.e.,$ maximum of the function.

Now, we have

$\frac{\partial \Lambda}{\partial x}=\frac{1}{y+z} +\lambda=0$

$\Rightarrow -\frac{1}{y+z} = \lambda$

Now sub $\lambda$ into your other two equations and simplify them.

Now we have three equations and three unknowns.

Solve equation $1$ for $x,$ say, then sub the obtained value of $x(y,z)$ (a function of the other two variables) into equation $2.$ Proceed in this manner to find the solutions, $[x^*, y^*, z^*]$ to your system of equations.
• April 2nd 2010, 11:46 PM
rainer
Thanks. I think I got it now. Just to follow through:

So having solved for $\lambda$ as you demonstrate...

$\lambda=-\frac{1}{y+z}$

I then substitute this in for $\lambda$ in one of the other equations...

$\frac{-x}{(y+z)^2}-\frac{1}{y+z}=0$

Simplifying...

$x+y+z=0$

And then solving for any of these variables gives me the maximization formula for that variable? I.e. $y_{\max}=-x-z$? Is that it?

Oh, one last question. What if the constraint only involves two of the three variables. I.e. instead of $x+y+z=c$ it were only $y+z=c$. In that case one of the first order condition equations would be without a lambda. Would that pose a problem for solving the system of equations? Thanks.
• April 2nd 2010, 11:54 PM
Anonymous1
Quote:

Originally Posted by rainer
Oh, one last question. What if the constraint only involves two of the three variables. I.e. instead of $x+y+z=c$ it were only $y+z=c$. In that case one of the first order condition equations would be without a lambda. Would that pose a problem for solving the system of equations? Thanks.

You will always have f.o.c. w.r.t. $\lambda.$ This is default.

In the two variable case you would have a f.o.c. w.r.t. x, and w.r.t. y because you are only trying to find the zenith for those two variables.