Re: reuse values maximize
- To: mathgroup at smc.vnet.net
- Subject: [mg51996] Re: reuse values maximize
- From: Bill Rowe <readnewsciv at earthlink.net>
- Date: Sat, 6 Nov 2004 02:08:50 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 11/5/04 at 2:18 AM, a.kant at web.de (Arne) wrote:
>I want to use the output of a maximation for further calculations.
>something like:
>z[y_]=-y^2+y
>a=Maximize[z,{y}]
>b=Extract[a,1]
>Now mathematica returns {y -> -0.5}.
>I want to assign the value of -0.5 to a new variable. So far I
>haven't worked out how to do this (besides copy and paste!).
Try the following:
z = -y^2 + y
a = Maximize[z,{y}]
b = y/.Last[a]
That is the usual way to use an output formated as {y->expr} is y/.{y->expr}
Alternatively, you could directly access what you want, i.e.,
a[[2,1,2]]
But I wouldn't use this approach since it makes the code more difficult to understand
--
To reply via email subtract one hundred and four