bson@fruit-and-fibre.ai.mit.edu (Jan Brittenson) (10/21/90)
This is a general Taylor program. It returns the Taylor series coinciding with a function at any given X. Not just at X=0 (i.e. Maclaurin series), like the built-in function TAYLR. It uses the SYSEVAL #546Dh to create the algebraic 'n!' where n is an arbitrary real. The SYSEVAL #54AFh is used to obtain the function ! and the short <2h>. The usage is identical to TAYLR (is TAYLR differentiable?) with an additional fourth argument, the X value. Two examples - the former a Maclaurin series, the latter a Taylor series at X=1: Example 1. 'EXP(X)' 'X' 3 0 TAYLRX --> '1+X/1!+X^2/2!+X^3/3!' 'EXP(X)' 'X' 3 TAYLR --> '1+X+0.5*X^2+1/3!*X^3' Example 2. 'LN(X)' 'X' 5 1 TAYLRX --> '(X-1)/1!-(X-1)/2!+2*(X-1)^3/3!-6*(X-1)^4/4!+24*(X-1)^5/5!' 'LNT(X)' SWAP = DEFINE 1.25 LN 1.25 LNT - --> -.000033532019 O / \/ /\~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ O \ @ TAYLRX #8CD8h @ General Taylor series @ f: function of dv @ dv: variable of differentiation @ N: polynomial degree @ pt: X value @ FC: ! @ S3: <2h> @ c: degree counter %%HP: T(3)A(R)F(,); \<< \-> f dv N pt \<< '1!' # 54AFh SYSEVAL 3 ROLL DROP dv pt 2 \->LIST \-> FC S3 dv0 \<< f dv0 | @ start with f(pt) 1 N FOR c f dv \.d 'f' STO @ f'(dv) -> f f dv0 | dv pt - c ^ * @ 'f(pt)*(dv-pt)^c' c FC S3 # 546Dh SYSEVAL / + @ 'c!' / ; sum up NEXT \>> \>> \>>