Re: Maximize function question
- To: mathgroup at smc.vnet.net
- Subject: [mg46355] Re: Maximize function question
- From: drbob at bigfoot.com (Bobby R. Treat)
- Date: Mon, 16 Feb 2004 08:59:55 -0500 (EST)
- References: <c0fru2$c03$1@smc.vnet.net> <c0hhpk$lg0$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
That really should be
grad[f_, vars_] := (D[f, #1] & ) /@ vars
obj = a*k + w*l;
condition = q == Sqrt[k] + Sqrt[l];
lagrangian = obj + lambda*Subtract @@ condition
vList = {k, l, lambda};
Thread[grad[lagrangian, vList] == 0]
First[Solve[%, vList]]
Simplify[%, q > 0]
Simplify@PowerExpand@%
Bobby
drbob at bigfoot.com (Bobby R. Treat) wrote in message news:<c0hhpk$lg0$1 at smc.vnet.net>...
> Try this for locating possible extrema:
>
> grad[f_] := (D[f, #1] & ) /@ {k, l}
> obj = a*k + w*l;
> condition = q == Sqrt[k] + Sqrt[l];
> lagrange = obj + lambda*Subtract @@ condition
> Append[Thread[grad[lagrange] == 0], condition]
> Simplify[First[Solve[%, {k, l, lambda}]]]
> PowerExpand /@ %
> Simplify[%]
>
> Bobby
>
> "David" <nospam at nospam.com> wrote in message news:<c0fru2$c03$1 at smc.vnet.net>...
> > Hello,
> >
> > I am attempting to perform a constrained optimization in Mathematica 5.0 on
> > the objective function:
> >
> > f(K,L)=aK+wL s.t. K^0.5 + L^0.5=Q where a,w,Q are constant.
> >
> > I define:
> > objA[K_,L_]:=rK+wL
> > and
> > constraintsA = {K^0.5+L^0.5==Q,K>=0, L>=0}
> >
> > After which I try to evaluate
> >
> > Maximize[{objA[K,L],constraintsA},{K,L}]
> >
> > However, I receive an error message that the objective function contains a
> > nonconstant expression independent of variables {K,L}.
> >
> > Though the calculation is trivial and is easy to do by hand, I would like to
> > be able to figure out how to do these types of optimization problems not
> > having to assign real numbers to the constants for future use. Is there an
> > elegent way to do this?
> >
> > Your collective help is greatly appreciated.