next up previous contents
Next: GAMMALN Log Gamma Function Up: Mathematical Functions Previous: PSI Psi Function   Contents

Subsections

GAMMA Gamma Function

Usage

Computes the gamma function for real arguments. The gamma function takes only a single argument

  y = gamma(x)

where x is either a float or double array. The output vector y is the same size (and type) as x.

Function Internals

The gamma function is defined by the integral:

$\displaystyle \Gamma(x) = \int_{0}^{\infty} e^{-t} t^{x-1}   dt
$

The gamma function obeys the interesting relationship

$\displaystyle \Gamma(x) = (x-1)\Gamma(x-1),
$

and for integer arguments, is equivalent to the factorial function.

Example

Here is a plot of the gamma function over the range [-5,5].

--> x = linspace(-5,5);
--> y = gamma(x);
--> plot(x,y); xlabel('x'); ylabel('gamma(x)');
--> axis([-5,5,-5,5]);

which results in the following plot.

3667



Samit K. Basu 2005-03-16