Simplification test. Comparison between
Maple and Mathemtica
Updated March 12, 2007 by
Nasser M. Abbasi
This document can be downloaded in PDF format here.
March 12, 2007: Added more tests using Maple simplify() command with option called size. I learned about this new option for simplify, which is designed to reduce the size of the expression, from Maple help:
The simplify(expr, size) calling sequence is used to
attempt simplifying the expression size, performing only collections and simple decomposition of
fractional powers in the coefficients  sometimes taking advantage of linear factors when they exist. No other
mathematical simplifications of the expression or its subexpressions is
performed. These operations, while simple and with low computational cost, may
remarkably structure the expression and reduce its size.
The concept of size used by these routines is close to the
concept of length, but function calls and radicals are considered of
bigger size than mathematically simpler objects of the same length. In this
framework size partly includes the idea of mathematical complexity (for
advanced users, see the routines `simplify/size/size` and `simplify/size/size/object`).
The approach used consists of collecting subexpressions using an
ordering based on size, then searching for possible fractional decompositions
or linear factors that lead to coefficients of smaller size. Functions are
handled by first simplifying in size their arguments, followed by reevaluating
the function when the simplification leads to simpler arguments. To avoid
reevaluating the functions, use the optional argument evaluate_known_functions=false.
Expressions given as a ratio between two subexpressions have the
numerator and denominator simplified in size separately, and the returned
result constructed by dividing the expressions obtained (whenever this result
is simpler than the given expression).
The simplification of the expression size is not performed
automatically by the simplify command. To perform it, invoke
the routines by calling simplify with the extra argument size. Alternatively, the
simplification of size is an option in the context menu. To activate this menu,
highlight Maple output and rightclick with the mouse.
This is result of doing informal simplification measure on expressions using Maple and Mathematica based on script posted on sci.math.symbolic by Dr Carlos and slightly changed by me for formatting purposes and to add a new calculation for the percentage of the size of the expression after simplification to that before the simplification.
Maple used: Version 11 on Windows XP
Mathematica used: Version 5.2 on Windows XP
PC: Intel P4, 2.4 GHz, 750 MB RAM.
For the Mathematica tests, one test used Simplify[] and the second used FullSimplify[]. Both tested used LeafCount[] command to count the size of the expression. Before start of each test, the Mathematic Kernel was restarted.
For Maple, 2 tests are done, Both use the length() command as a measure of size of expression. In one test simplify() was called, and in the second test simplify() with the option size, which is designed to reduce the size of the expression.
Maple simplify(expr,size) Test1
Test2
Test3
Test4
Test5

Maple
simplify(expr) Test1
Test2
Test3
Test4
Test5

Mathematica
Simplify[expr] Test1
Test2
Test3
Test4
Test5

Mathematica
FullSimplify[expr] Test1
Test2
Test3
Test4
Test5

For N=1, Maple, using simplify() without the size option, was able to obtain a size=1 after simplification. This is good. For tests N=2,3,4,5 (i.e. as the expression size is increasing), the size of the expression after simplification was about 42% to about 50% compared to the size of the expression before simplification.
Mathematica was not able to obtain size=1 using either Simplify[] nor FullSimplify[] for N=1, but on average, the final size of the expression was about half that of Maple final size of expression when Maple test was done using simplify().
However, when using Maple simplify() command with the size option, Maple was able to reduce the size of the expression to about the same size as Mathematica (few percentage off) and Maple did this in an amazing speed.
However, since with Maple, the length() function was used to determine the size of the expression, and with Mathematica, the function LeafCount[] was used, it is not clear to me that this is a completely valid comparison as the complexity reduction of the expression might not be reflected similarly. This is why I included an image of each test output for comparison so as to allow one to visually see for themselves.
For Mathematica, Using Simplify[], Mathematica achieved a simplification in range of 22% to 35%. While using FullSimplify[], the simplification ranged from 17% to 26%. This shows that FullSimplify[] can achieve about 10% more simplification than Simplify[].
It is also interesting to notice that with Mathematica, as the size of the expression increased (N=4 and N=5), FullSimplify[] achieved the same simplification reduction as Simplify[] did, but using much more CPU time. For N=5, FullSimplify[] CPU usage increased dramatically. One might conclude that using FullSimplify[] for larger expression is not as efficient as using it for smaller expressions. It looks like FullSimplify might needs to be tuned up more for larger expressions?
Using FullSimplify[] was most productive for N=1 and N=2, where percentage simplification improved by more than 10%
For the CPU time used by Simplification. Maple simplify() was much faster than Mathematica FullSimplify[] as expected since FullSimplify[] is designed to do more simplification on expressions. Maple simplify() CPU time ranged from 0.2 to 18.5 seconds. While Mathematica FullSimplify[] CPU time ranged from about 1.8 seconds to 518 seconds. Mathematica Simplify[] command on the other hand used less than 1 second.
This is Maple implementation of simplification test posted
on the internet
sci.symbolic news group. The original test was written in
Mathematica by Dr Carlos.
For Maple, I run this test twice, once using simpify() and once using simplify() with the size option.
>
restart;
#names of indexes into matrix which
collects the data into
ID:=1: BEFORE_COUNT:=2:
AFTER_COUNT:=3: SIMPLIFY_CPU:=5:
PERCENT_SIMPLIFICATION:=4:
xnum:=((64*sqrt(2))*ln(32*sqrt(2))+(32*sqrt(2))*ln(1712*sqrt(2))+3224*sqrt(2));
xden:=(48*sqrt(2)72)*(ln(sqrt(2)+1)+sqrt(2))/3;
x:=xnum/xden;
print("check:",evalf(x,300));
n:=5:
stab:=Matrix(5,5,0): #Matrix where to keep track of stats
xtab:=expand({x,x^2,x^4,x^8,x^16,x^32}):
s:=Vector(5,0);
for i from 1 to n do
stab[i,ID]:=i:
stab[i,BEFORE_COUNT]:=length(xtab[i]):
startingTime :=time():
s[i]:=simplify(xtab[i]);
#s[i]:=simplify(xtab[i],size):
stab[i,SIMPLIFY_CPU]:=time()startingTime:
stab[i,AFTER_COUNT]:=length(s[i]):
stab[i,PERCENT_SIMPLIFICATION]:=ceil(100.*stab[i,AFTER_COUNT]/stab[i,BEFORE_COUNT]):
od:
stab;
>