powerseries
- Subject: powerseries
- From: Dan Gildea
- Date: Wed, 11 Jul 2007 19:49:25 -0400
On Wed, July 11, 2007 at 8:44AM, Barton Willis wrote:
> I think the function %piargs (in trigi.lisp) is buggy
this seems to fix it:
*** trigi.lisp 19 Apr 2007 12:47:19 -0400 1.27
--- trigi.lisp 11 Jul 2007 11:30:13 -0400
***************
*** 631,637 ****
(cond ((and (integerp (car x)) (integerp (cdr x))) 0)
((not (mevenp (car x)))
(cond ((null ratcoeff) nil)
! ((alike1 (cdr x) '((rat) 1 2))
(power -1 (add ratcoeff -1//2)))))
((or (alike1 '((rat) 1 6) (setq x (mmod (cdr x) 2))) (alike1 '((rat) 5 6) x)) 1//2)
((or (alike1 '((rat) 1 4) x) (alike1 '((rat) 3 4) x)) (div (power 2 1//2) 2))
--- 631,637 ----
(cond ((and (integerp (car x)) (integerp (cdr x))) 0)
((not (mevenp (car x)))
(cond ((null ratcoeff) nil)
! ((and (integerp (car x)) (alike1 (cdr x) '((rat) 1 2)))
(power -1 (add ratcoeff -1//2)))))
((or (alike1 '((rat) 1 6) (setq x (mmod (cdr x) 2))) (alike1 '((rat) 5 6) x)) 1//2)
((or (alike1 '((rat) 1 4) x) (alike1 '((rat) 3 4) x)) (div (power 2 1//2) 2))
(%i2) powerseries(1/(1+x+x^2),x,0)$
(%i3) rectform(%);
Is x positive or negative?
pos;
(%o3) 'sum((-sin(%pi*(-i1-1)/3)*(-1)^i1/sqrt(3)-sin(2*%pi*(-i1-1)/3)/sqrt(3))
*x^i1,i1,0,inf)
+%i*'sum((cos(%pi*(-i1-1)/3)*(-1)^i1/sqrt(3)
+cos(2*%pi*(-i1-1)/3)/sqrt(3))
*x^i1,i1,0,inf)
(%i4) subst(inf=5,%);
(%o4) -x^4+x^3-x+1
(%i5) declare(y, integer);
(%o5) done
(%i6) cos(2*y*%pi/3);
(%o6) cos(2*%pi*y/3)
(%i7) cos(2*y*%pi);
(%o7) 1
(%i8) cos(y*%pi);
(%o8) (-1)^y
(%i9) cos(3*y*%pi);
(%o9) (-1)^y