Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2005
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: Form of a linear equation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg53752] Re: [mg53734] Form of a linear equation
  • From: "David Park" <djmp at earthlink.net>
  • Date: Wed, 26 Jan 2005 04:36:42 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

With a little luck maybe we can make Mathematica do as well as a TI-89.

If we set the equation...

eqn = -((4 + 4*x + y)/Sqrt[17]) ==
    (2 + x + y)/Sqrt[2];

Then the following Mathematica code shows the step by step reduction of the
equation to your desired form.

Print["Our equation"]
eqn
Print["Move rhs to lhs"]
# - Last[eqn] & /@ eqn
Print["Collect terms and simplify if possible"]
MapAt[Collect[#, {x, y}, FullSimplify] &, %%, 1]

This does use functional Mathematica constructs such as pure functions (# -
Last[eqn] &) and Map (/@). If you don't use Mathematica a lot you will have
to look them up in Help.

Then we can repackage this as a single routine, working backward from the
last statement and filling in from the previous step, and eliminating the
Print statements.

simplifyLinearEquation[eqn_] :=
  MapAt[Collect[#, {x, y}, FullSimplify] &, # - Last[eqn] & /@ eqn, 1]

simplifyLinearEquation[eqn]
-Sqrt[2] - 4/Sqrt[17] + (-(1/Sqrt[2]) - 4/Sqrt[17])*
    x + (-(1/Sqrt[2]) - 1/Sqrt[17])*y == 0

Sometimes FullSimplify will simplify radical expressions but not in the
above case.

Another example.

simplifyLinearEquation[Cos[t]^2 x + 5 y - 3 == 2 y - Sin[t]^2 x + b]
-3 - b + x + 3 y == 0

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


From: DJ Craig [mailto:spit at djtricities.com]
To: mathgroup at smc.vnet.net

I'm trying to convert this linear equation:

-(4+4x+y) / 17^(1/2) = (2+x+y) / 2^(1/2)

into the form:

(a_)*x + (b_)*y + (c_) = 0

This sounds simple enough, but I can't figure out how to make
Mathematica do it.  My TI-89 does it automatically, but I need to be
able to do this like a batch process for a bunch of linear equations.
Heres the solution the TI-89 gives me:

\!\(\*
StyleBox[\(\((\(\(-4\)\ \@17\)\/17 - \@2\/2)\)\ x + \((\(-\@17\)\/17
- \
\@2\/2)\)\ y - \(3\ \@17\)\/17 - \@2 = 0\),
FontWeight->"Bold"]\)

Just copy and paste that mess into Mathematica and it will change into
the equation at the top, but in the form that I want it.

I haven't been using Mathematica for long.  I'm used to my TI-89; I've
been using it for years.




  • Prev by Date: compile / optimize
  • Next by Date: Re: Monte Carlo Simulation Experiences
  • Previous by thread: Re: Form of a linear equation
  • Next by thread: Graphics'Master in 5.1