@c -----------------------------------------------------------------------------
@c File     : stirling.de.texi
@c License  : GNU General Public License (GPL)
@c Language : German
@c Original : stirling.texi revision 1.4
@c Date     : 08.11.2010
@c Revision : 15.03.2011
@c 
@c This file is part of Maxima -- GPL CAS based on DOE-MACSYMA
@c -----------------------------------------------------------------------------

@menu
* Functions and Variables for stirling::
@end menu

@c -----------------------------------------------------------------------------
@node Functions and Variables for stirling,  , stirling, stirling
@section Functions and Variables for stirling
@c -----------------------------------------------------------------------------

@c -----------------------------------------------------------------------------
@deffn  {Function} stirling (@var{z}, @var{n})
@deffnx {Function} stirling (@var{z}, @var{n}, @var{pred})

Replace @code{gamma(x)} with the @math{O(1/x^(2n-1))} Stirling formula.  When 
@var{n} isn't a nonnegative integer, signal an error.  With the optional third 
argument @code{pred}, the Stirling formula is applied only when @code{pred} is 
true.

To use this function write first @code{load(stirling)}.

Reference: Abramowitz & Stegun, "Handbook of mathematical functions", 6.1.40.

Examples:

@example
(%i1) load (stirling)$

(%i2) stirling(gamma(%alpha+x)/gamma(x),1);
       1/2 - x             x + %alpha - 1/2
(%o2) x        (x + %alpha)
                                   1           1
                            --------------- - ---- - %alpha
                            12 (x + %alpha)   12 x
                          %e
(%i3) taylor(%,x,inf,1);
                    %alpha       2    %alpha
          %alpha   x       %alpha  - x       %alpha
(%o3)/T/ x       + -------------------------------- + . . .
                                 2 x
(%i4) map('factor,%);
                                       %alpha - 1
         %alpha   (%alpha - 1) %alpha x
(%o4)   x       + -------------------------------
                                  2
@end example

The function @code{stirling} knows the difference between the variable 'gamma' 
and the function gamma:

@example
(%i5) stirling(gamma + gamma(x),0);
                                    x - 1/2   - x
(%o5)    gamma + sqrt(2) sqrt(%pi) x        %e
(%i6) stirling(gamma(y) + gamma(x),0);
                         y - 1/2   - y
(%o6) sqrt(2) sqrt(%pi) y        %e
                                              x - 1/2   - x
                         + sqrt(2) sqrt(%pi) x        %e
@end example

To apply the Stirling formula only to terms that involve the variable @code{k},
use an optional third argument; for example

@example
(%i7) makegamma(pochhammer(a,k)/pochhammer(b,k));
                      gamma(b) gamma(k + a)
(%o7)                 ---------------------
                      gamma(a) gamma(k + b)

(%i8) stirling(%,1, lambda([s], not(freeof(k,s))));
        b - a                 k + a - 1/2        - k - b + 1/2
      %e      gamma(b) (k + a)            (k + b)
(%o8) --------------------------------------------------------
                              gamma(a)
@end example

The terms @code{gamma(a)} and @code{gamma(b)} are free of @code{k}, so the 
Stirling formula was not applied to these two terms.
@end deffn

@c --- End of file stirling.de.texi

