MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Re: Getting rid of the symbol -> after finding the root


Mathematica almost always returns the results of various "solving" routines
as a set of rules. Often there may be multiple variables and/or multiple
values and then you get sets of rules. You could save the rules and use them
later to substitute into some expression. Here is an example.

xsol = FindRoot[Cos[x] == x, {x, 1}]
{x -> 0.739085}

I saved the rule in the variable xsol. Then suppose you have an expression
in x. You can replace using xsol.

x^2 + 2x - 3
% /. xsol
-3 + 2*x + x^2

/. is the shortcut for ReplaceAll. (Lookup ReplaceAll in Help. Also lookup
Rule.) It uses the rule to replace each value of x.

Or you could replace x and save it once and for all.

FindRoot[Cos[x] == x, {x, 1}]
x = x /. %
{x -> 0.739085}

Now everytime you use x in an expression it will be replaced by its value.

x^2 + 2x - 3

I like the first procedure a little better because I don't like to assign
permanent values to a symbol like x.

David Park
djmp at

From: Mostaghel, Naser [mailto:NMostag at UTNet.UToledo.Edu]
To: mathgroup at

Dear Friends,
I need to use the root of a simple equation in subsequent operations.
After extracting the root, it comes in the form ->root.  I have not been
able to get rid of the symbol -> .

Can someone help?


Naser Mostaghel
Professor, Civil Engineering
T: (419) 530-8131
F: (419) 530-8116
E: nmostag at

  • Prev by Date: RE: Limits: Is there something I'm missing Here?
  • Next by Date: webMathematica: ClassNotFoundException: org.apache.tomcat.facade.HttpServletRequestFacade
  • Previous by thread: Re: Getting rid of the symbol -> after finding the root
  • Next by thread: Re: Re: Re: Getting rid of the symbol -> after finding the root