1[section:trigamma Trigamma] 2 3[h4 Synopsis] 4 5`` 6#include <boost/math/special_functions/trigamma.hpp> 7`` 8 9 namespace boost{ namespace math{ 10 11 template <class T> 12 ``__sf_result`` trigamma(T x); 13 14 template <class T, class ``__Policy``> 15 ``__sf_result`` trigamma(T x, const ``__Policy``&); 16 17 }} // namespaces 18 19[h4 Description] 20 21Returns the trigamma function of /x/. Trigamma is defined as the 22derivative of the digamma function: 23 24[equation trigamma1] 25 26[graph trigamma] 27 28[optional_policy] 29 30The return type of this function is computed using the __arg_promotion_rules: 31the result is of type `double` when T is an integer type, and type T otherwise. 32 33[h4 Accuracy] 34 35The following table shows the peak errors (in units of epsilon) 36found on various platforms with various floating point types. 37Unless otherwise specified any floating point type that is narrower 38than the one shown will have __zero_error. 39 40[table_trigamma] 41 42As shown above, error rates are generally very low for built in types. 43For multiprecision types, error rates are typically in the order of a 44few epsilon. 45 46The following error plot are based on an exhaustive search of the functions domain, MSVC-15.5 at `double` precision, 47and GCC-7.1/Ubuntu for `long double` and `__float128`. 48 49[graph trigamma__double] 50 51[graph trigamma__80_bit_long_double] 52 53[graph trigamma____float128] 54 55[h4 Testing] 56 57Testing is against Mathematica generated spot values to 35 digit precision. 58 59[h4 Implementation] 60 61The arbitrary precision version of this function simply calls __polygamma. 62 63For built in fixed-precision types, negative arguments are first made positive via: 64 65[equation trigamma2] 66 67Then arguments in the range \[0, 1) are shifted to >= 1 via: 68 69[equation trigamma3] 70 71Then evaluation is via one of a number of rational approximations, for small /x/ these are 72of the form: 73 74[equation trigamma4] 75 76and for large /x/ of the form: 77 78[equation trigamma5] 79 80[endsect] [/section:digamma The Trigamma Function] 81 82[/ 83 Copyright 2014 John Maddock and Paul A. Bristow. 84 Distributed under the Boost Software License, Version 1.0. 85 (See accompanying file LICENSE_1_0.txt or copy at 86 http://www.boost.org/LICENSE_1_0.txt). 87] 88 89