home *** CD-ROM | disk | FTP | other *** search
- "File: SPECIAL.MTH (c) 02/23/90 Soft Warehouse, Inc."
-
- "Special Functions, Probability Distributions & Constants --"
-
- "Reference: Abramowitz & Stegun, Handbook of Mathematical Functions, Dover."
-
- "PART 1, CONSTANTS:"
-
- "Lower-case gamma = lim(sum(1/k,k,1,m) - ln m, m, inf), to 25 sig. digits:"
-
- EULER_GAMMA:=0.577215664901532860606512
-
- "PART 2, EXPONENTIAL AND LOGARITHMIC INTEGRALS:"
-
- "A series for the exponential integral, Ei(x)=-int(ê^-t/t,t,-x,inf), x>0:"
-
- EI(x,m):=EULER_GAMMA+LN(x)+SUM(x^k_/(k_*k_!),k_,1,m)
-
- "A series for the logarithmic integral, li(x)=int(1/ln t,t,0,x), x>1:"
-
- LI(x,m):=EI(LN(x),m)
-
- "The nth exponential integral, approximating inf by 10 (2+|z|):"
-
- EN(n,z):=INT(#e^(-z*t_)/t_^n,t_,1,INF)
-
- "An asymptotic series for the nth exponential integral as z -> inf:"
-
- EN_ASYMP(n,z,m):=#e^(-z)/z*SUM(PERM(n+k_-1,k_)/(-z)^k_,k_,0,m)
-
- "A degree m power series approximation for EN (1, z):"
-
- E1(z,m):=-EULER_GAMMA-LN(z)-SUM((-z)^k_/(k_*k_!),k_,1,m)
-
- "The sine integral. Use Taylor on the integral to get a power series:"
-
- SI(z):=INT(SIN(t_)/t_,t_,0,z)
-
- "The cosine integral. Use Taylor on the integral to get a power series:"
-
- CI(z):=EULER_GAMMA+LN(z)+INT((COS(t_)-1)/t_,t_,0,z)
-
- "PART 3, RELATIVES OF THE GAMMA FUNCTION:"
-
- "Generalized Pochhammer symbol, (a)x:"
-
- POCHHAMMER(a,x):=GAMMA(a+x)/GAMMA(a)
-
- "Tail-truncated aprx. to PSI(z) = (d/dz gamma(z))/gamma(z), for |phase z|<PI/2~
- :"
-
- PSI(z):=LN(z)-1/(2*z)-2*INT(t_/((t_^2+z^2)*(#e^(2*PI*t_)-1)),t_,0,INF)
-
- "An m-term + tail aprx. to POLYGAMMA(n,z) = (d/dz)^(n) PSI(z) for z/=0,-1,-2,.~
- ..:"
-
- "For about 6 significant digits use m about 5 |z| n^-.75 + 18 n^-.9"
-
- POLYGAMMA(n,z,m):=(-1)^(n-1)*n!*(1/(n*(z+m+1/2)^n)+SUM((z+k_)^(-n-1),k_,0,m))
-
- "The incomplete gamma function for RE(z)>0:"
-
- INCOMPLETE_GAMMA(z,w):=1/GAMMA(z)*(w^z/z+INT((#e^(-t_)-1)*t_^(z-1),t_,0,w))
-
- "A series useful near where the above is indeterminate at z=0,-1,-2,..."
-
- INCOMPLETE_GAMMA_SERIES(z,w,m):=#e^(-w)*w^z*SUM(w^(m-k_)/GAMMA(z+m-k_+1),k_,0,~
- m)
-
- "The complete beta function:"
-
- BETA(z,w):=GAMMA(z)*GAMMA(w)/GAMMA(z+w)
-
- "The incomplete Beta function or distribution, using singularity cancellation:"
-
- INCOMPLETE_BETA(x,z,w):=(x^z/z+(1-(1-x)^w)/w+INT(t_^(z-1)*((1-t_)^(w-1)-1)-(1-~
- t_)^(w-1),t_,0,x))/BETA(z,w)
-
- "PART 4, RELATIVES OF THE ERROR FUNCTION:"
-
- "The Fresnel sine integral:"
-
- FRESNEL_S(z):=INT(SIN(PI*t_^2/2),t_,0,z)
-
- "A series approximation to the Fresnel sine integral:"
-
- FRESNEL_S_SERIES(z,m):=SUM((-1)^k_*(PI/2)^(2*k_+1)*z^(4*k_+3)/((2*k_+1)!*(4*k_~
- +3)),k_,0,m)
-
- "The Fresnel cosine integral:"
-
- FRESNEL_C(z):=INT(COS(PI*t_^2/2),t_,0,z)
-
- "A series approximation to the Fresnel cosine integral:"
-
- FRESNEL_C_SERIES(z,m):=SUM((-1)^k_*(PI/2)^(2*k_)*z^(4*k_+1)/((2*k_)!*(4*k_+1))~
- ,k_,0,m)
-
- "PART 5, BESSEL FUNCTIONS:"
-
- "The nth order Bessel function of the first kind with RE(n) > -1/2:"
-
- BESSEL_J(n,z):=(z/2)^n/(SQRT(PI)*GAMMA(n+1/2))*INT(COS(z*COS(t_))*SIN(t_)^(2*n~
- ),t_,0,PI)
-
- "The truncated Taylor series is more efficient for |z| < about 10:"
-
- BESSEL_J_SERIES(n,z,m):=(z/2)^n*SUM((-z^2/4)^k_/(k_!*(n+k_)!),k_,0,m)
-
- "An asymptotic form with error O(#e^IM(z)/|z|) as |z| --> inf"
-
- BESSEL_J_ASYMP(n,z):=SQRT(2/(PI*z))*COS(z-(n+1/2)*PI/2)
-
- "The nth-order Bessel function of the 2nd kind for noninteger n:"
-
- BESSEL_Y(n,z):=(BESSEL_J(n,z)*COS(n*PI)-BESSEL_J(-n,z))/SIN(n*PI)
-
- "An asymptotic form with error O(#e^IM(z)/|z|) as |z| --> inf"
-
- BESSEL_Y_ASYMP(n,z):=SQRT(2/(PI*z))*SIN(z-(n+1/2)*PI/2)
-
- "The Airy function Ai(z):"
-
- AI(z):=SQRT(-z)/3*(BESSEL_J(1/3,2*(-z)^(3/2)/3)+BESSEL_J(-1/3,2*(-z)^(3/2)/3))
-
- "The BAiry function Bi(z):"
-
- BI(z):=SQRT(-z/3)*(BESSEL_J(1/3,2*(-z)^(3/2)/3)-BESSEL_J(-1/3,2*(-z)^(3/2)/3))
-
- "PART 6, HYPERGEOMETRIC FUNCTIONS:"
-
- "Kummer's confluent hypergeometric function 1F1(a;b;z), with singularities sub~
- tracted:"
-
- KUM_AUX(a,b,z):=(1/2)^a/a+INT(t_^(a-1)*(#e^(z*t_)*(1-t_)^(b-a-1)-1),t_,0,1/2)
-
- KUMMER(a,b,z):=GAMMA(b)/(GAMMA(b-a)*GAMMA(a))*(KUM_AUX(a,b,z)+#e^z*KUM_AUX(b-a~
- ,b,-z))
-
- "A truncated series for Kummer's confluent hypergeometric function:"
-
- KUMMER_SERIES(a,b,z,m):=GAMMA(b)/GAMMA(a)*SUM(GAMMA(a+k_)*z^k_/(GAMMA(b+k_)*k_~
- !),k_,0,m)
-
- "The Gauss hypergeometric function 2F1(a,b,c,z), using singularity cancellatio~
- n:"
-
- HYP_AUX(a,b,c,z):=(1/2)^b/b+INT(t_^(b-1)*((1-t_)^(c-b-1)*(1-t_*z)^(-a)-1),t_,0~
- ,1/2)
-
- HYPERGEOMETRIC(a,b,c,z):=GAMMA(c)/(GAMMA(b)*GAMMA(c-b))*(HYP_AUX(a,b,c,z)+(1-z~
- )^(-a)*HYP_AUX(a,c-b,c,z/(z-1)))
-
- "A truncated series for the Gauss hypergeometric function:"
-
- HYPERGEOMETRIC_SERIES(a,b,c,z,m):=GAMMA(c)/(GAMMA(a)*GAMMA(b))*SUM(GAMMA(a+k_)~
- *GAMMA(b+k_)*z^k_/(GAMMA(c+k_)*k_!),k_,0,m)
-
- "PART 7, ELLIPTIC INTEGRALS:"
-
- "Elliptic integral of the 1st kind:"
-
- ELLIPTIC_F(a,m):=INT(1/SQRT(1-m*SIN(t_)^2),t_,0,a)
-
- "Elliptic integral of the 2nd kind:"
-
- ELLIPTIC_E(a,m):=INT(SQRT(1-m*SIN(t_)^2),t_,0,a)
-
- "Elliptic integral of the 3rd kind:"
-
- ELLIPTIC_PI(a,n,m):=INT(1/((1-n*SIN(t_)^2)*SQRT(1-m*SIN(t_)^2)),t_,0,a)
-
- "PART 8, ORTHOGONAL POLYNOMIALS:"
-
- "Chebychev polynomials of the 1st kind, T(n,x):"
-
- CHEBYCHEV_T(n,x):=SQRT(PI*(1-x^2))/((-2)^n*GAMMA(n+1/2))*DIF((1-x^2)^(n-1/2),x~
- ,n)
-
- "Chebychev polynomials of the 2nd kind, U(n,x):"
-
- CHEBYCHEV_U(n,x):=(-(n+1)*SQRT(PI)/((-2)^(n+1)*GAMMA(n+3/2)*SQRT(1-x^2))*DIF((~
- 1-x^2)^(n+1/2),x,n))
-
- "Legendre polynomials, P(n,x):"
-
- LEGENDRE_P(n,x):=DIF((1-x^2)^n,x,n)/((-2)^n*n!)
-
- "Associated Legendre 'polynomials':"
-
- ASSOCIATED_LEGENDRE_P(n,m,x):=(-1)^m*(1-x^2)^(m/2)*DIF(LEGENDRE_P(n,x),x,m)
-
- "Hermite polynomials, H(n,x):"
-
- HERMITE_H(n,x):=(-1)^n*#e^(x^2)*DIF(#e^(-x^2),x,n)
-
- HERMITE_HE(n,x):=HERMITE_H(n,x/SQRT(2))
-
- "Weber Parabolic Cylinder functions D(n,x):"
-
- WEBER_D(n,x):=#e^(-x^2/4)*HERMITE_HE(n,x)
-
- "Generalized Laguerre polys L(n,a,x). a=0 gives ordinary Laguerre polys:"
-
- GENERALIZED_LAGUERRE(n,a,x):=#e^x/(x^a*n!)*DIF(x^(a+n)/#e^x,x,n)
-
- "The generalized Jacobi polynomials, P(n,a,b,x):"
-
- JACOBI_P(n,a,b,x):=DIF((1-x)^a*(1-x)^b*(1-x^2)^n,x,n)/((-2)^n*n!*(1-x)^a*(1-x)~
- ^b)
-
- "The Gegenbauer ultra-spherical polynomials, C(n,a,x):"
-
- GEGENBAUER_C(n,a,x):=GAMMA(a+1/2)*GAMMA(n+2*a)/((-2)^n*n!*GAMMA(2*a)*GAMMA(a+n~
- +1/2)*(1-x^2)^(a-1/2))*DIF((1-x^2)^(n+a-1/2),x,n)
-
- "PART 9, RELATIVES OF THE ZETA FUNCTION:"
-
- "An m-term plus tail aprx to the Riemann zeta function for RE(s)>1."
-
- ZETA(s,m):=(m+1/2)^(1-s)/(s-1)+SUM(k^(-s),k,1,m)
-
- "An m+1 term plus tail aprx to the Hurwitz zeta fcn for a+k/=0 & RE(s)>1"
-
- HURWITZ_ZETA(s,a,m):=(m+a+1/2)^(1-s)/(s-1)+SUM((k_+a)^(-s),k_,0,m)
-
- "A degree-m approximation to the Lerch transcendent:"
-
- LERCH_PHI(z,s,a,m):=SUM(z^k_/(a+k_)^s,k_,0,m)
-
- "A degree-m approximation to the Jonquiere's polylogarithms LIn(z):"
-
- POLYLOG(n,z,m):=SUM(z^k_/k_^n,k_,1,m)
-
- "An integral definition of the dilogarithm POLYLOG(1,z), a special case of Spe~
- nce's integrals:"
-
- DILOG(x):=INT(LN(t_)/(1-t_),t_,1,x)
-
- "PART 10, PROBABILITY DENSITIES AND DISTRIBUTIONS:"
-
- "Poisson probability density:"
-
- POISSON_DENSITY(k,t):=#e^(-t)*t^k/k!
-
- "Poisson probability distribution:"
-
- POISSON_DISTRIBUTION(k,t):=SUM(POISSON_DENSITY(j_,t),j_,0,k)
-
- "The binomial probability density:"
-
- BINOMIAL_DENSITY(k,n,p):=COMB(n,k)*p^k*(1-p)^(n-k)
-
- "The binomial cumulative probability distribution:"
-
- BINOMIAL_DISTRIBUTION(k,n,p):=SUM(BINOMIAL_DENSITY(j_,n,p),j_,0,MIN(k,n))
-
- "Hypergeometric probability density:"
-
- HYPERGEOMETRIC_DENSITY(k,n,m,j):=COMB(m,k)*COMB(j-m,n-k)/COMB(j,n)
-
- "Hypergeometric cumulative probability distribution:"
-
- HYPERGEOMETRIC_DISTRIBUTION(k,n,m,j):=SUM(HYPERGEOMETRIC_DENSITY(i_,n,m,j),i_,~
- MAX(0,n-j+m),MIN(k,n,m))
-
- "The Student's-t cumulative probability distribution:"
-
- STUDENT(x,d):=1-INCOMPLETE_BETA(d/2,1/2,d/(d+x^2))
-
- "The F cumulative probability distribution:"
-
- F_DISTRIBUTION(x,d1,d2):=INCOMPLETE_BETA(d2/2,d1/2,d2/(d2+d1*x))
-
- "The Chi-Square cumulative probability distribution function:"
-
- CHI_SQ(x,d):=INCOMPLETE_GAMMA(d/2,x/2)