       Re: Simplify

• To: mathgroup at smc.vnet.net
• Subject: [mg98663] Re: [mg98659] Simplify
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Thu, 16 Apr 2009 04:10:50 -0400 (EDT)
• References: <200904150902.FAA08151@smc.vnet.net>

```Actually, this point has been explained many times (by me ;-))

(I like to think of Mathematica's evaluation process in terms of
something called "The Evaluator", which I think I first found in David
Wagner's book "Power Programming with Mathematica". I think it is only
an abstraction, along with "the Parser", "the Typesetter" etc, but a
convenient one when one is thinking about the evaluation process. )

The "Evaluator" always evaluates

(x/y)^2

to

x^2/y^2

This happens before Simplify takes any effect. Even if Simplify
converted x^2/y^2 to (x/y)^2  the Evaluator would kick in and again
convert  it back to x^2/y^2. Since the Evaluator always overrides
Simplify there is no way to get (x/y)^2 as the output without using
Hold.

Perhaps you are asking why Mathematica (or the "Evaluator")
automatically converts (x/y)^2 to  x^2/y^2. It's because of something
called "canonical forms" or "standard forms". Basically, in order to
optimize performance in computer algebra systems one want to reduce to
0 as quickly as possible as many expressions that are actually equal.
The earlier you do this the better the performance. If you allow
expressions to contain a large number of subexpressions that are
actually 0 until you apply Simplify, it may very seriously impair
performance. "Canonical forms" (or "normal forms", there is a slight
difference between them but I shall ignore it) are certain unique
forms to which various expressions are reduced automatically by the
Evaluator (before applying Simplify). This has the effect causing
cancellations to occur early. Also, these "canonical forms" have to be
independent of any particular ComplexityFunction used, hence the
reduction has to be performed outside Simplify. The advantage of using
canonical forms independent of ComplexityFunction is that they often
enable Mathematica to identify two expressions as equal even if
Simplify can't fine a sequence of Complexity reducing transformations
that will convert one expression into the other.
Not surprisingly, using "canonical forms" can sometimes produce
undesirable side-effects and this is one of them (a rather minor one,
worse ones do occur).

Andrzej Kozlowski

Andrzej Kozlowski

On 15 Apr 2009, at 18:02, dh wrote:

>
>
> Hi,
>
> can somebody explain, why
>
> Simplify[x^2/y^2,ComplexityFunction->LeafCount]
>
> does not simplify to (x/y)^2, although the LeafCount is:
>
> LeafCount[Hold[x^2/y^2]] gives 10
>
> and
>
> LeafCount[Hold[(x/y)^2]] gives 8
>
>
>
> Daniel
>
>
>

```

• References:
• Prev by Date: Re: Simplify
• Next by Date: Re: Simplify
• Previous by thread: Re: Simplify
• Next by thread: Re: Simplify