home *** CD-ROM | disk | FTP | other *** search
/ PC Open 13 / pcopen13.iso / Zip / SM34A.ZIP / LIBRARY / SERIES.LI < prev    next >
Encoding:
Text File  |  1995-04-11  |  499 b   |  13 lines

  1. # series(f,x,x0,order)    generates a Taylor power series expansion for 
  2. #            f about the point x=x0 to order x^n.
  3. # series(f,x)        with the default x0=0 and order n=5.
  4. #     e.g. series(sin(x), x)    gives x-x^3/6+x^5/120
  5. # generate the Taylor power series for sin(x)
  6.  
  7. series(y_,x_,x0_,n_) := block(p:=y,
  8.   do(p:=d(p,x), q[j]:=p, j,1,n,1),
  9.   subs(subs(y+sum(q[j]*(xx-x0)^j/j!, j from 1 to n, 1),x = x0), xx = x ),
  10.   local(p) )
  11. series(y_,x_,x0_) := series(y,x,x0,5)
  12. series(y_,x_) := series(y,x,0,5)
  13.