Question: hints on when NOT to use simplify?

I have been using simplify() in number of places, and not really expecting it will do any harm. At worst, it will have no effect, or it will change the expression to different form, but the semantics will remain the same.

Until I noticed that odetest() fail on some of my solutions because I called simplify  on the solution before.

One example why this happens, is that Maple simplifies cos(2*x)*sqrt(1/cos(2*x)^2) to csgn(1/cos(2*x)) and this makes odetest fail. Adding assuming x::real has no effect on making odetest happy.

So now I changed simplify(sol) to simplify(sol,size) and this seems so far not to have this adverse effect. 

My main reason for calling simplify  is to make the expression smaller. In Mathematica that is what I do, In Mathematica there is no "size" option to Simplify.

So now, I am very worried about calling simplify() as is.

Could some Maple experts share some of their experience on this? Should one call simplify() only when an explicit option, like size, trig, exp, etc....is also used and not call simplify as is?

restart;

ode:= diff(y(x),x) = 2+2*sec(2*x)+2*y(x)*tan(2*x);
my_sol:= y(x) = ((2*x+sin(2*x))/(cos(2*x)*sqrt(1/cos(2*x)^2))+_C1)*sqrt(1+tan(2*x)^2);
odetest(my_sol,ode);

diff(y(x), x) = 2+2*sec(2*x)+2*y(x)*tan(2*x)

y(x) = ((2*x+sin(2*x))/(cos(2*x)*(1/cos(2*x)^2)^(1/2))+_C1)*(1+tan(2*x)^2)^(1/2)

0

#now simplify the solution first
simplify(my_sol);
odetest(%,ode);

y(x) = (_C1*csgn(1/cos(2*x))+sin(2*x)+2*x)/cos(2*x)

csgn(1, 1/cos(2*x))*_C1/cos(2*x)

simplify(my_sol) assuming x::real;
odetest(%,ode);

y(x) = (_C1*signum(cos(2*x))+sin(2*x)+2*x)/cos(2*x)

signum(1, cos(2*x))*_C1/cos(2*x)

simplify(my_sol,size);
odetest(%,ode);

y(x) = ((2*x+sin(2*x))/(cos(2*x)*(1/cos(2*x)^2)^(1/2))+_C1)*(1+tan(2*x)^2)^(1/2)

0

simplify(cos(2*x)*sqrt(1/cos(2*x)^2))

csgn(1/cos(2*x))

 

 

Download 072519.mw

 

 

Please Wait...