Skip to Main Content Skip to Search
Product Documentation

psi - Digamma function

Syntax

psi(x)
psi(k,x)
psi(A)
psi(k,A)

Description

psi(x) computes the digamma function of x.

psi(k,x) computes the polygamma function of x, which is the kth derivative of the digamma function at x.

psi(A) computes the digamma function of each element of A.

psi(k,A) computes the polygamma function of A, which is the kth derivative of the digamma function at A.

Tips

Input Arguments

x

Nonnegative symbolic number, variable, or expression.

k

Nonnegative integer.

A

Vector or matrix of nonnegative symbolic numbers, variables, or expressions.

Definitions

digamma Function

The digamma function is the first derivative of the logarithm of the gamma function:

polygamma Function

The polygamma function of the order k is the (k + 1)th derivative of the logarithm of the gamma function:

Examples

Compute the digamma and polygamma functions for these numbers. Because these numbers are not symbolic objects, you get the floating-point results:

[psi(1/2) psi(2, 1/2) psi(1.34) psi(1, sin(pi/3))]

The results are:

ans =
   -1.9635  -16.8288   -0.1248    2.0372
 

Compute the digamma and polygamma functions for the numbers converted to symbolic objects:

[psi(sym(1/2)), psi(1, sym(1/2)), psi(sym(1/4))]
ans =
[ - eulergamma - 2*log(2), pi^2/2, - eulergamma - pi/2 - 3*log(2)]

For some symbolic (exact) numbers, psi returns unresolved symbolic calls:

psi(sym(sqrt(2)))
ans =
psi(2^(1/2))
 

Compute the derivatives of these expressions containing the digamma and polygamma functions:

syms x
diff(psi(1, x^3 + 1), x)
diff(psi(sin(x)), x)
ans =
3*x^2*psi(2, x^3 + 1)
 
ans =
cos(x)*psi(1, sin(x))
 

Expand the expressions containing the digamma functions:

syms x
expand(psi(2*x + 3))
expand(psi(x + 2)*psi(x))
ans =
psi(x + 1/2)/2 + log(2) + psi(x)/2 +...
1/(2*x + 1) + 1/(2*x + 2) + 1/(2*x)
 
ans =
psi(x)/x + psi(x)^2 + psi(x)/(x + 1)
 

Compute the limits for expressions containing the digamma and polygamma functions:

syms x
limit(x*psi(x), x, 0)
limit(psi(3, x), x, inf)
ans =
-1
 
ans =
0
 

Compute the digamma function for elements of these matrix M and vector V:

M =sym([0 inf; 1/3 1/2]);
V = sym([1; inf]);
psi(M)
psi(V)
ans =
[                                          Inf,                     Inf]
[ - eulergamma - (3*log(3))/2 - (pi*3^(1/2))/6, - eulergamma - 2*log(2)]

ans =
 -eulergamma
         Inf

See Also

beta | factorial | gamma | mfun | mfunlist | nchoosek

How To

  


Free Symbolic Math Interactive Kit

See how symbolic computations can help you find analytical solutions to math and engineering problems.

Get free kit

Trials Available

Try the latest version of symbolic math products.

Get trial software
 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS