MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: NEWBIE: How do I use the results of a Solve?

In article <gm0q3d$rm2$1 at>, Tim Heger <timheger at> 

> 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

or directly from within the documentation center at 



  • Prev by Date: Re: Re: Re: two y-axes with different scaling
  • Next by Date: Re: Defining assumptions globally
  • Previous by thread: Re: NEWBIE: How do I use the results of a Solve?
  • Next by thread: best hardware platform for Mathematica 7 under Linux?