4
votes

I apologize beforehand if there’s an obvious answer, I’m not a user of Mathematica but I’m working on a borrowed laptop and that’s what I have available for the moment. For some reason Simplify and FullSimplify are missing obvious simplifications, for instance:

Simplify[1/2 (2/5 (x - y)^2 + 2/3 z)]

Yields:

1/2 (2/5 (x - y)^2 + (2 z)/3)

For some reason, it doesn't get rid of the 1/2 factor, try it yourself!

Of course I can do it manually but I have much bigger expressions with the same problem.

Am I missing something?

PS: This laptop has Mathematica 8.0

EDIT: FullSimplify works for the previous example but it doesn't for

FullSimplify[1/2 (2 (x - y)^2 + 2/5 (y - z)^2)]
4

4 Answers

4
votes

FullSimplify works for me:

In[693]:= Simplify[1/2 (2/5 (x - y)^2 + 2/3 z)]

Out[693]= 1/2 (2/5 (x - y)^2 + (2 z)/3)

In[694]:= FullSimplify[1/2 (2/5 (x - y)^2 + 2/3 z)]

Out[694]= 1/5 (x - y)^2 + z/3

In[695]:= $Version

Out[695]= "8.0 for Mac OS X x86 (64-bit) (October 5, 2011)"
3
votes

I don't know why Simplify misses this case, but FullSimplify helps out here:

FullSimplify[1/2 (2/5 (x - y)^2 + 2/3 z)]

gives:

Mathematica graphics

3
votes

Sometimes Collect can be more appropriate :

 In[1]:= Collect[1/2 (2/5 (x - y)^2 + 2/3 z), {z}]

 Out[1]= 1/5 (x - y)^2 + z/3

Edit

In[2]:= Collect[1/2 (2 (x - y)^2 + 2/5 (y - z)^2), {x - y, y - z}]

Out[2]= (x - y)^2 + 1/5 (y - z)^2

In this specific case Verbeia's approach using Ditribute seems to be the simplest way to get what you want, however Collect[expr, list] is customizable to generic cases by ordering a list. In Mathematica there are many functions, which may help in various cases. Though Simplify and FullSimplify could be a bit smarter they can do quite a lot. A nice example of their different behavior you may find beneath:

enter image description here

I recommend to take a closer look at a neat demonstration what one may expect in general : Simplifying Some Algebraic Expressions Using Mathematica.

2
votes

For your second example, Distribute works:

Distribute[1/2 (2 (x - y)^2 + 2/5 (y - z)^2)]

results in

  (x - y)^2 + 1/5 (y - z)^2  

which is what I assume you want.