psi
Digamma/polygamma function
MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
psi(x
) psi(x
,n
)
psi(x)
represents the digamma function,
i.e., the logarithmic derivative of
the gamma
function.
psi(x, n)
represents the nth
polygamma function, i.e., the nth
derivative .
psi(x, 0)
is equivalent to psi(x)
.
The digamma/polygamma function is defined for all complex arguments x
apart
from the singular points 0,  1,  2, ….
If x
is a floatingpoint value, then a floating
point value is returned.
Simplifications are implemented for rational numbers x.
In particular, if x = numer(x)/k
with
denominators k = 1, 2, 3, 4 or 6,
explicit results expressed in terms of EULER, PI,
and ln
are returned.
In general, for any rational x
with x (n
+ 1) ≤ 6 Pref::autoExpansionLimit() = 6000
(see Pref::autoExpansionLimit
),
the functional equation
,
is used to obtain a result with an argument x
from
the interval .
Use expand(psi(x, n))
to obtain such a shift of
the argument for larger values of x
.
Some explicit formulas are implemented including
,
,
,
.
The special values ψ(∞) = ∞ and for n > 0 are implemented.
For all other arguments, a symbolic function call of psi
is
returned.
The float attribute of the digamma function psi(x)
is
a kernel function, i.e., floatingpoint evaluation is fast. The float
attribute of the polygamma function psi(x, n)
with n
> 0
is a library function. Note that psi(float(x))
and psi(float(x),
n)
rather than float(psi(x))
and float(psi(x,
n))
should be used for float evaluation because, for rational
values of x
, the computation of the symbolic result psi(x)
, psi(x,
n)
may be costly. Further, the float evaluation of the symbolic
result may be numerically unstable.
The expand
attribute
uses the functional equation
,
the nth derivative of the reflection formula
,
and the Gauß multiplication formula for when k is
a positive integer, to rewrite psi(x, n)
. For numerical x
,
the functional equation is used to shift the argument to the range 0
< x < 1
. Cf. examples Example 3 and Example 4.
When called with a floatingpoint value x
,
the function is sensitive to the environment variable DIGITS
which
determines the numerical working precision.
We demonstrate some calls with exact and symbolic input data:
psi(3/2), psi(4, 1), psi(3/2, 2)
psi(x + sqrt(2), 4), psi(infinity, 5)
Floating point values are computed for floatingpoint arguments:
psi(5.2), psi(1.0, 3), psi(2.0 + 3.0*I, 10)
psi
is singular for nonpositive integers:
psi(2)
Error: Singularity. [psi]
For positive integers and rational numbers x with
denominators 2, 3, 4 and 6,
respectively, the result is expressed in terms of EULER, PI, ln
, and zeta
if x (n
+ 1) ≤ 6 Pref::autoExpansionLimit() = 6000
:
Pref::autoExpansionLimit()
psi(5/2), psi(3/2, 1), psi(13/3, 2), psi(11/6, 4)
For larger arguments, use expand
to obtain such expressions:
psi(1001, 5)
expand(%)
6 8 PI  63  133533.../1093808...
The functions diff
, expand
, float
, limit
, and series
handle expressions
involving psi
:
diff(psi(x^2 + 1, 3), x), float(ln(3 + psi(sqrt(PI))))
expand(psi(2*x + 3, 2))
limit(x*psi(x), x = 0), limit(psi(x, 3), x = infinity)
series(psi(x), x = 0), series(psi(x, 3), x = infinity, 3)
 

A nonnegative integer 
Arithmetical expression.
x