Opened 10 years ago

Closed 8 years ago

#7029 closed Feature Requests (fixed)

Add trigamma function

Reported by: agribov_no_s_p_a_m@… Owned by: John Maddock
Milestone: To Be Determined Component: math
Version: Boost 1.49.0 Severity: Not Applicable
Keywords: trigamma, digamma, gamma Cc:

Description

Boost has implementation of digamma function. It would be nice to have implementation of trigamma function (second derivative of ln(Gamma())). http://en.wikipedia.org/wiki/Trigamma_function

Change History (10)

comment:1 by anonymous, 9 years ago

Yes, trigamma would be appreciated! Please.

comment:2 by anonymous, 9 years ago

FYI There's a Google summer of code student working on polygamma so hopefully this will come to pass...

comment:3 by anonymous, 9 years ago

Do you mean this? http://code.google.com/p/pmtk3/source/browse/trunk/misc/fastfit/trigamma.m?spec=svn1197&r=1197

Looks interesting. Thank you. But I trust boost MUCH more than google, taking into account eg google translator which is an bottomless source of inspiration for demotivators. When I use something from boost I can assume that it is perfect (almost). When I use something from google it is like mine field.

comment:4 by John Maddock, 9 years ago

No, I meant: http://www.google-melange.com/gsoc/project/google/gsoc2013/nikhar/52001 with code at: https://github.com/BoostGSoC/boost.math

But please note it's very early days yet, nothing there ready for Boost primetime yet...

comment:5 by anonymous, 9 years ago

Looks like a great beginning! Good luck. And I implemented trigamma using http://upload.wikimedia.org/math/a/8/0/a80acd50152662cd7bcd41659fe489cc.png http://upload.wikimedia.org/math/6/6/9/66906e84ea81f06b3dbad5a8bf24558c.png LoL. Very slow working but quick to implement. :-) Proper implementation would use Remez and asymptotic expansions I suppose. Have no time for it.

comment:6 by anonymous, 9 years ago

Is there any progress on that? Really looking forward to use the trigamma function!

comment:7 by John Maddock, 8 years ago

Well it only took a year!

There's now a complete polygamma implementation in the bernoulli-tgamma branch of Boost math, available as a zip here https://github.com/boostorg/math/archive/bernoulli-tgamma.zip.

There are still docs to write, so it won't get officially released just yet, but in the mean time if you have any feedback or concrete use cases they would be much appreciated.

comment:8 by anonymous, 8 years ago

Hi,

thanks for the fine work! I stumbled on this by chance today! I am currently struggling with extracting the minimal subset required to test it with my software, but so far no real success as the polygamma function relies on quite a large new subset of things.

But may I ask why the multiplication theorem is not used in the formulas? It seems to be a nice way to reduce the problem for large arguments instead of heaving to rely on Bernoulli coefficients.

As you asked for concrete use cases: I want to use it for the gradient and Hessian of the Dirichlet-Function and in this case I need the bigamma and trigamma function at the same time. Therefore I miss a way to just compute both at the same time as they should share some computations...

comment:9 by John Maddock, 8 years ago

Many thanks for the response,

But may I ask why the multiplication theorem is not used in the formulas? It seems to be a nice way to reduce the problem for large arguments instead of heaving to rely on Bernoulli coefficients.

The Bernoulli expansion is pretty efficient, for example at double precision it requires recursion to x > 9, then just 9 Bernoulli terms to converge.

I don't immediately see how the argument multiplication formula helps in this case - as each reduction in x results in 2 new polygamma functions.

As you asked for concrete use cases: I want to use it for the gradient and Hessian of the Dirichlet-Function and in this case I need the bigamma and trigamma function at the same time. Therefore I miss a way to just compute both at the same time as they should share some computations...

I don't think there much overlap in terms of computation as digamma uses rational approximations for the evaluation.

comment:10 by John Maddock, 8 years ago

Resolution: fixed
Status: newclosed

Fixed in develop

Note: See TracTickets for help on using tickets.