RE: SIMPLIFY: Results seem to depend on the form of the expression

• To: mathgroup at smc.vnet.net
• Subject: [mg26283] RE: [mg26236] SIMPLIFY: Results seem to depend on the form of the expression
• From: "David Park" <djmp at earthlink.net>
• Date: Sun, 10 Dec 2000 00:19:55 -0500 (EST)
• Sender: owner-wri-mathgroup at wolfram.com

```Jerry,

Manipulating Mathematica expressions to obtain the form you want is really
something of an art. I find that as I practice more and more, I can usually
get what I want, but one has to learn all the tricks. Simplify and
FullSimplify are really somewhat vague commands. They seem to depend upon
the starting point, and their criterion for what is simple may not be yours.
So you are often going to have to bring other "surgical" techniques to bear.
Take the case of your last expression.

expr = a x + b x - c y - d y - g x - f x;

Simplify[expr]
a x + b x - f x - g x - c y - d y

FullSimplify[expr]
a x + b x - (f + g) x - (c + d) y

But you can get what you want by other techniques.

FullSimplify[expr, Null, ComplexityFunction ->
(Count[#1, Times[__], Infinity] & )]
(a + b - f - g) x + (-c - d) y

If we wanted to get the minus signs outside the factor in the second term we
could use

FullSimplify[expr, Null, ComplexityFunction ->
(Count[#1, Times[__], Infinity] +
Count[#1, -1, Infinity] & )]
(a + b - f - g) x - (c + d) y

But our complexity function doesn't work with Simplify (I don't know why).

Simplify[expr, Null, ComplexityFunction ->
(Count[#1, Times[__], Infinity] +
Count[#1, -1, Infinity] & )]
a x + b x - f x - g x - c y - d y

We could also use other techniques on this.

Collect[expr, {x, y}]
MapAt[Simplify, %, 2]
(a + b - f - g) x + (-c - d) y
(a + b - f - g) x - (c + d) y

Ted Ersek, a few months ago, put forward a complexity function which
sometimes works better than the standard one. I have a package at my web
site for Version 4 called ExpressionManipulation. It makes the Ersek
complexity function available and also has other routines useful in
manipulating expressions. It has a palette for obtaining the positions of
subexpressions in larger expressions (provided they are not held
expressions). It also has routines for combining radical expressions under

David Park

> From: Blimbaum Jerry DLPC [mailto:BlimbaumJE at ncsc.navy.mil]
To: mathgroup at smc.vnet.net
>
>
> 	To try to understand Mathematica better, sometimes I try some simple
> things to see what happens etc...Here are some things I tried
> with Simplify
> with the results depending on the form of the original expression even
> though they are just simple polynomial expressions...
>
> 	(1)   a x + b x == c y+d y+g x+f x//Simplify
>
> 	returns
>
> 	   (a+b) x == f x +g x +(c+d) y         (* incomplete *)
>
>
> 	(2)  a x + b x - c y - d y == g x + f x//Simplify
>
>
> 	returns
>
> 	(a+b) x ==  (f+g) x + (c+d) y            (* seems to work *)
>
>
> 	(3)  a x + b x - g x -f x == c y + d y//Simplify
>
> 	returns
>
> 	(a+b-f-g) x == (c+d) y                   (* seems to work *)
>
>
> 	(4)  a x + b x - c y - d y - g x - f x == 0//Simplify
>
> 	returns
>
> 	(a+b) x == f x + g x +(c+d) y          (* incomplete *)
>
>
> 	(5) a x + b x -c y - d y - g x - f x//Simplify
>
> 	doesnt do anything to the expression..
>
>
> 	Should Simplify be this temperamental?  (FullSimplify handles all
> these cases which is what I would have expected even from Simplify since
> these are just simple polynomial expressions).
>
> 	thanks...Jerry Blimbaum    NSWC  Panama City, Fl
>
>

```

• Prev by Date: Re: Newton's method
• Next by Date: Re: Big trouble with Mathematica Code parsing -- Rant.
• Previous by thread: SIMPLIFY: Results seem to depend on the form of the expression
• Next by thread: TeXSave undefined control sequences