Fix for bug [ 1370433 ] trigsimp(sqrt(%i2)) != sqrt(trigsimp(%i2))?
Subject: Fix for bug [ 1370433 ] trigsimp(sqrt(%i2)) != sqrt(trigsimp(%i2))?
From: Raymond Toy
Date: Thu, 09 Nov 2006 17:27:52 -0500
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