home *** CD-ROM | disk | FTP | other *** search
- # series(f,x,x0,order) generates a Taylor power series expansion for
- # f about the point x=x0 to order x^n.
- # series(f,x) with the default x0=0 and order n=5.
- # e.g. series(sin(x), x) gives x-x^3/6+x^5/120
- # generate the Taylor power series for sin(x)
-
- series(y_,x_,x0_,n_) := block(p:=y,
- do(p:=d(p,x), q[j]:=p, j,1,n,1),
- subs(subs(y+sum(q[j]*(xx-x0)^j/j!, j from 1 to n, 1),x = x0), xx = x ),
- local(p) )
- series(y_,x_,x0_) := series(y,x,x0,5)
- series(y_,x_) := series(y,x,0,5)
-