Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

RE: Mathematica 4.0 features

  • To: mathgroup at
  • Subject: [mg31431] RE: [mg31422] Mathematica 4.0 features
  • From: "David Park" <djmp at>
  • Date: Sat, 3 Nov 2001 18:25:08 -0500 (EST)
  • Sender: owner-wri-mathgroup at

This is the kind of thing that Mathematica is not naturally great at because
it usually does a lot of automatic simplification. So if you do

Factor[(a^3*b - a*b^3)/(a^3*b - 2*a^2*b^2 + a*b^3)]
(a + b)/(a - b)

you lose the intermediate steps. Ted Ersek and I have developed a package
ExpressionManipulation, available at my web-site, which goes some way to
permitting detailed manipulation of expressions. In this case, we have to
put the expression in a HoldForm, and we also need an auxilary function to
factor out a subexpression leaving the rest of the expression expanded.
EvaluateAt is a routine which will apply and evaluate a function at
specified positions within a held expression.


FactorOut[subexpr_][expr_] := subexpr (Simplify[expr/subexpr] // ExpandAll)

Then we can evaluate step-by-step to obtain your intermediate expressions.
The output looks much better in StandardForm.

e1=HoldForm[(a^3*b - a*b^3)/(a^3*b - 2*a^2*b^2 + a*b^3)]
EvaluateAt[{{1, 1}, {1, 2, 1}}, FactorOut[a*b]][%]
EvaluateAt[{{1, 1}, {1, 2, 1}}, Factor][%]
HoldForm[(a^3*b - a*b^3)/(a^3*b - 2*a^2*b^2 + a*b^3)]
HoldForm[(a*b*(a^2 - b^2))/(a*b*(a^2 - 2*a*b + b^2))]
HoldForm[(a^2 - b^2)/(a^2 - 2*a*b + b^2)]
HoldForm[((a - b)*(a + b))/(a - b)^2]
(a + b)/(a - b)

I got the positions of the numerator and denominator by:
posn = Position[e1, _Plus]
e1 // ColorPositions[posn]
{{1, 1}, {1, 2, 1}}

ColorPositions is a package routine which colors and labels positions so one
can check that the positions are the desired ones.

David Park
djmp at

> From: DinCo [mailto:vladimir.oletic at]
To: mathgroup at
> Does Mathematica (version 4.0 or higher) have an ability to do the
> calculations with symbols and to do just selected operations -for
> an example
> just to simplify (reduce) the algebric expressions and at the same time to
> show all the steps that have been made (look at the example)?
>      a^3b - ab^3              ab(a^2 - b^2)       (a - b)(a +b)     a + b
> --------------------- = ---------------------- = --------------- = -------
> a^3b - 2a^2b^2 + ab^3      ab(a^2 - 2ab + b^2)     (a - b)^2        a - b

  • Prev by Date: Re: Foldlist Question
  • Next by Date: Re: Clearing Subscripted Variables?
  • Previous by thread: Mathematica 4.0 features
  • Next by thread: Re: commuting and non-commuting symbols