Re: Simple Concept I can't figure out! Making rules?
- To: mathgroup at smc.vnet.net
 - Subject: [mg38076] Re: Simple Concept I can't figure out! Making rules?
 - From: "Kevin J. McCann" <kjm@KevinMcCann>
 - Date: Tue, 3 Dec 2002 04:28:43 -0500 (EST)
 - References: <as5pgp$n96$1@smc.vnet.net>
 - Sender: owner-wri-mathgroup at wolfram.com
 
ans = Solve[2x-1==0,x][[1]]//N
answer = x/.ans
Note that the [[1]] construct effectively turns ans into {x->0.5}, without
it the above answer would be {0.5} not 0.5.
Kevin
"Stan" <snarten at runbox.com> wrote in message
news:as5pgp$n96$1 at smc.vnet.net...
> Even though it's frowned upon by the engineering college, i use
> mathematica a lot of the stuff that would take pages of code in
> another system. I have most basic functions and operations down, but I am
> lacking one basic thing I need to do to be able to program more
> problems successfully:
>
> here is my problem:
>
> Lets say you solve an equation using "Solve"
>
> Solve[2x - 1 == 0, x] // N
>
> {{x -> 0.5}}
>
> How would I then use the result of "Solve" (0.5) and assign it to a
> new variable, like "answer"  for further calculations?
>
> I think it has something to do with /. and -> rules of some sort, but
> I can't get this simple concept to work!
>
> Thanks for the help.
>
> -Stan
>