*To*: mathgroup@smc.vnet.net*Subject*: [mg10773] Re: [mg10737] optimize*From*: Daniel Lichtblau <danl@wolfram.com>*Date*: Thu, 5 Feb 1998 00:58:21 -0500*References*: <199802020544.AAA28177@smc.vnet.net.>

Holger wrote: > > I'm a newbie and need help to solve this: > > max Z= x + 3 y + 5 z given x^2 + 2y^2 + 4z^2 <= 17 > > A would deeply appreciate answers because I can't seem to solve > (through mathematica 3.0) it by myself. You could use a Lagrange multiplier. As a matter of programming it can be tricky to get all the equations into the correct format. I show one way to do this below. surf = x^2 + 2*y^2 + 4*z^2 - 17; vars = {x,y,z}; grad1 = lambda*Map[D[surf,#]&,vars]; cost = x + 3*y + 5*z; grad2 = Map[D[cost,#]&,vars]; eqns = Append[MapThread[Equal,{grad1,grad2}], surf==0] Now it is simple to eliminate lambda and solve for {x,y,z}. In[54]:= InputForm[soln = Solve[eqns, vars, lambda]] Out[54]//InputForm= {{x -> -2*Sqrt[17/47], y -> -3*Sqrt[17/47], z -> (-5*Sqrt[17/47])/2}, {x -> 2*Sqrt[17/47], y -> 3*Sqrt[17/47], z -> (5*Sqrt[17/47])/2}} I trust the gist of your difficulty was in the programming rather than the math (were this textbook computer science instead of math maybe I'd reverse that assumption). Daniel Lichtblau Wolfram Research

**References**:**optimize***From:*kimhhans@online.no (Holger)