Question: how to improve my home made full_simplify() in Maple?

Maple does not have full_simplify() command like with Mathematica.

So I figured why not make one? 

Here is a basic implementation. All what it does is blindly tries different simplifications methods I know about and learned from this forum then at the end sorts the result by leaf count and returns to the user the one with smallest leaf count.

I tried it on few inputs.

Advantage of full_simplify() is that user does not have to keep trying themselves. One disadvantage is that this can take longer time. timelimit can be added to this to make it not hang.

Can you see and make more improvement to this function?

May be we all together can make a better full_simplify() in Maple to use. Feel free to edit and change.

#version 1.0  
#increment version number each time when making changes.

full_simplify:=proc(e::anything)
   local result::list;
   local f:=proc(a,b)
      RETURN(MmaTranslator:-Mma:-LeafCount(a)<MmaTranslator:-Mma:-LeafCount(b))
   end proc;

   #add more methods as needed

   result:=[simplify(e),
            simplify(e,size),
            simplify(combine(e)),
            simplify(combine(e),size),
            radnormal(evala( combine(e) )),
            simplify(evala( combine(e) )),
            evala(radnormal( combine(e) )),
            simplify(radnormal( combine(e) )),
            evala(factor(e)),
            simplify(e,ln),
            simplify(e,power),
            simplify(e,RootOf),
            simplify(e,sqrt),
            simplify(e,trig),
            simplify(convert(e,trig)),
            simplify(convert(e,exp)),
            combine(e)
   ];   
   RETURN( sort(result,f)[1]);   

end proc:

worksheet below

 


 

204648

#version 1.0  
#increment version number each time when making changes.

full_simplify:=proc(e::anything)
   local result::list;
   local f:=proc(a,b)
      RETURN(MmaTranslator:-Mma:-LeafCount(a)<MmaTranslator:-Mma:-LeafCount(b))
   end proc;

   #add more methods as needed

   result:=[simplify(e),
            simplify(e,size),
            simplify(combine(e)),
            simplify(combine(e),size),
            radnormal(evala( combine(e) )),
            simplify(evala( combine(e) )),
            evala(radnormal( combine(e) )),
            simplify(radnormal( combine(e) )),
            evala(factor(e)),
            simplify(e,ln),
            simplify(e,power),
            simplify(e,RootOf),
            simplify(e,sqrt),
            simplify(e,trig),
            simplify(convert(e,trig)),
            simplify(convert(e,exp)),
            combine(e)
   ];   
   RETURN( sort(result,f)[1]);   

end proc:

#test cases
T:=[(-192*cos(t)^6 + 288*cos(t)^4 - 912*cos(t)^3 - 108*cos(t)^2 + 684*cos(t) - 54)/(4608*cos(t)^9 - 10368*cos(t)^7 + 6208*cos(t)^6 + 7776*cos(t)^5 - 9312*cos(t)^4 - 2440*cos(t)^3 + 3492*cos(t)^2 + 372*cos(t) - 1169),
(10*(5+sqrt(41)))/(sqrt(70+10*sqrt(41))*sqrt(130+10*sqrt(41))),
((6-4*sqrt(2))*ln(3-2*sqrt(2))+(3-2*sqrt(2))*ln(17-12*sqrt(2))+32-24*sqrt(2))/(48*sqrt(2)-72)*(ln(sqrt(2)+1)+sqrt(2))/3,
(1/2)*exp((1/2)*x)*(cosh((1/2)*x)-cosh((3/2)*x)+sinh((1/2)*x)+sinh((3/2)*x))
];

[(-192*cos(t)^6+288*cos(t)^4-912*cos(t)^3-108*cos(t)^2+684*cos(t)-54)/(4608*cos(t)^9-10368*cos(t)^7+6208*cos(t)^6+7776*cos(t)^5-9312*cos(t)^4-2440*cos(t)^3+3492*cos(t)^2+372*cos(t)-1169), 10*(5+41^(1/2))/((70+10*41^(1/2))^(1/2)*(130+10*41^(1/2))^(1/2)), (1/3)*((6-4*2^(1/2))*ln(3-2*2^(1/2))+(3-2*2^(1/2))*ln(17-12*2^(1/2))+32-24*2^(1/2))*(ln(1+2^(1/2))+2^(1/2))/(48*2^(1/2)-72), (1/2)*exp((1/2)*x)*(cosh((1/2)*x)-cosh((3/2)*x)+sinh((1/2)*x)+sinh((3/2)*x))]

full_simplify~(T)

[-6*(10+cos(6*t)+38*cos(3*t))/(-975+18*cos(9*t)-70*cos(3*t)+194*cos(6*t)), (1/2)*2^(1/2), (1/9)*(ln(1+2^(1/2))+2^(1/2))^2, (1/2)*exp(x)-(1/2)*exp(-x)]

 


 

Download full_simplify.mw

Please Wait...