Re: Constrained Min, non-linear
- To: mathgroup at smc.vnet.net
- Subject: [mg4517] Re: Constrained Min, non-linear
- From: Stephen P Luttrell <luttrell at signal.dra.hmg.gb>
- Date: Fri, 2 Aug 1996 02:22:42 -0400
- Organization: Defence Research Agency, Malvern
- Sender: owner-wri-mathgroup at wolfram.com
Stefan Wolfrum wrote: >...DELETIA... > Where is f(x,y)=x^2+y^2 minimal, if x and y are > constrained to abs(x+y)=1 ? Try the following (this is long-winded for this particular problem because the solution is geometrically obvious): (* define the basic functions *) f[x_, y_] := x^2 + y^2; g[x_, y_] := x + y; (* differentiate using a Lagrange multipler *) dx = D[f[x,y] + a g[x,y], x]; dy = D[f[x,y] + a g[x,y], y]; (* find the stationary point *) soln = Solve[{dx==0, dy==0}, {x,y}]; (* find values of a that satisfy Abs[g[x,y]]==1 at the stationary point *) g0 = g[x, y] /. soln[[1]]; a1 = Solve[g0 == 1, a]; a2 = Solve[g0 == -1, a]; (* finally generate the 2 solutions *) soln /. a1 soln /. a2 -- Dr Stephen P Luttrell luttrell at signal.dra.hmg.gb Adaptive Systems Theory 01684-894046 (phone) Room EX21, Defence Research Agency 01684-894384 (fax) Malvern, Worcs, WR14 3PS, U.K. http://www.dra.hmg.gb/cis5pip/Welcome.html ==== [MESSAGE SEPARATOR] ====