home
PDF

CAS simplification comparison between Maple and Mathemtica

Nasser M. Abbasi

May 10, 2012 page compiled on June 29, 2015 at 9:47pm

Contents

1 introduction
 1.1 links to older version using Maple 11 and Mathematica 5.2
 1.2 updated results using Maple 14 and Mathematica 8.04
2 results
 2.1 Mathematica
  2.1.1 using Simplify[]
  2.1.2 using FullSimplify[]
 2.2 Maple
  2.2.1 using LeafCount()
  2.2.2 using length()
3 side-by-side

1 introduction

1.1 links to older version using Maple 11 and Mathematica 5.2

A detailed but older version that used Maple 11 and Mathematica 5.2 is here which contains images to each expression used.

1.2 updated results using Maple 14 and Mathematica 8.04

This version only shows the final result using an updated version of Mathematica and Maple, but does not show each expression generated. When I have more time I hope to also show those in this updated version.

For this version I used Mathematica 8.04 and Maple 14, both on windows 7. The PC is intel i7 930 @ 2.8 Ghz with 8 GB memory

This is the result of doing a simplification measure on an expression using Maple and Mathematica using an expression posted on sci.math.symbolic by Dr Carlos.

The expression given in the original post can be found at http://sci4um.com/about26200.html

  xnum = ((6-4*Sqrt[2])*Log[3-2*Sqrt[2]]+(3-2*Sqrt[2])*Log[17-12*Sqrt[2]]+32-24*Sqrt[2]);
  xden = (48*Sqrt[2]-72)*(Log[Sqrt[2]+1]+Sqrt[2])/3;
  
  x    = xnum/xden;
  
  The answer is x = 1

x is the following expression

pict

and in expanded form

pict

Using x  as shown above , the function Expand[] in Mathematica and expand() in Maple are then applied to x, x2,x4,x8,x16,x32   , then the result is fully simplified again, and the leaf count (measure of simplifcation) is compared to the original expression to obtain a measure of the system simplification.

Mathematica has both Simplify[expr] and FullSimplify[expr] and Maple has simplify(expr,size) and simplify(expr). Here, I used only the simplify(expr,size) since LeafCount was used.

The tables below show the result of using both functions in each system.

The tables show the size of the expression before and after simplification, the percentage in size reduction and the cpu time used.

2 results

2.1 Mathematica

Source code used is

  xnum = ((6-4*Sqrt[2])*Log[3-2*Sqrt[2]]+(3-2*Sqrt[2])*Log[17-12*Sqrt[2]]+32-24*Sqrt[2]);
  xden = (48*Sqrt[2]-72)*(Log[Sqrt[2]+1]+Sqrt[2])/3;
  x    = xnum/xden;
  xtab = Expand[{x,x^2,x^4,x^8,x^16}];
  n    = Length[xtab];
  stab = Table[0,{n},{4}];
  
  For[i=1,i<= n,i++,
   {
    stab[[i,1]] = LeafCount[xtab[[i]]];
    s = Timing[Simplify[ xtab[[i]] ]];  (*use FullSimplify or Simplify *)
    stab[[i,2]] = LeafCount[ s[[2]] ];
    stab[[i,3]] = s[[1]];
    stab[[i,4]] = Round[100.0*stab[[i,2]]/stab[[i,1]]];
    }
  ];
  
  Grid[Join[{{"leaf count before","leaf count after","cpu","% reduction"}},stab],
       Frame->All
      ]
2.1.1 using Simplify[]

When running the above code, using Simplify[], this is the result

pict

2.1.2 using FullSimplify[]

When running the above code, using FullSimplify[], this is the result

pict

2.2 Maple

2.2.1 using LeafCount()

In maple, using with(MmaTranslator[Mma]) to access the function LeafCount().

Source code

  restart;
  with(MmaTranslator[Mma]):
  xnum := ((6-4*sqrt(2))*ln(3-2*sqrt(2))+(3-2*sqrt(2))*ln(17-12*sqrt(2))+32-24*sqrt(2)):
  xden := (48*sqrt(2)-72)*(ln(sqrt(2)+1)+sqrt(2))/3:
  x    := xnum/xden:
  
  n:=5:
  stab := Matrix(5,4,0):  #Matrix where to keep track of stats
  xtab : =expand({x,x^2,x^4,x^8,x^16}):
  
  for i from 1 to n do
  
      stab[i,1]:= LeafCount(xtab[i]):
  
      startingTime := time():
      s            := simplify(xtab[i],size):
      stab[i,3]    := time()-startingTime:
  
      stab[i,2]    := LeafCount(s):
      stab[i,4]    := ceil(100.*stab[i,2]/stab[i,1]):
  od:
  stab;

Columns have the same meaning as above.

pict

2.2.2 using length()

Source code used is

  restart;
  
  xnum := ((6-4*sqrt(2))*ln(3-2*sqrt(2))+(3-2*sqrt(2))*ln(17-12*sqrt(2))+32-24*sqrt(2)):
  xden := (48*sqrt(2)-72)*(ln(sqrt(2)+1)+sqrt(2))/3:
  x    := xnum/xden:
  
  n    := 5:
  stab := Matrix(5,4,0):  #Matrix where to keep track of stats
  xtab := expand({x,x^2,x^4,x^8,x^16}):
  
  for i from 1 to n do
  
      stab[i,1]:=length(xtab[i]):
  
      startingTime := time():
      s            := simplify(xtab[i],size):
      stab[i,3]    := time() - startingTime:
  
      stab[i,2]    := length(s):
      stab[i,4]    := ceil(100.*stab[i,2]/stab[i,1]):
  od:
  
  stab;

Columns have the same meaning as above.

pict

3 side-by-side

This shows Mathematica Simplify result against Maple simplify(expr,size) both using LeafCount.



Maple 14 Mathematica 8.04


pict pict


And this shows Mathematica FullSimplify result against Maple simplify(expr,size) both using LeafCount.



Maple 14 Mathematica 8.04


pict pict