Re: Defining Solve results as variable

*To*: mathgroup at smc.vnet.net*Subject*: [mg70059] Re: Defining Solve results as variable*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>*Date*: Sun, 1 Oct 2006 04:10:34 -0400 (EDT)*Organization*: The Open University, Milton Keynes, UK*References*: <eflebs$deg$1@smc.vnet.net>

Diana wrote: > Hi, > > I am trying to write a program which defines a variable with the > results of a Solve equation. > > So, if I write > > Solve[x+1=2,x] > > I get {{x -> 1}} > > I have not been able to figure out how to define a variable to the > result, so that if I then type > > x1 = %, for example, it defines x1 as 1. > > I know this must be simple, but I didn't find it in the Help material. > > Thanks in advance, > > Diana > Hi Diana, In[1]:= sols = Solve[x + 1 == 2, x] Out[1]= {{x -> 1}} In[2]:= x1 = x /. sols[[1]] Out[2]= 1 Have a look at the following links: http://documents.wolfram.com/mathematica/book/section-1.4.2 http://documents.wolfram.com/mathematica/book/section-1.5.7 Regards, Jean-Marc