#2554 sign(sqrt(-x^2-x^4)) => zero

None
open
nobody
Lisp Core (472)
5
2013-05-24
2013-02-26
Stavros Macrakis
No

As the title says, sign(sqrt(-x^2-x^4)) => zero. This should give an "argument cannot be imaginary" error as does sign(sqrt(-1-x^2)).

A consequence of this bug is abs(sqrt(-x^2-x^4)) => 0.

Discussion

  • Barton Willis
    Barton Willis
    2013-02-27

    Same bug, I suppose

    $ ./maxima-local
    Maxima 5.28.0_232_g5b9ec8e http://maxima.sourceforge.net
    using Lisp Clozure Common Lisp Version 1.8-r15286M (WindowsX8664)

    (%i1) assume(p <=0)$

    (%i2) csign(sqrt(p));
    (%o2) zero

     
  • Barton Willis
    Barton Willis
    2013-02-27

    The bug is almost surely in the function sign-mexpt--here is a portion of this
    code. On the first line sign-base is $nz, so sign-base is set to $zero. After that
    the global sign is set to sign-base. The final conditional doesn't have a clause for
    $zero, so sign remains zero. A quick cure would be append a clause ((eq sign-base '$zero) ..., I suppose.

            ((eq sign-base '$nz)
             (setq sign-base '$zero)
             (tdzero base1))
            (t (setq sign-base '$pz)
               (tdpz base1)))))
       (cond ((eq sign-expt '$neg)
          (cond ((eq sign-base '$zero) (dbzs-err x))
            ((eq sign-base '$pz)
             (setq sign-base '$pos)
             (tdpos base1))
            ((eq sign-base '$nz)
             (setq sign-base '$neg)
             (tdneg base1))
            ((eq sign-base '$pnz)
             (setq sign-base '$pn)
             (tdpn base1)))))
       (setq sign sign-base))
      ((eq sign-base '$pos)
       (setq sign '$pos))
      ((eq sign-base '$neg)
       (if (eq evod '$odd)
           (setq sign '$neg)
         (setq sign (if *complexsign* '$complex '$pn)))))))
    
     
  • Robert Dodier
    Robert Dodier
    2013-05-24

    • labels: --> Lisp Core