2
/* This batch contains a function which returns an asymptotic expansion of
3
the GAMMA function truncated to N terms, in the variable Z.
4
Just say ASYMPGAMMA(Z,N);
5
It also contains a function which computes the asymptotic expansion of
6
GAMMA(z+a)/GAMMA(z+b). */
8
REMARRAY(%GAMA1,%GAMA)$
10
%GAMA1[N]:=%GAMA1[N-1]/(N+1)-(1/2)*SUM(%GAMA1[R]*%GAMA1[-R+N+1],R,2,N-1)$
11
/*The above array contains the a[n] as defined in Copson.*/
13
%GAMA[K]:=LAMBDA([FACTLIM],(2*K+1)*2^(1-K)*(2*K-1)!*%GAMA1[2*K+1]/(K-1)!)(-1)$
15
ASYMPGAMMA(Z,N):=(Z/%E)^Z*SQRT(2*%PI/Z)*
16
SUM(apply('EV,[%GAMA[K]])*Z^(-K),K,0,N)$
18
/* The following program computes the asymptotic expansion for
19
GAMMA(z-a)/GAMMA(z-b). Just call GAMMAR(z,a,b). */
21
GAMMAR(ZVAR,AVAR,BVAR,N):=BLOCK([A,B,W,T1,T2,T3,T4,T5,T6,T7,T8,T9,answer],
22
T1: TAYLOR((1/W+A-1/2)*LOG(W*A+1),W,0,N),
23
T2: TAYLOR(T1-subst(a=b,T1),W,0,N)+B-A,
24
T3: TAYLOR(%E^T2,W,0,N),
25
T4: SUM(%GAMA[K]*(A+1/W)^(-K),K,0,N),
26
T5: TAYLOR(LOG(T4),W,0,N),
27
T7: TAYLOR(T5-subst(a=b,T5),W,0,N),
28
T8: TAYLOR(%E^T7,W,0,N),
30
ANSWER: ZVAR^(AVAR-BVAR)*
31
subst([A=AVAR,B=BVAR,W=1/ZVAR],RATDISREP(T9)))$