Re: [Maxima-bugs] [ maxima-Bugs-1407378 ] polarform returns a rectangular expression for float argumen



>>>>> "Stavros" == Stavros Macrakis <macrakis at gmail.com> writes:

    Stavros> 1.  (*) text/plain          ( ) text/html           
    >> 
    >> the extra %e^0 seems like cruft in this case.


    Stavros> So basically you like the current behavior.

I think the following replacement for $polarform is a reasonable
compromise.  It leaves current behavior except that exp(num*%i) isn't
expanded into rectangular form.  All this replacement does is check to
see if the phase is exactly zero, and deletes the exponential part.
If the phase is non-zero, it sets the simp flag for mexpt so no
simplification is done, which fixes the reported bug.


I made some tests with 1 -> exp(%i*0), but multiplying two such polar
forms gives things like 72*1 which is bad.  Or things like
exp(2*%i*0), which is weird too.

Ray

(defmfun $polarform (xx)
  (cond ((and (not (atom xx))
	      (memq (caar xx) '(mequal mlist $matrix)))
	 (cons (car xx) (mapcar #'$polarform (cdr xx))))
	(t ((lambda (aas $%emode)
	      (let ((p (mul '$%i (cdr aas))))
		(if (and (numberp p) (zerop p))
		    (car aas)
		    (mul (car aas) `((mexpt simp) $%e ,p)))))
	    (absarg xx) nil))))