From: SourceForge.net <noreply@so...>  20080830 19:12:13

Bugs item #620246, was opened at 20021008 10:18 Message generated for change (Comment added) made by dgildea You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=620246&group_id=4933 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Lisp Core  Complex Group: None >Status: Closed >Resolution: Fixed Priority: 5 Private: No Submitted By: Nobody/Anonymous (nobody) >Assigned to: Dan Gildea (dgildea) Summary: carg(complex) Initial Comment: 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  >Comment By: Dan Gildea (dgildea) Date: 20080830 15:12 Message: Logged In: YES user_id=1797506 Originator: NO fix below applied in rprart.lisp rev 1.12  Comment By: Robert Dodier (robert_dodier) Date: 20050205 23:04 Message: 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: i686redhatlinuxgnu lispimplementationtype: CLISP lispimplementationversion: 2.31 (released 20030901)  You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=104933&aid=620246&group_id=4933 