MathGroup Archive 2003

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg39350] RE: [mg39326] Re: Getting rid of the symbol -> after finding the root
  • From: "David Park" <djmp at earthlink.net>
  • Date: Wed, 12 Feb 2003 03:52:38 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Mostaghel,

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
-0.975583

/. 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.

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

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

x^2 + 2x - 3
-0.975583

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 earthlink.net
http://home.earthlink.net/~djmp/





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


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?

Thanks,


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





  • 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