# (Also see the file Fitting Functions to Arrays, which
# has definitions for Legendre Polynomials.)
#
#
# function Gamma(x) # Returns integral 0->∞ { exp(-t) t^(x-1) dt .
# function IncompleteGamma(a,x) # Returns P(a,x)= 1/gamma(x) integral 0->x { exp(-t) t^(a-1) dt }
#
# function ErrorFunction(x) # Return erf(x).
# function ChiSqProbability(ChiSq,Nu) # Returns prob. of ChiSqaured fit.
#
# function Bessel(L,x) # Returns the spherical Bessel functions j_l(x), l=1,2,3,…
#
#
# This text file explains and gives examples of
# some of the routines in the file All Library Routines, which
# should be Opened before trying any of these examples.
#################
# Here are the xCOD's that are used.
xGAMMA
# xCOD xGAMMA(N,x,Answer:num), finds Answer[1…N]=Gamma(x[1…N])=integral 0->∞ of t^(x-1) e^(-t) dt, with Gamma(J)=(J-1)! for integer J ; an external program.
xINCOMPLETE_GAMMA
# xCOD xINCOMPLETE_GAMMA(N,a,X,Answer,Err:num), calculates Answer[1…N]=1/gamma(a) integral 0 to x[1…N] {exp(-t) t^(a-1)}. Err: 0=> success, -1=> hit iteration limit, -2=> x≤0.; an external program.
xBESSEL
# xCOD xBESSEL(L,N,X,Answer,err:num); computes a spherical Bessel function Answer[1…N]=j_L(X[1…N]). Err: 0=> success, -1=> L < 0.; an external program.
####
# Interface routines:
#
# The gamma function is Gamma(x) = integral 0->∞ { exp(-t) t^(x-1) dt},
# which is Gamma(n) = (n-1)! for integer n.
#
function Gamma(x) # Returns integral 0->∞ { exp(-t) t^(x-1) dt .
. var n,y
. # Input: x = number or array
. # Output: Gamma(x) = number or array = G(x)
. # = integral 0->∞ { exp(-t) t^(x-1) dt
. begin
. n = size(x)
. y = x # save space for answer
. xGAMMA(n,x,y)
. Gamma = y
. end
.
# This incomplete gamma function (sometimes called P(a,x)) is
# 1/gamma(x) integral 0->x { exp(-t) t^(a-1) dt }
# and has IncompleteGamma(a,0) = 0 and
# IncompleteGamma(1,∞)=1.
# The error function and the goodness of a Chi Squared
# fit may be calculated in terms of this.
#
function IncompleteGamma(a,x) # Returns P(a,x)= 1/gamma(x) integral 0->x { exp(-t) t^(a-1) dt }