MathGroup Archive 2005

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

Search the Archive

Re: Solve question

  • To: mathgroup at
  • Subject: [mg57470] Re: [mg57457] Solve question
  • From: "David Park" <djmp at>
  • Date: Sun, 29 May 2005 01:03:28 -0400 (EDT)
  • Sender: owner-wri-mathgroup at


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

From: Sterritt, Lanny [mailto:lanny.sterritt at]
To: mathgroup at

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?


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