PDA

View Full Version : maximizing a function with multiple independent variables


_TKO_
04-20-2007, 01:17 PM
Let's say I have a function like z = 26xy - 14y + 8. How do I go about figuring the maximum value for z. Is this even possible?

jay_shark
04-20-2007, 01:51 PM
Questions like this are possible if you have constraints like x+y=C for some constant C and then you simply use the Lagrange Multiplier method .

_TKO_
04-20-2007, 04:26 PM
I know x+y = 1. I'll refresh myself with the Lagrange stuff. I haven't taken calc for a couple years now.

Neuge
04-20-2007, 07:05 PM
You can find local minima of a multivariate function without the a+b=C constraint using steepest descent or conjugate gradient. If you want a maximum just take the negative of your function and find the minimum.

Keep in mind these methods find a local minimum, which may not be the absolute minimum.

BruceZ
04-20-2007, 07:09 PM
[ QUOTE ]
I know x+y = 1. I'll refresh myself with the Lagrange stuff. I haven't taken calc for a couple years now.

[/ QUOTE ]

If that's the only constraint, you don't need LaGrange. Just substitute 1 - y for x, take the derivative with respect to y, and set it equal to zero.

z = 26*(1-y)*y - 14y + 8

z = -26y^2 + 12y + 8

dz/dy = -52y + 12 = 0

y = 3/13, x = 10/13

_TKO_
04-21-2007, 05:33 AM
Thanks Bruce. I got the same answer using the LaGrange method.

f(x,y) = 26xy - 14y + 8
g(x,y) = x + y = 1

fx = L*gx
26x - 14 = L

fy = L*gy
26y = L

Therefore, 26x - 14 = 26y. Use substition of y = 1-x to get x = 10/13 and y = 3/13.

-----------------

Anyway, I think I set up my contraints incorrectly. Is there some way to solve it based on a set of ranges for x and y, like 1/4 <= x <= 3/4, and 2/5 <= y < 1?

My suspicion is that I would need to come up with an equation involving both x and y and use this as my contraint, but such a system would involve 4 equations...?

gumpzilla
04-21-2007, 07:48 PM
If you're trying to optimize it on a range, just take the gradient and see if it is zero for any point in the range. If not, your extrema will be on the boundary, meaning one of the corners in this case.