;; convert truncated power series (TPS), sometimes called Taylor series ;; from series representation to a lisp of subparts. ;; see example: ;; listsrdisrep(taylor(sin(x),x,0,10)) produces: ;; tps(var=x,trunc=10,expons=[1,3,5,7,9],coefs=[1,-1/6,1/120,-1/5040,1/362880]) ;; I'm using structures (see defstruct). Also I'm using CL rational numbers ;; for exponents. Someone who knows how to do (/ 1 2) to produce Maxima ((rat) 1 2) ;; could fix this. ;; Richard Fateman 1/25/2014 (defun $listsrdisrep (r) (let ((varlist (mrat-varlist r)) (genvar (mrat-genvar r))) (mapc #'(lambda (exp genv) (putprop genv exp 'disrep)) varlist genvar) (setup-multivar-disrep r) (listpsdisrep (cdr r)))) (defun listpsdisrep (p) (if (psp p) (listpsdisrep2 (terms p) (getdisrep (gvar-o p)) (trunc-lvl p)) ;(if (or $psexpand (trunc-lvl p)) '(mplus trunc) '(mplus exact)) (rcdisrep p))) (defun listpsdisrep2 (p var trunc) (if (or $ratexpand $psexpand) (psdisrep2expand p var) (do ((coefs () (cons (listpsdisrep (lc p)) coefs)) (expons() (cons (/(car (le p)) (cdr (le p))) expons)) (p p (cdr p))) ((or (null p) (e> (le p) trunc)) (list '($tps) var (/ (car trunc)(cdr trunc)) (cons '(mlist) (nreverse expons)) (cons '(mlist) (nreverse coefs))))))) (defstruct1 '(($tps) $var $trunc $expons $coefs))