MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Constrained Min, non-linear


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] ====


  • Prev by Date: Re: Two Dimensional Numerical Integration Packages
  • Next by Date: Re:ListPlot the output of Print
  • Previous by thread: Constrained Min, non-linear
  • Next by thread: Re: Constrained Min, non-linear