File: taylor1.mac

package info (click to toggle)
maxima 5.42.1-1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 150,192 kB
  • sloc: lisp: 382,565; fortran: 14,666; perl: 14,365; tcl: 11,123; sh: 4,622; makefile: 2,688; ansic: 444; xml: 23; awk: 17; sed: 17
file content (35 lines) | stat: -rw-r--r-- 1,312 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* find the taylor series of a function of x which is defined implicitly
 by a polynomial equation in x and y, if there is a unique branch at a particular
 pt. 
 implicit_taylor(f,pt,deg,init_a0) where F is the implicit defining equation,
 pt is the value of x around which we wish to form the expansion, deg is the
 highest degree of x to appear in the expansion, and init_a0 is the initial value
 of y at point, for the branch for which we will form the expansion.

(C2) implicit_taylor(y^3+x*y^2+x*y+y-2,0,10,1);
	      10	 9	   8	    7	    6	    5	    4	 3
       83787 X	   2847 X    5853 X    189 X    21 X    23 X    15 X    X
(D2) - --------- + ------- + ------- - ------ - ----- + ----- - ----- - --
       134217728   8388608   4194304   65536    32768   2048    1024    32

								      2
								   3 X	  X
								 + ---- - - + 1
								    16	  2

*/

implicit_taylor(f,pt,deg,init_a0):=
 block([n:deg,ratwtlvl:deg,ratweights:[],expansion,res,ans:[],eqns],
  ratweight(x,1),
  expansion:sum((x-pt)^i*concat(a,i),i,0,n),
  res:sublis([y=expansion],f),
  res:ratsimp(res),
  eqns:create_list(coeff(res,x,i),i,1,n),
  ans:[a0=init_a0], 
  eqns:sublis(ans,eqns),
  for i:1 thru n do (ans:append(ans,solve(eqns[i],concat(a,i))),
                   eqns: sublis(ans,eqns)),
  sublis(ans,expansion));