Re: reuse values maximize
- To: mathgroup at smc.vnet.net
- Subject: [mg51991] Re: reuse values maximize
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Sat, 6 Nov 2004 02:08:28 -0500 (EST)
- References: <cmfbkc$7eh$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Arne wrote:
> Sorry, very simple question, but I really can't work it out...
>
> 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!).
>
> Thanks for any comment.
>
Let us say you have the expression {y->-0.5} in a variable ans, then you
could extract the value into another variable with:
othervar= y/.ans
What happens here is that the expression y/.ans means y with the
substitutions contained in ans applied - which boils down to -0.5.
Regards,
David Bailey