Jacques Gélinas on Sun, 07 Apr 2019 16:39:56 +0200


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Padé approximants?


This is what I have; your formulas can vary (:-)

/*	  Padé approximation  http://mathworld.wolfram.com/PadeApproximant.html
	f(x) = sum(j=0,oo,aj*x^j) ~=~ [L/M] P(x)/Q(x)
          = sum(j=0,L,pj*x^j)/sum(j=0,M,qj*x^j),  q0=1

	p0 = a0
	p1 = a1+a0*q1
	pL = aL+a(L-1)*q1...+a0*qL
	0  = a(L+1)+aL*q1+...+a(L-M+1)*qM
	0  = a(L+M)+a(L+M-1)*q1...+a(L-M+1)*qM
*/
f(x)   = exp(x);
ak(k)  = if(k>=0,Vec(f(x))[k+1]);
P(L,M) = matdet(matrix(M+1,M+1,k,j,\
         if(k<=M, ak(L-M+k+j-1),\
         sum(i=M+1-j,L,ak(i+j-M-1)*x^i)) ));
Q(L,M) = matdet(matrix(M+1,M+1,k,j,\
         if(k<=M, ak(L-M+k+j-1), x^(M+1-j)) ));

ckpade()={[
P(0,0)==1, Q(0,0)==1,
P(1,0)==1+x, Q(1,0)==1,
P(0,1)==1, Q(0,1)==1-x,
-P(0,2)==1, -Q(0,2)==1-x+x^2/2!,
-P(0,3)==1, -Q(0,3)==1-x+x^2/2!-x^3/3!,
P(0,4)==1, Q(0,4)==1-x+x^2/2!-x^3/3!+x^4/4!,

P(1,1)==1+x/2, Q(1,1)==1-x/2
]};
ckpade()