# Gamma and Error Functions

Page Contents

## Gamma Function

The #~{gamma function} of any positive number &alpha. is defined as

&Gamma.( &alpha. ) _ = _ int{,0,&infty.,} ~x^{&alpha. - 1} e^{-~x} d~x

We have:

fract{d ( ~x^{&alpha.} e^{-~x} ), d~x} _ = _ &alpha. ~x^{&alpha. - 1} e^{-~x} _ - _ ~x^{&alpha.} e^{-~x}

Integrating and re-arranging we get:

int{,0,&infty.,} ~x^{&alpha.} e^{-~x} d~x _ + _ script{sqrb{~x^{&alpha.} e^{-~x}},,,&infty.,0} _ = _ &alpha. int{,0,&infty.,} ~x^{&alpha. - 1} e^{-~x} d~x

Now _ ~x^{&alpha.} e^{-~x} -> 0 , _ as ~x -> &infty. , _ so the above can be expressed as:

 &Gamma.( &alpha. + 1 ) _ = _ &alpha. &Gamma.( &alpha. )

## Values of the Gamma Function

Results:

1. &Gamma.( 1 ) _ = _ ~{∫}__0^^{&infty.}e^{-~x} d~x _ = _ [ -e^{-~x} ]_0^{&infty.} _ = _ 1
2. ~n &in. &naturals.^+ , ~n > 1 , _ &Gamma.( ~n ) _ = _ ( ~n - 1 )&Gamma.( ~n - 1 ) , _ &Gamma. ( 1 ) _ = _ 1 , _ so _ &Gamma.( ~n ) _ = _ ( ~n - 1 )#!
3. &Gamma.( 1/2 ) _ = _ &sqrt.\${&pi.}

#{Proof} _ of 3)

&Gamma.( 1/2 ) _ = _ ~{&integ.}__0^^{&infty.} ~x^{- 1/2 } e^{-~x} d~x _ = _ 2 ~{&integ.}__0^^{&infty.} e^{-~u^2} d~u _ _ _ _ ( using the substitution _ ~u = ~x^{ 1/2 } )

( ~{&integ.}__0^^{&infty.} e^{-~u^2} d~u ) ^2 _ = _ ~{&integ.}__0^^{&infty.} ~{&integ.}__0^^{&infty.} e^{- (~u^2 + ~v^2)} d~u d~v _ = _ ~{&integ.}__0^^{&pi./2} ~{&integ.}__0^^{&infty.} ~r e^{- ~r^2} d~r d&theta.

by changing to polar coordinates for the positive quadrant.

_ _ _ _ _ = _ ~{&integ.}__0^^{&pi./2} [ - 1/2 e^{- ~r^2} ]__0^^{&infty.} d&theta. _ = _ ~{&integ.}__0^^{&pi./2} 1/2 _ d&theta. _ = _ &pi. ./ 4

So _ _ _ _ _ &Gamma.( 1/2 ) _ = _ 2 # &sqrt.\${&pi. / 4} _ = _ &sqrt.\${&pi.}.

## Incomplete Gamma Function

Define the #~{incomplete gamma function} , _ &gamma.( &alpha. , ~x )

&gamma.( &alpha. , ~x ) _ _ _ _ #:= _ _ _ _ int{,0,~x,} ~t^{&alpha. - 1} e^{-~t} d~t

Note: _ &gamma.( &alpha. , ~x ) _ -> _ &Gamma.( &alpha. ) _ as _ ~x -> &infty.

We have:

F( ~y ; &alpha. , &beta. ) _ = _ &gamma.( &alpha. , &beta.~y ) ./ &Gamma.( &alpha. )

_ _ _ _ _ _ _ _ _ _ _ = _ F( &beta.~y ; &alpha. , 1 )

## Reduction Formula

Now , _ if _ &alpha. _ > _ 1

F( ~y ; &alpha. , 1 ) _ = _ int{,0,~y,} fract{~x^{&alpha. - 1} e^{-~x},&Gamma.(&alpha.)} d~x _ = _ fract{~y^{&alpha. - 1} # -e^{-~y},&Gamma.(&alpha.)} _ - _ int{,0,~y,} fract{~x^{&alpha. - 2} # -e^{-~x},&Gamma.(&alpha. - 1)} d~x

Integrating by parts, using _ ~u _ =_ ~x^{&alpha. - 1} ./ &Gamma.( &alpha. ) _ and _ ~v _ = _ - e^{-~x}

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ = _ F( ~y ; (&alpha. - 1) , 1 ) _ - _ fract{~y^{&alpha. - 1} e^{-~y},&Gamma.(&alpha.)}

so , _ if _ &alpha. _ = _ ~n + &theta. , _ _ where _ ~n _ is a positive integer, then

F( ~y ; &alpha. , 1 ) _ = _ F( ~y ; &theta. , 1 ) _ - _ sum{fract{~y^{&alpha. - ~i} e^{-~y},&Gamma.(&alpha. - ~i + 1)},~i = 1,~n}

## Integer Alpha

In particular , _ if _ &alpha. _ = _ ~n + 1 , _ _ ~n _ positive integer, then

F( ~y ; &alpha. , 1 ) _ = _ int{,0,~y,} e^{-~x} d~x _ - _ sum{fract{~y^{&alpha. - ~i} e^{-~y},&Gamma.(&alpha. - ~i + 1)},~i = 1,~n}

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ = _ 1 _ - _ e^{-~y} _ - _ sum{fract{~y^{&alpha. - ~i} e^{-~y},( &alpha. - ~i )#!},~i = 1,&alpha. - 1}

putting _ ~j _ = _ &alpha. - ~i

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ = _ 1 _ - _ e^{-~y} _ - _ sum{fract{~y ^~j e^{-~y}, _ ~j#!}, ~j = 1,&alpha. - 1}

## Half-Integer Alpha

In particular , _ if _ &alpha. _ = _ ~n + &hlf. , _ _ ~n _ positive integer, then

F( ~y ; &alpha. , 1 ) _ = _ F( ~y ; &hlf. , 1 ) _ - _ sum{fract{~y^{&alpha. - ~i} e^{-~y},&Gamma.(&alpha. - ~i + 1)},~i = 1,~n}

Now

F( ~y ; &hlf. , 1 ) _ = _ fract{1,&sqrt.\${&pi.}} int{,0,~y,} ~x^{-&hlf.}e^{-~x} d~x

Since _ &Gamma.( &hlf. ) _ = _ &sqrt.\${&pi.} . _ Using the substitution _ ~u _ = _ ~x^{-&hlf.} , _ ~x _ = _ ~u^2 , _ d~x _ = _ 2~u d~u

fract{1,&sqrt.\${&pi.}} int{,0,~y,} ~x^{-&hlf.}e^{-~x} d~x _ = _ fract{2,&sqrt.\${&pi.}} int{,0,&sqrt.\$~y,} e^{-~u^2} d~u

We write

F( ~y ; &hlf. , 1 ) _ = _ erf( &sqrt.\$~y )

where _ erf( ~x ) is the error function

erf( ~x ) _ _ _ _ #:= _ _ _ _ fract{2,&sqrt.\${&pi.}} int{,0,~x,} e^{-~u^2} d~u

and more generally, _ where _ &alpha. = ~n + &hlf.

F( ~y ; &alpha. , 1 ) _ = _ erf( &sqrt.\$~y ) _ - _ sum{fract{~y^{&alpha. - ~i} e^{-~y},&Gamma.(&alpha. - ~i + 1)},~i = 1,~n}

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ = _ erf( &sqrt.\$~y ) _ - _ e^{-~y} sum{fract{~y ^{~j - &hlf.} ,&Gamma.( ~j + &hlf. )},~j = 1,~n}

### Error Function

The function

erf( ~x ) _ _ _ _ #:= _ _ _ _ fract{2,&sqrt.\${&pi.}} int{,0,~x,} e^{-~u^2} d~u

is called the #~{error function} of ~x.

The Maclaurin expansion of _ e^{-~u^2} _ is _

e^{-~u^2} _ = _ sum{ fract{({-1})^~n, ~n#!} ~x^{2~n}, ~n = 0, &infty.}

Integrating term by term

erf( ~x ) _ = _ fract{2,&sqrt.\${&pi.}} sum{ fract{({-1})^~n, ~n#!} fract{~x^{2~n + 1},2~n + 1}, ~n = 0, &infty.}

However this is very slow to converge for large ~x, _ [ the _ ~x^{2~n + 1} _ term dominating ]. In such cases consider the complementary error function _ erfc( ~x ) _ = _ 1 - erf( ~x ) , _ which has an asymptotic expansion ( for large ~x , _ say ~x > 4 )

erfc( ~x ) _ = _ fract{e^{-~x^2},~x &sqrt.\${&pi.}} sqrb{ 1 + sum{ ({-1})^~n fract{(2~n)#!, ~n#! (2~x)^{2~n}} , ~n = 1, &infty.}}

Reference: Wikipedia