Re: Assigning solutions found by FindRoot
- To: mathgroup at smc.vnet.net
- Subject: [mg9473] Re: [mg9417] Assigning solutions found by FindRoot
- From: Des Penny <penny at suu.edu>
- Date: Thu, 6 Nov 1997 02:40:16 -0500
- Organization: Southern Utah University
- Sender: owner-wri-mathgroup at wolfram.com
Christian Zemlin wrote: > Hello everybody, > > I use FindRoot to solve systems of around ten equations and I would like > to use the results for further computation. Therefore, I need a > function that assigns the computed solution to the variables. For > example: > > In[1] := FindRoot[{x == y, x + y == 2}, {x, 0}, {y, 0}] Out[1] := {x -> > 1., y -> 1.} > > In[2] := **Command I am looking for ** Out[2] := ** Now, x is set to 1 > and y is set to 1 ** > > Can anybody help me with this? > > Thanks, > Chris Hi Chris: I don't have Mathematica available in front of me so there may be some minor errors in my response. If you look at the Fullform of the output from the FindRoot you see: In: sol=FindRoot[{x == y, x + y == 2}, {x, 0}, {y, 0}] ; FullForm[sol] Out: {Rule[x,1] , Rule[y,1]} Now we need to set x=1. The internal form of this in Mathematica is "Set[x,1]". Therefore, all we need to do in the above sol is to replace the word "Rule" with "Set". The following does that: In: sol /. Rule->Set This has the consequence that x is set equal to 1 and y is set equal to 1. Having said all the above, the recommended way to do the above is: {x,y}={x,y} /. sol Hope this helps, Des Penny