Computes \(\psi'(x)\), the trigamma function (the second derivative of
\(\log\Gamma(x)\), i.e. the derivative of the digamma function
fast_digamma_vec_cpp), elementwise over x, via an
asymptotic series expansion combined with the recurrence relation \(\psi'(x)
= \psi'(x+1) + 1/x^2\) (shifting small arguments up into the expansion's
accurate range before applying it) — faster than base R's
trigamma while matching it to within the approximation's own
precision. Used wherever this package's likelihood kernels need the variance of
a log-Gamma-based sufficient statistic or a Fisher-information second
derivative involving \(\log\Gamma\) (e.g. negative-binomial dispersion-parameter
curvature), and exported standalone for the same reason as
fast_digamma_vec_cpp and friends. Benchmarked at roughly
19.3x the speed of base R's vectorized trigamma() on this
package's benchmark suite; see the
"Utility
/ Math Kernel Performance" section of the benchmark report for the full
methodology and current measured multiple.
References
Trigamma
function for orientation. Analogous Python API:
SciPy
polygamma(1, x).
See also
fast_digamma_vec_cpp for the corresponding first-derivative
kernel this function's recurrence builds on.
