Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #4324
| From | Murray Eisenberg <murray@math.umass.edu> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: ? |
| Date | 2011-08-11 09:22 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j2070b$77u$1@smc.vnet.net> (permalink) |
| References | <201108101047.GAA26230@smc.vnet.net> |
This is something that arises even from plain Solve as well as DSolve,
etc.: you get rules instead of values.
Given a rule x -> val, the typical way you get the value val is:
x /. x -> val
This in your case either directly...
x /. FindRoot[x+9,{x,-5}]
... or else in two steps:
FindRoot[x+9,{x,-5}]
x /. %
Note that for things like Solve where multiple solutions are possible,
the result of the x /. rule expression will be a list of the solutions.
For example:
x /. Solve[x^2 + 4 == 0, x]
{-2I, 2I}
On 8/10/11 6:47 AM, 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.
>
> Dave
>
--
Murray Eisenberg murray@math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower phone 413 549-1020 (H)
University of Massachusetts 413 545-2859 (W)
710 North Pleasant Street fax 413 545-1801
Amherst, MA 01003-9305
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
Re: ? Murray Eisenberg <murray@math.umass.edu> - 2011-08-11 09:22 +0000
csiph-web