Documentation

gamma

Gamma function

Syntax

Y = gamma(X)

Description

example

Y = gamma(X)returns thegammafunction evaluated at the elements ofX.

Examples

collapse all

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[-3.5 3.5].

x = -3.5:3.5; y = gamma(x)
y =0.2701 -0.9453 2.3633 -3.5449 1.7725 0.8862 1.3293 3.3234

Plot the gamma function and its inverse.

Usefplotto 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) holdonfplot(@(x) 1./gamma(x)) legend('\Gamma(x)','1/\Gamma(x)') holdoffgridon

Input Arguments

collapse all

Input array, specified as a scalar, vector, matrix, or multidimensional array. The elements ofXmust be real.

Data Types:single|double

More About

collapse all

Gamma Function

Thegammafunction is defined for realx > 0by the integral:

Γ ( x ) = 0 e t t x 1 d t

Thegammafunction interpolates thefactorialfunction. For integern:

gamma(n+1) = factorial(n) = prod(1:n)

The domain of thegamma函数前tends to negative real numbers by analytic continuation, with simple poles at the negative integers. This extension arises from repeated application of the recursion relation

Γ ( n 1 ) = Γ ( n ) n 1 .

Algorithms

The computation ofgammais based on algorithms outlined in[1]. Several different minimax rational approximations are used depending upon the value ofA.

参考

[1] 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.

[2] Abramowitz, M. and I.A. Stegun,Handbook of Mathematical Functions, National Bureau of Standards, Applied Math. Series #55, Dover Publications, 1965, sec. 6.5.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced before R2006a

Was this topic helpful?