Computes \(\psi^{(n)}(x)\) where \(n\) is the derivative order. The derivative of \(\psi^{(n)}(x)\) is \(\psi^{(n+1)}(x)\).

psigamma(x, deriv = 0L)

# S4 method for class 'numeric'
psigamma(x, deriv = 0L)

# S4 method for class 'dualr'
psigamma(x, deriv = 0L)

Arguments

x

A numeric or dual value.

deriv

Integer derivative order (0 = digamma, 1 = trigamma, etc.).

Value

The polygamma function value.

Examples

psigamma(1, deriv = 0)  # digamma(1)
#> [1] -0.5772157
x <- dual_variable(2)
value(psigamma(x, deriv = 1))  # trigamma(2)
#> [1] 0.6449341