MathGroup Archive 2005

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

Search the Archive

Re: Solve question


L.W.,

Here is an example.

eqn = a x + b == c;
xsol = Solve[eqn, x]
{{x -> (-b + c)/a}}

Notice that Mathematica returned a List within a List. That is because there
may be more than one solution, and for multiple equations there may be more
than one variable in each solution. Generally we will want to extract a
specific solution by taking a specific part of xsol.

Let's create an x function that depends on the a,b,c parameters. We do that
by using Replace denoted by "/.". We want only the solution in the inner
bracket so we use the following:

x[a_, b_, c_] = x /. Part[xsol, 1]
(-b + c)/a

which we can now use.

x[p, q, 3]
(3 - q)/p

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/


From: Sterritt, Lanny [mailto:lanny.sterritt at lmco.com]
To: mathgroup at smc.vnet.net


When the Solve command is used to obtain the value of a variable in an
equation, something like  {x -> value}  is returned.  How does one get
Mathematica  to automatically apply this value to following  expressions in
a notebook?

L.W.Sterritt





  • Prev by Date: Re: Complex Oddity
  • Next by Date: Re: Complex Oddity
  • Previous by thread: Re: Solve question
  • Next by thread: Re: Solve question