From 25b3ffa9da1fd12908d25533f321003162eaeacd Mon Sep 17 00:00:00 2001 From: jzmaddock Date: Tue, 30 Dec 2014 13:25:25 +0000 Subject: [PATCH] [ellint] try some different approximations for single-arg ellints. --- minimax/f.cpp | 35 +++-------------------------------- 1 file changed, 3 insertions(+), 32 deletions(-) diff --git a/minimax/f.cpp b/minimax/f.cpp index 74ff97638..cc52b1fcc 100644 --- a/minimax/f.cpp +++ b/minimax/f.cpp @@ -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() / 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) {