Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4317
| From | Bill Rowe <readnews@sbcglobal.net> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: ? |
| Date | 2011-08-11 09:18 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j206pl$76d$1@smc.vnet.net> (permalink) |
On 8/10/11 at 6:47 AM, david.kirkby@onetel.net (David Kirkby) wrote:
>The output of FindRoot[] when trying to find a root is like:
>{x -> 0.49454545}
>How can I convert that list, into the number 0.49454545?
>In[1]:= FindRoot[x+9,{x,-5}]
>Out[1]= {x -> -9.}
>In[2]:= Head[%]
>Out[2]= List
>I can't seem to find any "normal" operations on the list which give
>me the number.
The output from FindRoot is a list of replacement rules. When
there is a single replacement rule simply do
In[1]:= sol = FindRoot[x + 9, {x, -5}];
In[2]:= x /. sol
Out[2]= -9.
When there is more than one replacement rule you will need to
specify which solution you want. For example using Solve
In[3]:= sol = Solve[x^2 == 9, x];
In[4]:= x /. sol[[1]]
Out[4]= -3
In[5]:= x /. sol[[2]]
Out[5]= 3
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: ? Bill Rowe <readnews@sbcglobal.net> - 2011-08-11 09:18 +0000
csiph-web