Exemplo n.º 1
0
inline T digamma_imp_large(T x, const mpl::int_<24>*)
{
   BOOST_MATH_STD_USING // ADL of std functions.
   static const T P[] = {
      BOOST_MATH_BIG_CONSTANT(T, 24, 0.083333333333333333333333333333333333333333333333333),
      BOOST_MATH_BIG_CONSTANT(T, 24, -0.0083333333333333333333333333333333333333333333333333),
      BOOST_MATH_BIG_CONSTANT(T, 24, 0.003968253968253968253968253968253968253968253968254)
   };
   x -= 1;
   T result = log(x);
   result += 1 / (2 * x);
   T z = 1 / (x*x);
   result -= z * tools::evaluate_polynomial(P, z);
   return result;
}
Exemplo n.º 2
0
inline T digamma_imp_large(T x, const mpl::int_<53>*)
{
   BOOST_MATH_STD_USING // ADL of std functions.
   static const T P[] = {
      BOOST_MATH_BIG_CONSTANT(T, 53, 0.083333333333333333333333333333333333333333333333333),
      BOOST_MATH_BIG_CONSTANT(T, 53, -0.0083333333333333333333333333333333333333333333333333),
      BOOST_MATH_BIG_CONSTANT(T, 53, 0.003968253968253968253968253968253968253968253968254),
      BOOST_MATH_BIG_CONSTANT(T, 53, -0.0041666666666666666666666666666666666666666666666667),
      BOOST_MATH_BIG_CONSTANT(T, 53, 0.0075757575757575757575757575757575757575757575757576),
      BOOST_MATH_BIG_CONSTANT(T, 53, -0.021092796092796092796092796092796092796092796092796),
      BOOST_MATH_BIG_CONSTANT(T, 53, 0.083333333333333333333333333333333333333333333333333),
      BOOST_MATH_BIG_CONSTANT(T, 53, -0.44325980392156862745098039215686274509803921568627)
   };
   x -= 1;
   T result = log(x);
   result += 1 / (2 * x);
   T z = 1 / (x*x);
   result -= z * tools::evaluate_polynomial(P, z);
   return result;
}
Exemplo n.º 3
0
inline T digamma_imp_large(T x, const mpl::int_<64>*)
{
   BOOST_MATH_STD_USING // ADL of std functions.
   static const T P[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.083333333333333333333333333333333333333333333333333),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.0083333333333333333333333333333333333333333333333333),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.003968253968253968253968253968253968253968253968254),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.0041666666666666666666666666666666666666666666666667),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.0075757575757575757575757575757575757575757575757576),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.021092796092796092796092796092796092796092796092796),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.083333333333333333333333333333333333333333333333333),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.44325980392156862745098039215686274509803921568627),
      BOOST_MATH_BIG_CONSTANT(T, 64, 3.0539543302701197438039543302701197438039543302701),
      BOOST_MATH_BIG_CONSTANT(T, 64, -26.456212121212121212121212121212121212121212121212),
      BOOST_MATH_BIG_CONSTANT(T, 64, 281.4601449275362318840579710144927536231884057971),
   };
   x -= 1;
   T result = log(x);
   result += 1 / (2 * x);
   T z = 1 / (x*x);
   result -= z * tools::evaluate_polynomial(P, z);
   return result;
}
Exemplo n.º 4
0
inline T digamma_imp_large(T x, const mpl::int_<0>*)
{
   BOOST_MATH_STD_USING // ADL of std functions.
   static const T P[] = {
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.083333333333333333333333333333333333333333333333333),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.0083333333333333333333333333333333333333333333333333),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.003968253968253968253968253968253968253968253968254),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.0041666666666666666666666666666666666666666666666667),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.0075757575757575757575757575757575757575757575757576),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.021092796092796092796092796092796092796092796092796),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.083333333333333333333333333333333333333333333333333),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.44325980392156862745098039215686274509803921568627),
      BOOST_MATH_BIG_CONSTANT(T, 113, 3.0539543302701197438039543302701197438039543302701),
      BOOST_MATH_BIG_CONSTANT(T, 113, -26.456212121212121212121212121212121212121212121212),
      BOOST_MATH_BIG_CONSTANT(T, 113, 281.4601449275362318840579710144927536231884057971),
      BOOST_MATH_BIG_CONSTANT(T, 113, -3607.510546398046398046398046398046398046398046398),
      BOOST_MATH_BIG_CONSTANT(T, 113, 54827.583333333333333333333333333333333333333333333),
      BOOST_MATH_BIG_CONSTANT(T, 113, -974936.82385057471264367816091954022988505747126437),
      BOOST_MATH_BIG_CONSTANT(T, 113, 20052695.796688078946143462272494530559046688078946),
      BOOST_MATH_BIG_CONSTANT(T, 113, -472384867.72162990196078431372549019607843137254902),
      BOOST_MATH_BIG_CONSTANT(T, 113, 12635724795.916666666666666666666666666666666666667)
   };
   x -= 1;
   T result = log(x);
   result += 1 / (2 * x);
   T z = 1 / (x*x);
   result -= z * tools::evaluate_polynomial(P, z);
   return result;
}
Exemplo n.º 5
0
T digamma_imp_1_2(T x, const mpl::int_<53>*)
{
   //
   // Now the approximation, we use the form:
   //
   // digamma(x) = (x - root) * (Y + R(x-1))
   //
   // Where root is the location of the positive root of digamma,
   // Y is a constant, and R is optimised for low absolute error
   // compared to Y.
   //
   // Maximum Deviation Found:               1.466e-18
   // At double precision, max error found:  2.452e-17
   //
   static const float Y = 0.99558162689208984F;

   static const T root1 = T(1569415565) / 1073741824uL;
   static const T root2 = (T(381566830) / 1073741824uL) / 1073741824uL;
   static const T root3 = BOOST_MATH_BIG_CONSTANT(T, 53, 0.9016312093258695918615325266959189453125e-19);

   static const T P[] = {    
      BOOST_MATH_BIG_CONSTANT(T, 53, 0.25479851061131551),
      BOOST_MATH_BIG_CONSTANT(T, 53, -0.32555031186804491),
      BOOST_MATH_BIG_CONSTANT(T, 53, -0.65031853770896507),
      BOOST_MATH_BIG_CONSTANT(T, 53, -0.28919126444774784),
      BOOST_MATH_BIG_CONSTANT(T, 53, -0.045251321448739056),
      BOOST_MATH_BIG_CONSTANT(T, 53, -0.0020713321167745952)
   };
   static const T Q[] = {    
      BOOST_MATH_BIG_CONSTANT(T, 53, 1),
      BOOST_MATH_BIG_CONSTANT(T, 53, 2.0767117023730469),
      BOOST_MATH_BIG_CONSTANT(T, 53, 1.4606242909763515),
      BOOST_MATH_BIG_CONSTANT(T, 53, 0.43593529692665969),
      BOOST_MATH_BIG_CONSTANT(T, 53, 0.054151797245674225),
      BOOST_MATH_BIG_CONSTANT(T, 53, 0.0021284987017821144),
      BOOST_MATH_BIG_CONSTANT(T, 53, -0.55789841321675513e-6)
   };
   T g = x - root1;
   g -= root2;
   g -= root3;
   T r = tools::evaluate_polynomial(P, T(x-1)) / tools::evaluate_polynomial(Q, T(x-1));
   T result = g * Y + g * r;

   return result;
}
Exemplo n.º 6
0
T digamma_imp_1_2(T x, const mpl::int_<64>*)
{
   //
   // Now the approximation, we use the form:
   //
   // digamma(x) = (x - root) * (Y + R(x-1))
   //
   // Where root is the location of the positive root of digamma,
   // Y is a constant, and R is optimised for low absolute error
   // compared to Y.
   //
   // Max error found at 80-bit long double precision:   5.016e-20
   // Maximum Deviation Found (approximation error):     3.575e-20
   //
   static const float Y = 0.99558162689208984375F;

   static const T root1 = T(1569415565) / 1073741824uL;
   static const T root2 = (T(381566830) / 1073741824uL) / 1073741824uL;
   static const T root3 = BOOST_MATH_BIG_CONSTANT(T, 64, 0.9016312093258695918615325266959189453125e-19);

   static const T P[] = {    
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.254798510611315515235),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.314628554532916496608),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.665836341559876230295),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.314767657147375752913),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.0541156266153505273939),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.00289268368333918761452)
   };
   static const T Q[] = {    
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.0),
      BOOST_MATH_BIG_CONSTANT(T, 64, 2.1195759927055347547),
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.54350554664961128724),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.486986018231042975162),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.0660481487173569812846),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.00298999662592323990972),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.165079794012604905639e-5),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.317940243105952177571e-7)
   };
   T g = x - root1;
   g -= root2;
   g -= root3;
   T r = tools::evaluate_polynomial(P, T(x-1)) / tools::evaluate_polynomial(Q, T(x-1));
   T result = g * Y + g * r;

   return result;
}
Exemplo n.º 7
0
T digamma_imp_1_2(T x, const mpl::int_<0>*)
{
   //
   // Now the approximation, we use the form:
   //
   // digamma(x) = (x - root) * (Y + R(x-1))
   //
   // Where root is the location of the positive root of digamma,
   // Y is a constant, and R is optimised for low absolute error
   // compared to Y.
   //
   // Max error found at 128-bit long double precision:  5.541e-35
   // Maximum Deviation Found (approximation error):     1.965e-35
   //
   static const float Y = 0.99558162689208984375F;

   static const T root1 = T(1569415565) / 1073741824uL;
   static const T root2 = (T(381566830) / 1073741824uL) / 1073741824uL;
   static const T root3 = ((T(111616537) / 1073741824uL) / 1073741824uL) / 1073741824uL;
   static const T root4 = (((T(503992070) / 1073741824uL) / 1073741824uL) / 1073741824uL) / 1073741824uL;
   static const T root5 = BOOST_MATH_BIG_CONSTANT(T, 113, 0.52112228569249997894452490385577338504019838794544e-36);

   static const T P[] = {    
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.25479851061131551526977464225335883769),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.18684290534374944114622235683619897417),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.80360876047931768958995775910991929922),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.67227342794829064330498117008564270136),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.26569010991230617151285010695543858005),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.05775672694575986971640757748003553385),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.0071432147823164975485922555833274240665),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.00048740753910766168912364555706064993274),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.16454996865214115723416538844975174761e-4),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.20327832297631728077731148515093164955e-6)
   };
   static const T Q[] = {    
      BOOST_MATH_BIG_CONSTANT(T, 113, 1.0),
      BOOST_MATH_BIG_CONSTANT(T, 113, 2.6210924610812025425088411043163287646),
      BOOST_MATH_BIG_CONSTANT(T, 113, 2.6850757078559596612621337395886392594),
      BOOST_MATH_BIG_CONSTANT(T, 113, 1.4320913706209965531250495490639289418),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.4410872083455009362557012239501953402),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.081385727399251729505165509278152487225),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.0089478633066857163432104815183858149496),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.00055861622855066424871506755481997374154),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.1760168552357342401304462967950178554e-4),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.20585454493572473724556649516040874384e-6),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.90745971844439990284514121823069162795e-11),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.48857673606545846774761343500033283272e-13),
   };
   T g = x - root1;
   g -= root2;
   g -= root3;
   g -= root4;
   g -= root5;
   T r = tools::evaluate_polynomial(P, T(x-1)) / tools::evaluate_polynomial(Q, T(x-1));
   T result = g * Y + g * r;

   return result;
}
Exemplo n.º 8
0
T expm1_imp(T x, const mpl::int_<64>&, const P& pol)
{
   BOOST_MATH_STD_USING

   T a = fabs(x);
   if(a > T(0.5L))
   {
      if(a >= tools::log_max_value<T>())
      {
         if(x > 0)
            return policies::raise_overflow_error<T>("boost::math::expm1<%1%>(%1%)", 0, pol);
         return -1;
      }
      return exp(x) - T(1);
   }
   if(a < tools::epsilon<T>())
      return x;

   static const float Y = 0.10281276702880859375e1f;
   static const T n[] = { 
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.281276702880859375e-1), 
       BOOST_MATH_BIG_CONSTANT(T, 64, 0.512980290285154286358e0), 
       BOOST_MATH_BIG_CONSTANT(T, 64, -0.667758794592881019644e-1),
       BOOST_MATH_BIG_CONSTANT(T, 64, 0.131432469658444745835e-1),
       BOOST_MATH_BIG_CONSTANT(T, 64, -0.72303795326880286965e-3),
       BOOST_MATH_BIG_CONSTANT(T, 64, 0.447441185192951335042e-4),
       BOOST_MATH_BIG_CONSTANT(T, 64, -0.714539134024984593011e-6)
   };
   static const T d[] = { 
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.0),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.461477618025562520389e0),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.961237488025708540713e-1),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.116483957658204450739e-1),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.873308008461557544458e-3),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.387922804997682392562e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.807473180049193557294e-6)
   };

   T result = x * Y + x * tools::evaluate_polynomial(n, x) / tools::evaluate_polynomial(d, x);
   return result;
}
Exemplo n.º 9
0
T expm1_imp(T x, const mpl::int_<113>&, const P& pol)
{
   BOOST_MATH_STD_USING

   T a = fabs(x);
   if(a > T(0.5L))
   {
      if(a >= tools::log_max_value<T>())
      {
         if(x > 0)
            return policies::raise_overflow_error<T>("boost::math::expm1<%1%>(%1%)", 0, pol);
         return -1;
      }
      return exp(x) - T(1);
   }
   if(a < tools::epsilon<T>())
      return x;

   static const float Y = 0.10281276702880859375e1f;
   static const T n[] = { 
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.28127670288085937499999999999999999854e-1),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.51278156911210477556524452177540792214e0),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.63263178520747096729500254678819588223e-1),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.14703285606874250425508446801230572252e-1),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.8675686051689527802425310407898459386e-3),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.88126359618291165384647080266133492399e-4),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.25963087867706310844432390015463138953e-5),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.14226691087800461778631773363204081194e-6),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.15995603306536496772374181066765665596e-8),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.45261820069007790520447958280473183582e-10)
   };
   static const T d[] = { 
      BOOST_MATH_BIG_CONSTANT(T, 113, 1.0),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.45441264709074310514348137469214538853e0),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.96827131936192217313133611655555298106e-1),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.12745248725908178612540554584374876219e-1),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.11473613871583259821612766907781095472e-2),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.73704168477258911962046591907690764416e-4),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.34087499397791555759285503797256103259e-5),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.11114024704296196166272091230695179724e-6),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.23987051614110848595909588343223896577e-8),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.29477341859111589208776402638429026517e-10),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.13222065991022301420255904060628100924e-12)
   };

   T result = x * Y + x * tools::evaluate_polynomial(n, x) / tools::evaluate_polynomial(d, x);
   return result;
}
Exemplo n.º 10
0
T igamma_temme_large(T a, T x, const Policy& pol, mpl::int_<64> const *)
{
   BOOST_MATH_STD_USING // ADL of std functions
   T sigma = (x - a) / a;
   T phi = -boost::math::log1pmx(sigma, pol);
   T y = a * phi;
   T z = sqrt(2 * phi);
   if(x < a)
      z = -z;

   T workspace[13];

   static const T C0[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.333333333333333333333),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.0833333333333333333333),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.0148148148148148148148),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.00115740740740740740741),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000352733686067019400353),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.0001787551440329218107),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.39192631785224377817e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.218544851067999216147e-5),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.18540622107151599607e-5),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.829671134095308600502e-6),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.176659527368260793044e-6),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.670785354340149858037e-8),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.102618097842403080426e-7),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.438203601845335318655e-8),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.914769958223679023418e-9),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.255141939949462497669e-10),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.583077213255042506746e-10),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.243619480206674162437e-10),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.502766928011417558909e-11),
   };
   workspace[0] = tools::evaluate_polynomial(C0, z);

   static const T C1[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.00185185185185185185185),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.00347222222222222222222),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.00264550264550264550265),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.000990226337448559670782),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000205761316872427983539),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.40187757201646090535e-6),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.18098550334489977837e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.764916091608111008464e-5),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.161209008945634460038e-5),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.464712780280743434226e-8),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.137863344691572095931e-6),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.575254560351770496402e-7),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.119516285997781473243e-7),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.175432417197476476238e-10),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.100915437106004126275e-8),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.416279299184258263623e-9),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.856390702649298063807e-10),
   };
   workspace[1] = tools::evaluate_polynomial(C1, z);

   static const T C2[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.00413359788359788359788),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.00268132716049382716049),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000771604938271604938272),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.200938786008230452675e-5),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.000107366532263651605215),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.529234488291201254164e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.127606351886187277134e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.342357873409613807419e-7),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.137219573090629332056e-5),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.629899213838005502291e-6),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.142806142060642417916e-6),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.204770984219908660149e-9),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.140925299108675210533e-7),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.622897408492202203356e-8),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.136704883966171134993e-8),
   };
   workspace[2] = tools::evaluate_polynomial(C2, z);

   static const T C3[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000649434156378600823045),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000229472093621399176955),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.000469189494395255712128),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000267720632062838852962),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.756180167188397641073e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.239650511386729665193e-6),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.110826541153473023615e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.56749528269915965675e-5),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.142309007324358839146e-5),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.278610802915281422406e-10),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.169584040919302772899e-6),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.809946490538808236335e-7),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.191111684859736540607e-7),
   };
   workspace[3] = tools::evaluate_polynomial(C3, z);

   static const T C4[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.000861888290916711698605),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000784039221720066627474),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.000299072480303190179733),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.146384525788434181781e-5),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.664149821546512218666e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.396836504717943466443e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.113757269706784190981e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.250749722623753280165e-9),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.169541495365583060147e-5),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.890750753220530968883e-6),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.229293483400080487057e-6),
   };
   workspace[4] = tools::evaluate_polynomial(C4, z);

   static const T C5[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.000336798553366358150309),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.697281375836585777429e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000277275324495939207873),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.000199325705161888477003),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.679778047793720783882e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.141906292064396701483e-6),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.135940481897686932785e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.801847025633420153972e-5),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.229148117650809517038e-5),
   };
   workspace[5] = tools::evaluate_polynomial(C5, z);

   static const T C6[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000531307936463992223166),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.000592166437353693882865),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000270878209671804482771),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.790235323266032787212e-6),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.815396936756196875093e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.561168275310624965004e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.183291165828433755673e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.307961345060330478256e-8),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.346515536880360908674e-5),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.20291327396058603727e-5),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.57887928631490037089e-6),
   };
   workspace[6] = tools::evaluate_polynomial(C6, z);

   static const T C7[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000344367606892377671254),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.517179090826059219337e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.000334931610811422363117),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000281269515476323702274),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.000109765822446847310235),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.127410090954844853795e-6),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.277444515115636441571e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.182634888057113326614e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.578769494973505239894e-5),
   };
   workspace[7] = tools::evaluate_polynomial(C7, z);

   static const T C8[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.000652623918595309418922),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000839498720672087279993),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.000438297098541721005061),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.696909145842055197137e-6),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000166448466420675478374),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.000127835176797692185853),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.462995326369130429061e-4),
   };
   workspace[8] = tools::evaluate_polynomial(C8, z);

   static const T C9[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.000596761290192746250124),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.720489541602001055909e-4),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000678230883766732836162),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.0006401475260262758451),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000277501076343287044992),
   };
   workspace[9] = tools::evaluate_polynomial(C9, z);

   static const T C10[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.00133244544948006563713),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.0019144384985654775265),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.00110893691345966373396),
   };
   workspace[10] = tools::evaluate_polynomial(C10, z);

   static const T C11[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.00157972766073083495909),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.000162516262783915816899),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.00206334210355432762645),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.00213896861856890981541),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.00101085593912630031708),
   };
   workspace[11] = tools::evaluate_polynomial(C11, z);

   static const T C12[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.00407251211951401664727),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.00640336283380806979482),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.00404101610816766177474),
   };
   workspace[12] = tools::evaluate_polynomial(C12, z);

   T result = tools::evaluate_polynomial<13, T, T>(workspace, 1/a);
   result *= exp(-y) / sqrt(2 * constants::pi<T>() * a);
   if(x < a)
      result = -result;

   result += boost::math::erfc(sqrt(y), pol) / 2;

   return result;
}
Exemplo n.º 11
0
T trigamma_prec(T x, const mpl::int_<53>*, const Policy&)
{
   // Max error in interpolated form: 3.736e-017
   static const T offset = BOOST_MATH_BIG_CONSTANT(T, 53, 2.1093254089355469);
   static const T P_1_2[] = {
      BOOST_MATH_BIG_CONSTANT(T, 53, -1.1093280605946045),
      BOOST_MATH_BIG_CONSTANT(T, 53, -3.8310674472619321),
      BOOST_MATH_BIG_CONSTANT(T, 53, -3.3703848401898283),
      BOOST_MATH_BIG_CONSTANT(T, 53, 0.28080574467981213),
      BOOST_MATH_BIG_CONSTANT(T, 53, 1.6638069578676164),
      BOOST_MATH_BIG_CONSTANT(T, 53, 0.64468386819102836),
   };
   static const T Q_1_2[] = {
      BOOST_MATH_BIG_CONSTANT(T, 53, 1.0),
      BOOST_MATH_BIG_CONSTANT(T, 53, 3.4535389668541151),
      BOOST_MATH_BIG_CONSTANT(T, 53, 4.5208926987851437),
      BOOST_MATH_BIG_CONSTANT(T, 53, 2.7012734178351534),
      BOOST_MATH_BIG_CONSTANT(T, 53, 0.64468798399785611),
      BOOST_MATH_BIG_CONSTANT(T, 53, -0.20314516859987728e-6),
   };
   // Max error in interpolated form: 1.159e-017
   static const T P_2_4[] = {
      BOOST_MATH_BIG_CONSTANT(T, 53, -0.13803835004508849e-7),
      BOOST_MATH_BIG_CONSTANT(T, 53, 0.50000049158540261),
      BOOST_MATH_BIG_CONSTANT(T, 53, 1.6077979838469348),
      BOOST_MATH_BIG_CONSTANT(T, 53, 2.5645435828098254),
      BOOST_MATH_BIG_CONSTANT(T, 53, 2.0534873203680393),
      BOOST_MATH_BIG_CONSTANT(T, 53, 0.74566981111565923),
   };
   static const T Q_2_4[] = {
      BOOST_MATH_BIG_CONSTANT(T, 53, 1.0),
      BOOST_MATH_BIG_CONSTANT(T, 53, 2.8822787662376169),
      BOOST_MATH_BIG_CONSTANT(T, 53, 4.1681660554090917),
      BOOST_MATH_BIG_CONSTANT(T, 53, 2.7853527819234466),
      BOOST_MATH_BIG_CONSTANT(T, 53, 0.74967671848044792),
      BOOST_MATH_BIG_CONSTANT(T, 53, -0.00057069112416246805),
   };
   // Maximum Deviation Found:                     6.896e-018
   // Expected Error Term :                       -6.895e-018
   // Maximum Relative Change in Control Points :  8.497e-004
   static const T P_4_inf[] = {
      static_cast<T>(0.68947581948701249e-17L),
      static_cast<T>(0.49999999999998975L),
      static_cast<T>(1.0177274392923795L),
      static_cast<T>(2.498208511343429L),
      static_cast<T>(2.1921221359427595L),
      static_cast<T>(1.5897035272532764L),
      static_cast<T>(0.40154388356961734L),
   };
   static const T Q_4_inf[] = {
      static_cast<T>(1.0L),
      static_cast<T>(1.7021215452463932L),
      static_cast<T>(4.4290431747556469L),
      static_cast<T>(2.9745631894384922L),
      static_cast<T>(2.3013614809773616L),
      static_cast<T>(0.28360399799075752L),
      static_cast<T>(0.022892987908906897L),
   };

   if(x <= 2)
   {
      return (offset + boost::math::tools::evaluate_polynomial(P_1_2, x) / tools::evaluate_polynomial(Q_1_2, x)) / (x * x);
   }
   else if(x <= 4)
   {
      T y = 1 / x;
      return (1 + tools::evaluate_polynomial(P_2_4, y) / tools::evaluate_polynomial(Q_2_4, y)) / x;
   }
   T y = 1 / x;
   return (1 + tools::evaluate_polynomial(P_4_inf, y) / tools::evaluate_polynomial(Q_4_inf, y)) / x;
}
Exemplo n.º 12
0
T trigamma_prec(T x, const mpl::int_<113>*, const Policy&)
{
   // Max error in interpolated form: 1.916e-035

   static const T P_1_2[] = {
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.999999999999999082554457936871832533),
      BOOST_MATH_BIG_CONSTANT(T, 113, -4.71237311120865266379041700054847734),
      BOOST_MATH_BIG_CONSTANT(T, 113, -7.94125711970499027763789342500817316),
      BOOST_MATH_BIG_CONSTANT(T, 113, -5.74657746697664735258222071695644535),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.404213349456398905981223965160595687),
      BOOST_MATH_BIG_CONSTANT(T, 113, 2.47877781178642876561595890095758896),
      BOOST_MATH_BIG_CONSTANT(T, 113, 2.07714151702455125992166949812126433),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.858877899162360138844032265418028567),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.20499222604410032375789018837922397),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.0272103140348194747360175268778415049),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.0015764849020876949848954081173520686),
   };
   static const T Q_1_2[] = {
      BOOST_MATH_BIG_CONSTANT(T, 113, 1.0),
      BOOST_MATH_BIG_CONSTANT(T, 113, 4.71237311120863419878375031457715223),
      BOOST_MATH_BIG_CONSTANT(T, 113, 9.58619118655339853449127952145877467),
      BOOST_MATH_BIG_CONSTANT(T, 113, 11.0940067269829372437561421279054968),
      BOOST_MATH_BIG_CONSTANT(T, 113, 8.09075424749327792073276309969037885),
      BOOST_MATH_BIG_CONSTANT(T, 113, 3.87705890159891405185343806884451286),
      BOOST_MATH_BIG_CONSTANT(T, 113, 1.22758678701914477836330837816976782),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.249092040606385004109672077814668716),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.0295750413900655597027079600025569048),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.00157648490200498142247694709728858139),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.161264050344059471721062360645432809e-14),
   };

   // Max error in interpolated form: 8.958e-035
   static const T P_2_4[] = {
      BOOST_MATH_BIG_CONSTANT(T, 113, -2.55843734739907925764326773972215085),
      BOOST_MATH_BIG_CONSTANT(T, 113, -12.2830208240542011967952466273455887),
      BOOST_MATH_BIG_CONSTANT(T, 113, -23.9195022162767993526575786066414403),
      BOOST_MATH_BIG_CONSTANT(T, 113, -24.9256431504823483094158828285470862),
      BOOST_MATH_BIG_CONSTANT(T, 113, -14.7979122765478779075108064826412285),
      BOOST_MATH_BIG_CONSTANT(T, 113, -4.46654453928610666393276765059122272),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.0191439033405649675717082465687845002),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.515412052554351265708917209749037352),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.195378348786064304378247325360320038),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.0334761282624174313035014426794245393),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.002373665205942206348500250056602687),
   };
   static const T Q_2_4[] = {
      BOOST_MATH_BIG_CONSTANT(T, 113, 1.0),
      BOOST_MATH_BIG_CONSTANT(T, 113, 4.80098558454419907830670928248659245),
      BOOST_MATH_BIG_CONSTANT(T, 113, 9.99220727843170133895059300223445265),
      BOOST_MATH_BIG_CONSTANT(T, 113, 11.8896146167631330735386697123464976),
      BOOST_MATH_BIG_CONSTANT(T, 113, 8.96613256683809091593793565879092581),
      BOOST_MATH_BIG_CONSTANT(T, 113, 4.47254136149624110878909334574485751),
      BOOST_MATH_BIG_CONSTANT(T, 113, 1.48600982028196527372434773913633152),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.319570735766764237068541501137990078),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.0407358345787680953107374215319322066),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.00237366520593271641375755486420859837),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.239554887903526152679337256236302116e-15),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.294749244740618656265237072002026314e-17),
   };

   static const T y_offset_2_4 = BOOST_MATH_BIG_CONSTANT(T, 113, 3.558437347412109375);

   // Max error in interpolated form: 4.319e-035
   static const T P_4_8[] = {
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.166626112697021464248967707021688845e-16),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.499999999999997739552090249208808197),
      BOOST_MATH_BIG_CONSTANT(T, 113, 6.40270945019053817915772473771553187),
      BOOST_MATH_BIG_CONSTANT(T, 113, 41.3833374155000608013677627389343329),
      BOOST_MATH_BIG_CONSTANT(T, 113, 166.803341854562809335667241074035245),
      BOOST_MATH_BIG_CONSTANT(T, 113, 453.39964786925369319960722793414521),
      BOOST_MATH_BIG_CONSTANT(T, 113, 851.153712317697055375935433362983944),
      BOOST_MATH_BIG_CONSTANT(T, 113, 1097.70657567285059133109286478004458),
      BOOST_MATH_BIG_CONSTANT(T, 113, 938.431232478455316020076349367632922),
      BOOST_MATH_BIG_CONSTANT(T, 113, 487.268001604651932322080970189930074),
      BOOST_MATH_BIG_CONSTANT(T, 113, 119.953445242335730062471193124820659),
   };
   static const T Q_4_8[] = {
      BOOST_MATH_BIG_CONSTANT(T, 113, 1.0),
      BOOST_MATH_BIG_CONSTANT(T, 113, 12.4720855670474488978638945855932398),
      BOOST_MATH_BIG_CONSTANT(T, 113, 78.6093129753298570701376952709727391),
      BOOST_MATH_BIG_CONSTANT(T, 113, 307.470246050318322489781182863190127),
      BOOST_MATH_BIG_CONSTANT(T, 113, 805.140686101151538537565264188630079),
      BOOST_MATH_BIG_CONSTANT(T, 113, 1439.12019760292146454787601409644413),
      BOOST_MATH_BIG_CONSTANT(T, 113, 1735.6105285756048831268586001383127),
      BOOST_MATH_BIG_CONSTANT(T, 113, 1348.32500712856328019355198611280536),
      BOOST_MATH_BIG_CONSTANT(T, 113, 607.225985860570846699704222144650563),
      BOOST_MATH_BIG_CONSTANT(T, 113, 119.952317857277045332558673164517227),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.000140165918355036060868680809129436084),
   };

   // Maximum Deviation Found:                     2.867e-035
   // Expected Error Term :                        2.866e-035
   // Maximum Relative Change in Control Points :  2.662e-004
   static const T P_8_16[] = {
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.184828315274146610610872315609837439e-19),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.500000000000000004122475157735807738),
      BOOST_MATH_BIG_CONSTANT(T, 113, 3.02533865247313349284875558880415875),
      BOOST_MATH_BIG_CONSTANT(T, 113, 13.5995927517457371243039532492642734),
      BOOST_MATH_BIG_CONSTANT(T, 113, 35.3132224283087906757037999452941588),
      BOOST_MATH_BIG_CONSTANT(T, 113, 67.1639424550714159157603179911505619),
      BOOST_MATH_BIG_CONSTANT(T, 113, 83.5767733658513967581959839367419891),
      BOOST_MATH_BIG_CONSTANT(T, 113, 71.073491212235705900866411319363501),
      BOOST_MATH_BIG_CONSTANT(T, 113, 35.8621515614725564575893663483998663),
      BOOST_MATH_BIG_CONSTANT(T, 113, 8.72152231639983491987779743154333318),
   };
   static const T Q_8_16[] = {
      BOOST_MATH_BIG_CONSTANT(T, 113, 1.0),
      BOOST_MATH_BIG_CONSTANT(T, 113, 5.71734397161293452310624822415866372),
      BOOST_MATH_BIG_CONSTANT(T, 113, 25.293404179620438179337103263274815),
      BOOST_MATH_BIG_CONSTANT(T, 113, 62.2619767967468199111077640625328469),
      BOOST_MATH_BIG_CONSTANT(T, 113, 113.955048909238993473389714972250235),
      BOOST_MATH_BIG_CONSTANT(T, 113, 130.807138328938966981862203944329408),
      BOOST_MATH_BIG_CONSTANT(T, 113, 102.423146902337654110717764213057753),
      BOOST_MATH_BIG_CONSTANT(T, 113, 44.0424772805245202514468199602123565),
      BOOST_MATH_BIG_CONSTANT(T, 113, 8.89898032477904072082994913461386099),
      BOOST_MATH_BIG_CONSTANT(T, 113, -0.0296627336872039988632793863671456398),
   };
   // Maximum Deviation Found:                     1.079e-035
   // Expected Error Term :                       -1.079e-035
   // Maximum Relative Change in Control Points :  7.884e-003
   static const T P_16_inf[] = {
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.0),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.500000000000000000000000000000087317),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.345625669885456215194494735902663968),
      BOOST_MATH_BIG_CONSTANT(T, 113, 9.62895499360842232127552650044647769),
      BOOST_MATH_BIG_CONSTANT(T, 113, 3.5936085382439026269301003761320812),
      BOOST_MATH_BIG_CONSTANT(T, 113, 49.459599118438883265036646019410669),
      BOOST_MATH_BIG_CONSTANT(T, 113, 7.77519237321893917784735690560496607),
      BOOST_MATH_BIG_CONSTANT(T, 113, 74.4536074488178075948642351179304121),
      BOOST_MATH_BIG_CONSTANT(T, 113, 2.75209340397069050436806159297952699),
      BOOST_MATH_BIG_CONSTANT(T, 113, 23.9292359711471667884504840186561598),
   };
   static const T Q_16_inf[] = {
      BOOST_MATH_BIG_CONSTANT(T, 113, 1.0),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.357918006437579097055656138920742037),
      BOOST_MATH_BIG_CONSTANT(T, 113, 19.1386039850709849435325005484512944),
      BOOST_MATH_BIG_CONSTANT(T, 113, 0.874349081464143606016221431763364517),
      BOOST_MATH_BIG_CONSTANT(T, 113, 98.6516097434855572678195488061432509),
      BOOST_MATH_BIG_CONSTANT(T, 113, -16.1051972833382893468655223662534306),
      BOOST_MATH_BIG_CONSTANT(T, 113, 154.316860216253720989145047141653727),
      BOOST_MATH_BIG_CONSTANT(T, 113, -40.2026880424378986053105969312264534),
      BOOST_MATH_BIG_CONSTANT(T, 113, 60.1679136674264778074736441126810223),
      BOOST_MATH_BIG_CONSTANT(T, 113, -13.3414844622256422644504472438320114),
      BOOST_MATH_BIG_CONSTANT(T, 113, 2.53795636200649908779512969030363442),
   };

   if(x <= 2)
   {
      return (2 + boost::math::tools::evaluate_polynomial(P_1_2, x) / tools::evaluate_polynomial(Q_1_2, x)) / (x * x);
   }
   else if(x <= 4)
   {
      return (y_offset_2_4 + boost::math::tools::evaluate_polynomial(P_2_4, x) / tools::evaluate_polynomial(Q_2_4, x)) / (x * x);
   }
   else if(x <= 8)
   {
      T y = 1 / x;
      return (1 + tools::evaluate_polynomial(P_4_8, y) / tools::evaluate_polynomial(Q_4_8, y)) / x;
   }
   else if(x <= 16)
   {
      T y = 1 / x;
      return (1 + tools::evaluate_polynomial(P_8_16, y) / tools::evaluate_polynomial(Q_8_16, y)) / x;
   }
   T y = 1 / x;
   return (1 + tools::evaluate_polynomial(P_16_inf, y) / tools::evaluate_polynomial(Q_16_inf, y)) / x;
}
Exemplo n.º 13
0
T trigamma_prec(T x, const mpl::int_<64>*, const Policy&)
{
   // Max error in interpolated form: 1.178e-020
   static const T offset_1_2 = BOOST_MATH_BIG_CONSTANT(T, 64, 2.109325408935546875);
   static const T P_1_2[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, -1.10932535608960258341),
      BOOST_MATH_BIG_CONSTANT(T, 64, -4.18793841543017129052),
      BOOST_MATH_BIG_CONSTANT(T, 64, -4.63865531898487734531),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.919832884430500908047),
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.68074038333180423012),
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.21172611429185622377),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.259635673503366427284),
   };
   static const T Q_1_2[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.0),
      BOOST_MATH_BIG_CONSTANT(T, 64, 3.77521119359546982995),
      BOOST_MATH_BIG_CONSTANT(T, 64, 5.664338024578956321),
      BOOST_MATH_BIG_CONSTANT(T, 64, 4.25995134879278028361),
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.62956638448940402182),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.259635512844691089868),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.629642219810618032207e-8),
   };
   // Max error in interpolated form: 3.912e-020
   static const T P_2_8[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.387540035162952880976e-11),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.500000000276430504),
      BOOST_MATH_BIG_CONSTANT(T, 64, 3.21926880986360957306),
      BOOST_MATH_BIG_CONSTANT(T, 64, 10.2550347708483445775),
      BOOST_MATH_BIG_CONSTANT(T, 64, 18.9002075150709144043),
      BOOST_MATH_BIG_CONSTANT(T, 64, 21.0357215832399705625),
      BOOST_MATH_BIG_CONSTANT(T, 64, 13.4346512182925923978),
      BOOST_MATH_BIG_CONSTANT(T, 64, 3.98656291026448279118),
   };
   static const T Q_2_8[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.0),
      BOOST_MATH_BIG_CONSTANT(T, 64, 6.10520430478613667724),
      BOOST_MATH_BIG_CONSTANT(T, 64, 18.475001060603645512),
      BOOST_MATH_BIG_CONSTANT(T, 64, 31.7087534567758405638),
      BOOST_MATH_BIG_CONSTANT(T, 64, 31.908814523890465398),
      BOOST_MATH_BIG_CONSTANT(T, 64, 17.4175479039227084798),
      BOOST_MATH_BIG_CONSTANT(T, 64, 3.98749106958394941276),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.000115917322224411128566),
   };
   // Maximum Deviation Found:                     2.635e-020
   // Expected Error Term :                        2.635e-020
   // Maximum Relative Change in Control Points :  1.791e-003
   static const T P_8_inf[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.263527875092466899848e-19),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.500000000000000058145),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.0730121433777364138677),
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.94505878379957149534),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.0517092358874932620529),
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.07995383547483921121),
   };
   static const T Q_8_inf[] = {
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.0),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.187309046577818095504),
      BOOST_MATH_BIG_CONSTANT(T, 64, 3.95255391645238842975),
      BOOST_MATH_BIG_CONSTANT(T, 64, -1.14743283327078949087),
      BOOST_MATH_BIG_CONSTANT(T, 64, 2.52989799376344914499),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.627414303172402506396),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.141554248216425512536),
   };

   if(x <= 2)
   {
      return (offset_1_2 + boost::math::tools::evaluate_polynomial(P_1_2, x) / tools::evaluate_polynomial(Q_1_2, x)) / (x * x);
   }
   else if(x <= 8)
   {
      T y = 1 / x;
      return (1 + tools::evaluate_polynomial(P_2_8, y) / tools::evaluate_polynomial(Q_2_8, y)) / x;
   }
   T y = 1 / x;
   return (1 + tools::evaluate_polynomial(P_8_inf, y) / tools::evaluate_polynomial(Q_8_inf, y)) / x;
}
Exemplo n.º 14
0
T log1p_imp(T const& x, const Policy& pol, const mpl::int_<64>&)
{ // The function returns the natural logarithm of 1 + x.
   BOOST_MATH_STD_USING

   static const char* function = "boost::math::log1p<%1%>(%1%)";

   if(x < -1)
      return policies::raise_domain_error<T>(
         function, "log1p(x) requires x > -1, but got x = %1%.", x, pol);
   if(x == -1)
      return -policies::raise_overflow_error<T>(
         function, 0, pol);

   T a = fabs(x);
   if(a > 0.5f)
      return log(1 + x);
   // Note that without numeric_limits specialisation support, 
   // epsilon just returns zero, and our "optimisation" will always fail:
   if(a < tools::epsilon<T>())
      return x;

   // Maximum Deviation Found:                     8.089e-20
   // Expected Error Term:                         8.088e-20
   // Maximum Relative Change in Control Points:   9.648e-05
   // Max Error found at long double precision =   2.242324e-19
   static const T P[] = {    
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.807533446680736736712e-19),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.490881544804798926426e-18),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.333333333333333373941),
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.17141290782087994162),
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.62790522814926264694),
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.13156411870766876113),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.408087379932853785336),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.0706537026422828914622),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.00441709903782239229447)
   };
   static const T Q[] = {    
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.0),
      BOOST_MATH_BIG_CONSTANT(T, 64, 4.26423872346263928361),
      BOOST_MATH_BIG_CONSTANT(T, 64, 7.48189472704477708962),
      BOOST_MATH_BIG_CONSTANT(T, 64, 6.94757016732904280913),
      BOOST_MATH_BIG_CONSTANT(T, 64, 3.6493508622280767304),
      BOOST_MATH_BIG_CONSTANT(T, 64, 1.06884863623790638317),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.158292216998514145947),
      BOOST_MATH_BIG_CONSTANT(T, 64, 0.00885295524069924328658),
      BOOST_MATH_BIG_CONSTANT(T, 64, -0.560026216133415663808e-6)
   };

   T result = 1 - x / 2 + tools::evaluate_polynomial(P, x) / tools::evaluate_polynomial(Q, x);
   result *= x;

   return result;
}