Fix for bug [ 1370433 ] trigsimp(sqrt(%i2)) !=sqrt(trigsimp(%i2))?



I think the issue is more basic.

the bug is in the simplifier, which transforms sqrt(x^2) to abs(x).

Mathematica 5.1 returns  sqrt(x^2).  Or in its words, Sqrt[x^2].

Why?

There are two square roots. Which do you mean?  { there is a typo-- it is
either 2*abs(cos(x))  or -2*abs(cos(x)).}

Since you have not specified which one, how is Maxima to know?

To be correct, perhaps we could return both square roots, or let the answer
be ambiguous.

That is to say, sqrt(x^2) is the set {x,-x}  or perhaps leave it alone.

Radcan never introduces abs().  It sometimes chooses a branch that was not
intended by the user, but it is consistent within its own rules and it
chooses one >>algebraic<< interpretation for reductions. Abs() is not
algebraic.




> -----Original Message-----
> From: maxima-bounces at math.utexas.edu [mailto:maxima-
> bounces at math.utexas.edu] On Behalf Of Raymond Toy
> Sent: Thursday, November 09, 2006 2:28 PM
> To: maxima at math.utexas.edu
> Subject: Fix for bug [ 1370433 ] trigsimp(sqrt(%i2))
> !=sqrt(trigsimp(%i2))?
> 
> 
> A quick summary of the bug:
> 
> expr:2*(cos(x)^2-sin(x)^2)+2;
> 
> sqrt(trigsimp(expr)) -> 2*abs(x)
> trigsimp(sqrt(expr)) -> -2*abs(cos(x))
> 
> I would expect these to be the same.
> 
> The issue is the call to radcan in trigsimp in
> share/trigonometry/trgsmp.mac:
> 
> trigsimp(x):=
>   trigsimp3(radcan(apply1(x,
>                           trigrule1,trigrule2,trigrule3,trigrule4,
> 			  htrigrule1,htrigrule2,htrigrule3,htrigrule4)))$
> 
> The call to radcan is the source of this problem.  If radcan is
> removed or replaced by ratsimp, the problem goes away.  Tracing radcan
> shows what's happening: it simplifies sqrt(2*(cos(x)^2-sin(x)^2)+2) to
> sqrt(2)*%i*sqrt(sin(x)^2-cos(x)^2-1).  trigsimp3 simplifies the sqrt
> part to sqrt(-2*cos(x)^2) -> sqrt(2)*%i*abs(cos(x)).  Hence the
> -2*abs(cos(x)).
> 
> I think we should change this to be ratsimp instead of radcan.
> 
> Thoughts?
> 
> Ray
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima