1 ///////////////////////////////////////////////////////////////////////////////
2 // Copyright 2014 Anton Bikineev
3 // Copyright 2014 Christopher Kormanyos
4 // Copyright 2014 John Maddock
5 // Copyright 2014 Paul Bristow
6 // Distributed under the Boost
7 // Software License, Version 1.0. (See accompanying file
8 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
10 #ifndef BOOST_MATH_HYPERGEOMETRIC_SEPARATED_SERIES_HPP
11 #define BOOST_MATH_HYPERGEOMETRIC_SEPARATED_SERIES_HPP
13 namespace boost { namespace math { namespace detail {
15 template <class T, class Policy>
16 inline T hypergeometric_1F1_separated_series(const T& a, const T& b, const T& z, const Policy& pol)
20 boost::uintmax_t max_iter = policies::get_max_series_iterations<Policy>();
21 const T factor = policies::get_epsilon<T, Policy>();
23 T denom = 1, numer = 1;
24 T intermediate_result = 1, result = 1;
25 T a_pochhammer = a, z_pow = z;
30 const T mult = (((b + N) - 1) * N);
31 denom *= mult; numer *= mult;
32 numer += a_pochhammer * z_pow;
34 result = numer / denom;
36 if (fabs(factor * result) > fabs(result - intermediate_result))
39 intermediate_result = result;
41 a_pochhammer *= (a + N);
50 #endif // BOOST_MATH_HYPERGEOMETRIC_SEPARATED_SERIES_HPP