Y = gamma(X)
Evaluate the gamma function with a scalar and a vector.
Evaluate , which is equal to .
y = gamma(0.5)
y = 1.7725
Evaluate several values of the gamma function between
x = -3.5:3.5; y = gamma(x)
y = 1×8 0.2701 -0.9453 2.3633 -3.5449 1.7725 0.8862 1.3293 3.3234
Plot the gamma function and its inverse.
fplot to plot the gamma function and its inverse. The gamma function increases quickly for positive arguments and has simple poles at all negative integer arguments (as well as 0). The function does not have any zeros. Conversely, the inverse gamma function has zeros at all negative integer arguments (as well as 0).
fplot(@gamma) hold on fplot(@(x) 1./gamma(x)) legend('\Gamma(x)','1/\Gamma(x)') hold off grid on
X— Input array
Input array, specified as a scalar, vector, matrix, or multidimensional
array. The elements of
X must be real.
gamma function is
defined for real
x > 0 by the integral:
gamma function interpolates the
gamma(n+1) = factorial(n) = prod(1:n)
The domain of the
gamma function extends
to negative real numbers by analytic continuation, with simple poles
at the negative integers. This extension arises from repeated application
of the recursion relation
The computation of
gamma is based on algorithms outlined in .
 Cody, J., An Overview of Software Development for Special Functions, Lecture Notes in Mathematics, 506, Numerical Analysis Dundee, G. A. Watson (ed.), Springer Verlag, Berlin, 1976.
 Abramowitz, M. and I.A. Stegun, Handbook of Mathematical Functions, National Bureau of Standards, Applied Math. Series #55, Dover Publications, 1965, sec. 6.5.
This function fully supports tall arrays. For more information, see Tall Arrays.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
This function fully supports distributed arrays. For more information, see Run MATLAB Functions with Distributed Arrays (Parallel Computing Toolbox).