2
0
mirror of https://github.com/boostorg/math.git synced 2026-01-19 04:22:09 +00:00

[ellint] try some different approximations for single-arg ellints.

This commit is contained in:
jzmaddock
2014-12-30 13:25:25 +00:00
parent 669214556a
commit 25b3ffa9da

View File

@@ -194,42 +194,13 @@ boost::math::ntl::RR f(const boost::math::ntl::RR& x, int variant)
case 13:
// K(k):
{
// x = k^2
boost::math::ntl::RR k2 = x;
if(k2 > boost::math::ntl::RR(1) - 1e-40)
k2 = boost::math::ntl::RR(1) - 1e-40;
/*if(k < 1e-40)
k = 1e-40;*/
boost::math::ntl::RR p2 = boost::math::constants::pi<boost::math::ntl::RR>() / 2;
return (boost::math::ellint_1(sqrt(k2))) / (p2 - boost::math::log1p(-k2));
return boost::math::ellint_1(x);
}
case 14:
// K(k)
{
static double P[] =
{
1.38629436111989062502E0,
9.65735902811690126535E-2,
3.08851465246711995998E-2,
1.49380448916805252718E-2,
8.79078273952743772254E-3,
6.18901033637687613229E-3,
6.87489687449949877925E-3,
9.85821379021226008714E-3,
7.97404013220415179367E-3,
2.28025724005875567385E-3,
1.37982864606273237150E-4
};
// x = 1 - k^2
boost::math::ntl::RR mp = x;
if(mp < 1e-20)
mp = 1e-20;
if(mp == 1)
mp -= 1e-20;
boost::math::ntl::RR k = sqrt(1 - mp);
return (boost::math::ellint_1(k) - mp/*boost::math::tools::evaluate_polynomial(P, mp)*/) / -log(mp);
}
return boost::math::ellint_1(1-x) / log(x);
}
case 15:
// E(k)
{