GammaFunctions           package:fOptions           R Documentation

_G_a_m_m_a _a_n_d _R_e_l_a_t_e_d _F_u_n_c_t_i_o_n_s

_D_e_s_c_r_i_p_t_i_o_n:

     A collection and description of special mathematical functions.
     The functions include the error function,  the Psi function, the
     incomplete Gamma function, the  Gamma function for complex
     argument, and the  Pochhammer symbol. The Gamma function the
     logarithm   of the Gamma function, their first four derivatives, 
     and the Beta function and the logarithm of the Beta  function are
     part of R's base package. For example, these functions are
     required to valuate Asian Options based on the theory of
     exponential Brownian motion. 


     The functions are:

       'erf'          the Error function,
       'gamma*'       the Gamma function,
       'lgamma*'      the logarithm of the Gamma function,
       'digamma*'     the first derivative of the Log Gamma function,
       'trigamma*'    the second derivative of the Log Gamma function,
       'tetragamma*'  the third derivative of the Log Gamma function,
       'pentagamma*'  the fourth derivative of the Log Gammafunction,
       'beta*'        the Beta function,
       'lbeta*'       the logarithm of the Beta function,
       'Psi'          Psi(x) the Psi or Digamma function,
       'igamma'       P(a,x) the incomplete Gamma function,
       'cgamma'       Gamma function for complex argument,
       'Pochhammer'   the Pochhammer symbol.

     The functions marked by an asterisk are part of R's base package.

_U_s_a_g_e:

     erf(x)
     Psi(x)
     igamma(x, a)
     cgamma(x, log = FALSE)
     Pochhammer(x, n)

_A_r_g_u_m_e_n_t_s:

       x: [erf] - 
           a real numeric value or vector. 
           [Psi][*gamma][Pochhammer] - 
           a complex numeric value or vector. 

       a: a complex numeric value or vector. 

       n: an integer value 'n >= 0'. A notation used in the theory  of
          special functions for the rising factorial, also known as the
           rising factorial power, Graham et al. 1994.  

     log: a logical, if 'TRUE' the logarithm of the complex Gamma 
          function is calculated otherwise if 'FALSE', the complex 
          Gamma function itself will be calculated. 

_V_a_l_u_e:

     The functions return the values of the selected special
     mathematical function.

_A_u_t_h_o_r(_s):

     Diethelm Wuertz for this R-Port.

_R_e_f_e_r_e_n_c_e_s:

     Abramowitz M., Stegun I.A. (1972);  _Handbook of Mathematical
     Functions with Formulas, Graphs,  and Mathematical Tables_,  9th
     printing, New York, Dover Publishing. 

     Artin, E. (1964); _The Gamma Function_, New York, Holt, Rinehart,
     and Winston Publishing. 

     Weisstein E.W. (2004); _MathWorld-A Wolfram Web Resource_,
     http://mathworld.wolfram.com

_E_x_a_m_p_l_e_s:

     ## Calculate Error, Gamma and Related Functions

     ## gamma -
     ## Abramowitz-Stegun: Figure 6.1
        x = seq(-4.01, 4.01, by = 0.011)
        plot(x, gamma(x), ylim = c(-5,5), type = "l", main = "Gamma Function")
        lines(x = c(-4, 4), y = c(0, 0))
          
     ## Psi -
     ## Abramowitz-Stegun: Figure 6.1
        x = seq(-4.01, 4.01, by = 0.011)
        plot(x, Psi(x), ylim = c(-5, 5), type = "l", main = "Psi Function")
        lines(x = c(-4, 4), y = c(0, 0))
        # Note: Is digamma defined for positive values only ?

     ## igamma -
     ## Abramowitz-Stegun: Figure 6.3. 
        gammaStar = function(x, a) { igamma(x,a)/x^a }
        # ... create Figure as an exercise.
       
     ## igamma -
     ## Abramowitz-Stegun: Formula 6.5.12
     ## Relation to Confluent Hypergeometric Functions
        a = sqrt(2)
        x = pi
        Re ( (x^a/a) * kummerM(-x, a, 1+a) )
        Re ( (x^a*exp(-x)/a) * kummerM(x, 1, 1+a) )
        pgamma(x,a) * gamma(a)
        igamma(x, a)
      
     ## cgamma -
     ## Abramowitz-Stegun: Tables 6.7
        x = 1
        y = seq(0, 5, by = 0.1); x = rep(x, length = length(y))
        z = complex(real = x, imag = y)
        c = cgamma(z, log = TRUE)
        cbind(y, Re(c), Im(c))
         
     ## cgamma -
     ## Abramowitz-Stegun: Examples 4-8:
        options(digits = 10)
        gamma(6.38); lgamma(56.38)                            # 1/2
        Psi(6.38); Psi(56.38)                                 # 3/4
        cgamma(complex(real = 1, imag = -1), log = TRUE )     # 5
        cgamma(complex(real = 1/2, imag = 1/2), log = TRUE )  # 6
        cgamma(complex(real = 3, imag = 7), log = TRUE )      # 7/8 

