I have started to work on the documentation for all the functions we have
implemented and the extensions we have done.
I have recognized that a lot of documentation which belongs in principle to a
function is spread over different chapters.
Thus I have tried to find a more systematically approach. This is possibly an
organization of a new chapter:
Chapter: Mathematical functions
Section: Factorials and related functions
- factlim
- factorial_expand
- factorial (z)
- genfact (x,y,z)
- factorial_double (z)
- makefact (expr)
Section: Gamma function and related functions
- gammalim
- gamma_expand
- gamma (z)
- gamma_incomplete (a,z)
- gamma_incomplete_generalized (a,z)
- gamma_incomplete_regularized (a,z)
- gamma_incomplete_generalized_regularized (a,z)
- log_gamma (z)
- psi [n](x)
- makegamma
Section: Beta function and related functions
- beta (a,b)
- beta_incomplete (a,b,z)
Section: Error functions
- erf_representation
- erf (z)
- erfc (z)
- erfi (z)
- erf_generalized (z1,z2)
Section: Exponential Integrals
- expint_expand
- expint_representation
- expintegral_e (v,z)
- expintegral_e1 (z)
- expintegral_ei (z)
- expintegral_li (z)
- expintegral_si (z)
- expintegral_ci (z)
- expintegral_shi (z)
- expintegral_chi (z)
Furthermore, the Airy, Bessel, ... and other functions which are documented in
the chapter Special functions could be added too.
This is a print of a possible first section about factorials and related
functions:
--------------------------------------------------------------------------------
16.1 Factorials and related functions
- Option variable: factlim
Default value: 100,000
The greatest integer for which factorial(n) or factorial_double(n) will be
evaluated numerically. If factlim is set to -1 Maxima does not test the argument
and try to calculate the factorial for every integer.
With most compilers values about 100,000 will work. But much greater integers
might be possible. Warning: When an overflows occurs during the calculation the
system may hang or other unpredictable results may occur. For most compilers the
greatest result which can be displayed is much smaller than the result which can
be calculated numerically.
- Option variable: factorial_expand
Default value: false
Controls the expansion of factorials like factorial(n+z) where n is an integer.
See factorial and factorial_double.
- Function: factorial (z)
The factorial function. Maxima treats factorial(n) the same as n!. See !.
For any complex number z, except for negative integers, factorial(z) is defined
by factorial(z) = gamma(z+1). For a positive integer this simplifies to
factorial(n) = product(k,k,0,n).
For n an integer the factorial is calculated by a recursive algorithm modified
by Fatemann. For all other numbers including real and complex numbers in double
float and bigfloat precision the numerical evaluation is done by the implemented
gamma function gamma(z).
For a half integral value factorial(n/2) simplifies to a rational factor times
sqrt(%pi).
When the variable factorial_expand is true the following expansions occur for
positive integer n
factorial(z+n) = pochhammer(z,n) * factorial(n)
(-1)^m * factorial(n)
factorial(z-n) = ---------------------
pochhammer(-n,m)
Expressions containing factorials which differ only by an integer can simplify
after expanding the factorials. This is equivalent to the functionality of the
function minfactorial. But the expansion done by the simplifier is more
powerful, because the simplification is also done for nested expressions.
The factorial of an integer is simplified unless the operand is greater than
factlim. The variable factlim has the default value 100,000. This value for the
greatest calculateable value should work with most compilers. Even greater
values should be possible for some compilers. See factlim.
Maxima knows the derivative of the factorial and the fact that the factorial has
mirror symmetry. Thus conjugate(factorial(x+%i*y)) simplifies to
factorial(x-%i*y).
The functions minfactorial and factcomb control the simplification of
expressions containing factorials.
makegamma transforms factorials into the Gamma functions. See also makefact.
The factorial of an integer, half-integer, or floating point argument is
simplified unles the operator is greater than factlim.
(%i1) factlim : 10;
(%o1) 10
(%i2) [0!,(7/2)!,4.77!,8!,20!];
105 sqrt(%pi)
(%o2) [1, -------------, 81.44668037931206, 40320, 20!]
16
Furthermore, Maxima can simplify the factorial of a complex floating point, or a
bigfloat or complex bigfloat argument.
(%i26) [(6.5+1.5*%i),1.3b0!,(1.7b0+2.5b0*%i)!];
(%o26) [1.5 %i + 6.5, 1.1667119051981603374b0,
3.192332950943190195b-1 %i - 3.3818934082383175529b-1]
The factorial of a known constant, or a general expression is not simplified.
Even so it may be possible simplify the factorial after evaluating the operand.
(%i3) [%pi!,%e!,(cos(1)+sin(1))!];
(%o3) [%pi!, %e!, (sin(1) + cos(1))!]
(%i4) ev(%,numer,%enumer);
(%o4) [7.188082728976037, 4.260820476357002, 1.227580202486819]
Factorials are simplified, not evaluated. Thus x! may be replaced even in quoted
expressions.
(%i8) factlim : 20;
(%o8) 20
(%i9) '([0!,(7/2)!,4.77!,8!,20!]);
105 sqrt(%pi)
(%o9) [1, -------------, 81.44668037931206, 40320, 2432902008176640000]
16
Setting factorial_expand:true enables simplification of factorials like (z+n)!
or (z-n)! where n is an integer.
(%i12) factorial_expand:true;
(%o12) true
(%i13) [(n+1)!,(n-1)!,(n+1)!/(n-1)!,((n+2)!/(n+1)!)!];
n!
(%o13) [(n + 1) n!, --, n (n + 1), (n + 1) (n + 2) n!]
n
.Category: Gamma and factorial functions
- Function: genfact (x, y, z)
Returns the generalized factorial, defined as x (x-z) (x - 2 z) ... (x - (y - 1)
z). The function is defined for x an integer with z <= x and y <= x/z. When the
integer arguments are not within this range a Maxima error is thrown. For any
other numbers Maxima returns a noun form. For integral x, genfact(x, x, 1) = x!
and genfact(x, x/2, 2) = x!!.
For a generalization of the double factorial to real and complex numbers see the
function factorial_double(z).
.Category: Gamma and factorial functions
- Function: factorial_double (z)
For any complex number, except for negative even integer, the double factorial
is definied by
factorial_double(z) = (2/%pi)^(1/4*(1-cos(%pi*n)))*2^(n/2)*gamma(n/2+1)
For an integer argument the double factorial simplifies to the general factorial
genfact(n,n/2,2).
Maxima can numerically evaluate the double factorial for integers, real and
complex numbers with double float and bigfloat precision. For odd negative
integers, double float or bigfloat precision the numerically routines of the
implemented gamma function are used. For negative even integer or a float or
bigfloat representation of a negative even integer a Maxima error is thrown.
When factorial_expand is true the following expansions occur
factorial_double(n+2*k) = 2^m*pochhammer(n/2+1,m)*factorial_double(n)
(-1)^m*2^(-m)*factorial_double(n)
factorial_double(n-2*m) = --------------------------------
pochhammer(-n/2,m)
Maxima knows the derivative of double factorial and the fact that double
factorial has mirror symmetry.
makegamma transforms double factorials into gamma functions.
Some results for the double factorial.
(%i1) [factorial_double(10),factorial_double(1.0+%i),factorial_double(inf)];
(%o1) [3840, 0.10047442123544 %i + 0.25065077954575, inf]
Double factorial is defined for odd integer arguments. But not for even integer
arguments.
(%i1) factorial_double(-5);
(%o1) 0.33333333333333
(%i2) factorial_double(-6);
factorial_double(-6) is undefined.
-- an error. To debug this try debugmode(true);
Expansion of double factorial.
(%i1) factorial_expand:true;
(%o1) true
(%i2) factorial_double(2*n+2);
(%o2) 2 (n + 1) factorial_double(2 n)
(%i3) factorial_double(2*n-1);
(2 n)!
(%o3) ---------------------
factorial_double(2 n)
Double factorial has mirror symmetry.
(%i1) conjugate(factorial_double(x+%i*y));
(%o1) factorial_double(x - %i y)
The derivative of double factorial.
(%i1) diff(factorial_double(z),z);
2
%pi log(---) sin(%pi z)
%pi z
double_factorial(z) (----------------------- + psi (- + 1) + log(2))
2 0 2
(%o1) --------------------------------------------------------------------
2
The representation of double factorial as a gamma function.
(%i2) makegamma(factorial_double(z));
1 - cos(%pi z)
-------------- + z/2
z 4
gamma(- + 1) 2
2
(%o2) ----------------------------------
1 - cos(%pi z)
--------------
4
%pi
.Category: Gamma and factorial functions
- Function: makefact (expr)
Transforms instances of double factorials, binomial, gamma, and beta functions
in expr into factorials.
--------------------------------------------------------------------------------
What do you think? Should we collect the functions and the related stuff in a
chapter "Mathematical functions"?
Dieter Kaiser