Re: ?

• To: mathgroup at smc.vnet.net
• Subject: [mg120816] Re: ?
• From: Murray Eisenberg <murray at math.umass.edu>
• Date: Thu, 11 Aug 2011 05:13:27 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• 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.}
>
>
> Out[2]= List
>
> I can't seem to find any "normal" operations on the list which give me
> the number.
>
> Dave
>

--
Murray Eisenberg                     murray at 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

```

• Prev by Date: Re: Just another Mathematica "Gotcha"
• Next by Date: Re: Print Magnification?
• Previous by thread: Re: ?
• Next by thread: Re: ?