Display bug in 5.6.



This program was written by Richard Zippel, now employed
by  DEC/Compaq/HP  as director of their Cambridge Research Lab.
I wonder if he would like to know of this?

willisb@unk.edu wrote:
> 
> Here is my analysis of the powerseries(1 / sqrt(1+x),x,0) bug
> (this was done with Maxima 5.6 under Linux).
> 
> (C1) display2d : false;
> 
> (D1) FALSE
> (C2) :lisp(trace srbinexpnd);
> 
> (SRBINEXPND)
> (C2) powerseries((1+x)^(1/2),x,0);
> 
>   1> (SRBINEXPND
>          ((N (RAT SIMP) 1 2) (A . 1) (W . |$x|) (M . 1) (X . |$x|)
>           (M . 1) (X . |$x|) (C . 1) (CC . 1)))
>   <1 (SRBINEXPND
>          ((%SUM)
>           ((MTIMES SIMP) ((RAT SIMP) 2 3)
>            ((MEXPT SIMP)
>             (($BETA SIMP)
>              ((MPLUS SIMP) ((RAT SIMP) 3 2) ((MTIMES SIMP) -1 $I1))
>              ((MPLUS SIMP) 1 $I1))
>             -1)
>            ((MEXPT SIMP) |$x| $I1))
>           $I1 0 $INF))
> (D2) 2*('SUM(x^I1/BETA(3/2-I1,I1+1),I1,0,INF))/3
> (C3) powerseries((1+x)^(-1/2),x,0);
> 
>   1> (SRBINEXPND
>          ((N (RAT SIMP) 1 2) (A . 1) (W . |$x|) (M . 1) (X . |$x|)
>           (M . 1) (X . |$x|) (C . 1) (CC . 1)))
>   <1 (SRBINEXPND
>          ((%SUM)
>           ((MTIMES SIMP) ((RAT SIMP) 2 3)
>            ((MEXPT SIMP)
>             (($BETA SIMP)
>              ((MPLUS SIMP) ((RAT SIMP) 3 2) ((MTIMES SIMP) -1 $I2))
>              ((MPLUS SIMP) 1 $I2))
>             -1)
>            ((MEXPT SIMP) |$x| $I2))
>           $I2 0 $INF))
> (D3) 2*('SUM(x^I2/BETA(3/2-I2,I2+1),I2,0,INF))/3
> 
> For both cases, srbinexpnd gets the same arguments;  surely,
> this is a bug.  To fix this, it might seem that we should simply
> negate the exponent when the numerator is 1 in sratexpnd;
> however, this would be wrong because srintegexpd expects the exponent
> to be the exponent of the denominator.  Thus in the
> function call (sratexpnd n d), we should  negate the exponent only
> if n = 1 and the exponent is not an integer. [The exponent is
> stored in the association list ans; n is the numerator of what
> is being expanded.]
> 
> My proposed fix:
> 
> (defun sratexpnd (n d)
>     (let ((ans (list nil))
>         (splist)
>         (linpat
>          '((mtimes) ((coefftt) (cc not-zero-free var))
>                   ((mexpt) ((mplus) ((coeffpt)
>                                (w m1 ((mexpt) (x equal var)
>                                           (m not-zero-free var)))
>                                (c freevar))
>                               ((coeffpp) (a freevar)))
>                          (n not-zero-free var)))))
>       (cond ((and (not (equal n 1)) (smono n var))
>              (m* n (sratexpnd 1 d)))
>             ((free d var)
>              (cond ((poly? n var)
>                   (m// n d))
>                  ((m1 n linpat)
>                   (m* (srbinexpnd (cdr ans)) (div* 1 d)))
>                  ((throw 'psex nil))))
>             ((smonop d var)
>              (cond ((mplusp n)
>                   (m+l (mapcar #'(lambda (q) (div* q d)) (cdr n))))
>                  (t (m// n d))))
>             ((not (equal 1 (setq *gcd* (ggcd (nconc (exlist n) (exlist d))))))
>              (sratsubst *gcd* n d))
>             ((and (equal n 1)
>                 (prog2 (setq d (let (($ratfac t))
>                               (ratdisrep ($rat (factor d) var))))
>                      (m1 d linpat)))
> 
>              ;; fix for powerseries(1/sqrt(1+x),x,) bug--------------
>              (cond ((not (integerp (cdr (assq 'n ans))))
>                   (setf (cdadr ans) (mul -1 (cdadr ans)))))
>              ;; end of bug fix---------------------------------------
> 
>              (m// (srbinexpnd (cdr ans)) (cdr (assq 'cc (cdr ans)))))
>             (t
>              (and *ratexp (throw 'psex nil))
>              (if (not (eq (caar d) 'mtimes)) (ratexand1 n d))
>              (do ((p (cdr d) (cdr p)))
>                ((null p) (ratexand1 n d))
>                (cond ((or (eq (car p) var)
>                         (and (mexptp (car p)) (eq (cadaar p) var)))
>                     (return (m* (sratexpnd n (meval (div* d (car p))))
>                               (list '(mexpt) (car p) -1))))))))))
> 
> Under Common Lisp, we use assoc instead of assq
> 
> ....
>              (cond ((not (integerp (cdr (assoc 'n ans :test #'eq))))
>                   (setf (cdadr ans) (mul -1 (cdadr ans)))))
>              (print `(ans = ,ans))
>              (m// (srbinexpnd (cdr ans)) (cdr (assoc 'cc (cdr ans) :test #'eq))))
> ....
> 
> (assq uses sloop; I remember some disscussion about expunging sloop
> from Maxima.)
> 
> Barton
> 
> Wolfgang Jenkner <wjenkner@inode.at>@www.ma.utexas.edu on 08/03/2002
> 10:20:25 AM
> 
> Sent by:    maxima-admin@www.ma.utexas.edu
> 
> To:    Roberto Baginski <rbaginski@uol.com.br>
> cc:    Raymond Toy <toy@rtp.ericsson.se>, Maxima List
>        <maxima@www.ma.utexas.edu>
> 
> Subject:    Re: [Maxima] Display bug in 5.6.
> 
> Roberto Baginski <rbaginski@uol.com.br> writes:
> 
> >
> > Surprisingly or not, old Maxima 5.5 (running on Windows) displays it
> > correctly (see below).
> >
> > Maxima 5.5 Tue Dec 5 16:55:33 2000 (with enhancements by W. Schelter).
> > Licensed under the GNU Public License (see file COPYING)
> > (C1) powerseries(1/sqrt(1+x), x, 0);
> >
> >                  INF
> >                  ====        I1
> >                  \          x
> >                2  >     --------------------
> >                  /       3
> >                  ====   BETA(- - I1, I1 + 1)
> >                  I1 = 0        2
> > (D1)                 -----------------------------
> >                          3
> 
> Except that the result is wrong.  As a matter of fact this is the
> Taylor series of sqrt(1+x) at x=0...
> 
> Wolfgang
> --
> wjenkner@inode.at
> 
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
> 
> _______________________________________________
> Maxima mailing list
> Maxima@www.math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima