Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

psi - Psi (polygamma) function

Syntax

Y = psi(X)
Y = psi(k,X)
Y = psi(k0:k1,X)

Description

Y = psi(X) evaluates the function for each element of array X. X must be real and nonnegative. The function, also known as the digamma function, is the logarithmic derivative of the gamma function

Y = psi(k,X) evaluates the kth derivative of at the elements of X. psi(0,X) is the digamma function, psi(1,X) is the trigamma function, psi(2,X) is the tetragamma function, etc.

Y = psi(k0:k1,X) evaluates derivatives of order k0 through k1 at X. Y(k,j) is the (k-1+k0)th derivative of , evaluated at X(j).

Examples

Example 1

Use the psi function to calculate Euler's constant, .

format long
-psi(1)
ans =
   0.57721566490153

-psi(0,1)
ans =
   0.57721566490153

Example 2

The trigamma function of 2, psi(1,2), is the same as .

format long
psi(1,2)
ans =
   0.64493406684823

pi^2/6 - 1
ans =
   0.64493406684823

Example 3

This code produces the first page of Table 6.1 in Abramowitz and Stegun [1].

x = (1:.005:1.250)';  
[x gamma(x) gammaln(x) psi(0:1,x)' x-1]

Example 4

This code produces a portion of Table 6.2 in [1].

psi(2:3,1:.01:2)'

See Also

gamma, gammainc, gammaln

References

[1] Abramowitz, M. and I. A. Stegun, Handbook of Mathematical Functions, Dover Publications, 1965, Sections 6.3 and 6.4.

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS