Re: symbolic evaluation
- To: mathgroup at smc.vnet.net
- Subject: [mg87010] Re: symbolic evaluation
- From: "David Park" <djmpark at comcast.net>
- Date: Fri, 28 Mar 2008 03:20:00 -0500 (EST)
- References: <fsg6n1$j55$1@smc.vnet.net>
Paul,
If you are going to use Mathematica much, you should consider taking some
time to review the basic commands in Mathematica.
In this case you can just use Solve (Look it up in Help).
Solve[7x==14]
{{x->2}}
The solutions always come in the form of rules, with arrows, that you can
use to substitute x in any expression that contains x. The brackets are
there because in general there may be multiple variables and multiple
solutions. You could get rid of the brackets by:
xsol = Part[Solve[7 x == 14], 1, 1]
x -> 2
You could then use the rule, saved in xsol, to substitute in any expression,
such as:
x^2 + 3 x - 5 /. xsol
5
In the case of a simple equation like this there is another method of
solving. We write the equation and then divide each side of the equation by
7 using a pure function (look up Function in Help and note how a slot
notation for pure functions work. '#/7&' is the pure function. In the
following we are also using '/@' to Map the function to each side of the
equation. '%' is the previous output. Look up Map in Help.)
7 x == 14
#/7 & /@ % giving
7 x == 14
x == 2
--
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/
"news.east.cox.net" <sam at sam.com> wrote in message
news:fsg6n1$j55$1 at smc.vnet.net...
> I'm using Mathematica 5.1 I want to evaluate a simple equation
> symbolically, such as 7x = 14. of course the answer should be x = 14/7.
> I can't find a clear example on how to do this with a simple equation.
> Can anyone help me?
> TIA
> Paul
>