#151 carg(complex)

closed
5
2008-08-30
2002-10-08
Anonymous
No

carg ignores the complex declaration; since z
is complex, the question Is z postive, negative, or
zero is meaningless.

(C1) declare(z,complex);
(D1) DONE
(C2) carg(z);
Is z positive, negative, or zero?

pos;(D2) 0

Other functions in rpart (realpart, imagpart, ...) check for
complex arguments and work correctly. Another
bug is rectpart(log(x)) and rectform(plog(x)), with
x declared complex

(C1) declare(x,complex);
(D1) DONE
(C2) rectform(log(x));
Is x positive or negative?

pos;(D2) LOG(x)
(C3) rectform(plog(x));
Is x positive or negative?

pos;(D3) LOG(x)
(C4)

Again, the question Is x positive or negative is
meaningless.

Barton

Discussion

  • Robert Dodier

    Robert Dodier - 2005-02-06

    Logged In: YES
    user_id=501686

    The offending code is the function ABSARG in src/rpart.lisp.

    The strangeness in ABSARG affects $POLARFORM, $CARG,
    $REALPART and $IMAGPART applied to logarithms, and maybe
    other functions. In 5.9.1 (official release and current cvs
    as well):

    declare (u, complex)$
    polarform (u) => u (after asksign)
    carg (u) => 0 or %pi (after asksign)
    carg (log (u)) => 0 (after asksign)
    realpart (log (u)) => log(u) (after asksign)

    Here's a patch -- one new line to handle atoms which are
    declared complex:

    --- rpart.lisp 23 Nov 2004 18:25:33 -0000 1.6
    +++ rpart.lisp 6 Feb 2005 03:45:58 -0000
    @@ -440,6 +440,7 @@
    (cons (abs l) (argnum l)))
    ((memq l '($%e $%pi)) (cons l 0))
    ((eq l '$infinity) (cons '$inf '$ind))
    + ((kindp l '$complex) (cons (list '($cabs) l)
    (list '($carg) l)))
    (absflag (cons (take '(mabs) l) 0))
    (t ((lambda (gs)
    (cond ((eq gs '$positive) (cons l 0))

    After applying the patch:

    declare (u, complex)$
    polarform (u) => cabs(u) %e^(%i carg(u))
    carg (u) => carg(u)
    carg (log (u)) => atan2(carg(u), log(cabs(u)))
    realpart (log (u)) => log(cabs(u))
    imagpart (log (u)) => carg(u)

    I'll run the test suite and see what happens.

    Maxima version: 5.9.1.1cvs
    Maxima build date: 23:52 1/25/2005
    host type: i686-redhat-linux-gnu
    lisp-implementation-type: CLISP
    lisp-implementation-version: 2.31 (released 2003-09-01)

     
  • Robert Dodier

    Robert Dodier - 2005-08-31
    • labels: --> 460522
     
  • Robert Dodier

    Robert Dodier - 2006-04-09
    • labels: 460522 --> Lisp Core - Complex
     
  • Dan Gildea

    Dan Gildea - 2008-08-30

    Logged In: YES
    user_id=1797506
    Originator: NO

    fix below applied in rprart.lisp rev 1.12

     
  • Dan Gildea

    Dan Gildea - 2008-08-30
    • status: open --> closed
    • assigned_to: nobody --> dgildea
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks