#779 trigsimp and trigreduce & square roots

closed
nobody
5
2011-02-10
2005-09-08
No

Sometimes trigsimp and trigreduce seem to make
assumptions of the sign of variables. Consider:

(%i1) sqrt(r^2 * cos(x)^2 + r^2 * sin(x)^2);
(%o1) sqrt(r^2*sin(x)^2+r^2*cos(x)^2)
(%i2) trigsimp(%o1);
(%o2) r <--- should be |r|

(%i3) trigreduce(%o1);
(%o3) r <--- should be |r|

(%i4) trigreduce(sqrt(r^2));
(%o4) abs(r) <---- OK here

(%i5) trigsimp(sqrt(r^2));
(%o5) abs(r) <--- OK here too

And oh my! Using z instead of r makes the problem
go away.

(%i9) sqrt(z^2 * cos(x)^2 + z^2 * sin(x)^2);
(%o9) sqrt(sin(x)^2*z^2+cos(x)^2*z^2)
(%i10) trigsimp(%);
(%o10) abs(z) <--- OK here as well!

(%i6) build_info();
Maxima version: 5.9.1.1cvs
Maxima build date: 14:5 8/30/2005
host type: i686-pc-mingw32
lisp-implementation-type: GNU Common Lisp (GCL)
lisp-implementation-version: GCL 2.6.7

Barton

Discussion

  • Barton Willis

    Barton Willis - 2005-09-10

    Logged In: YES
    user_id=895922

    A possible fix:

    (defun sp1expt (b e)
    (cond ((mexptp b) (power b e))
    ;;(sp1expt (cadr b) (m* e (caddr b)))) <--- (sp1expt x^2
    1/2) --> x

    The old code calls sp1expt after it does (a^b)^c --> a^(bc).
    I'm not sure if that second call to sp1expt ever makes a
    difference.

    Barton

     
  • Raymond Toy

    Raymond Toy - 2005-10-05

    Logged In: YES
    user_id=28849

    Neat.

    It appears to be a bug in radcan.
    radcan(sqrt(r^2*cos(x)^2+r^2*sin(x)^2)) returns just
    r*stuff, but with r replaced with z, it returns
    abs(z)*stuff. Tracing radcan and friends, I see that fr1
    returns something different for the r version.

    I don't know why.

     
  • Robert Dodier

    Robert Dodier - 2006-08-13

    Logged In: YES
    user_id=501686

    Observed in 5.9.3cvs.

     
  • Robert Dodier

    Robert Dodier - 2006-08-13
    • labels: --> Lisp Core - Trigonometry
     
  • Raymond Toy

    Raymond Toy - 2006-11-10

    Logged In: YES
    user_id=28849

    What radcan returns seems to depend on the order of the
    variables.

    radcan(sqrt(c^2*cos(b)^2+c^2*sin(b)^2)) ->
    sqrt(sin(b)^2+cos(b)^2)*abs(c)
    radcan(sqrt(a^2*cos(b)^2+a^2*sin(b)^2)) ->
    a*sqrt(sin(b)^2+cos(b)^2)

    This seems to be true for any variables ordered in this way.

    FR1 returns different things in these two cases. For the
    first, FR1 factors c^2*cos(b)^2+c^2*sin(b)^2 to
    (sin(b)^2+cos(b)^2)*c^2.

    In the second, it's not factored out.

    Don't know why.

     
  • Dieter Kaiser

    Dieter Kaiser - 2011-02-10

    Fixed in trigred.lisp revision 1.11.
    The original example works now as expected.
    Closing this bug report as fixed.
    Dieter Kaiser

     
  • Dieter Kaiser

    Dieter Kaiser - 2011-02-10
    • status: open --> closed
     

Log in to post a comment.