Re: NEWBIE: How do I use the results of a Solve?
- To: mathgroup at smc.vnet.net
- Subject: [mg95994] Re: NEWBIE: How do I use the results of a Solve?
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Sat, 31 Jan 2009 06:44:35 -0500 (EST)
- Organization: The Open University, Milton Keynes, UK
- References: <gm0q3d$rm2$1@smc.vnet.net>
In article <gm0q3d$rm2$1 at smc.vnet.net>, Tim Heger <timheger at yahoo.com>
wrote:
> I can't figure out how to use the results of Solve I just created as a new
> variable.
>
> Here's a simple example of what I am trying to do:
>
> Solve[some equation, x]
>
> Results in {x->12}
>
> I then want to use the x in y = x * 5 for example....
>
> Obviously when I try to use this it fails because Mathematica sees the
> equation as y = {x->12} * 5 and not y = 12 *5 ...
>
> How do I change the results from the Solve from a rule to an actual value I
> can then use?
The function Solve returns a list of transformation rules (possibly an
empty list or just one) that can be further applied to other expressions
via the replacement operator /. as you can see in the following examples:
In[1]:= sol = Solve[x - 12 == 0, x]
Out[1]= {{x -> 12}}
In[2]:= y = x*5 /. sol[[1]]
Out[2]= 60
In[3]:= sol = Solve[x^2 - 12 == 0, x]
Out[3]= {{x -> -2 Sqrt[3]}, {x -> 2 Sqrt[3]}}
In[4]:= y = x*5 /. sol
Out[4]= {-10 Sqrt[3], 10 Sqrt[3]}
The tutorial "Solving Equations" might be worth reading. It is available
on the web at
http://reference.wolfram.com/mathematica/tutorial/SolvingEquations.html
or directly from within the documentation center at
tutorial/SolvingEquations
Regards,
--Jean-Marc