1 // Copyright (c) 2015 John Maddock
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 #ifndef BOOST_MATH_ELLINT_JZ_HPP
8 #define BOOST_MATH_ELLINT_JZ_HPP
14 #include <boost/math/special_functions/math_fwd.hpp>
15 #include <boost/math/special_functions/ellint_1.hpp>
16 #include <boost/math/special_functions/ellint_rj.hpp>
17 #include <boost/math/constants/constants.hpp>
18 #include <boost/math/policies/error_handling.hpp>
19 #include <boost/math/tools/workaround.hpp>
21 // Elliptic integral the Jacobi Zeta function.
23 namespace boost { namespace math {
27 // Elliptic integral - Jacobi Zeta
28 template <typename T, typename Policy>
29 T jacobi_zeta_imp(T phi, T k, const Policy& pol)
32 using namespace boost::math::tools;
33 using namespace boost::math::constants;
49 result = sinp * (boost::math::sign)(cosp); // We get here by simplifying JacobiZeta[w, 1] in Mathematica, and the fact that 0 <= phi.
51 result = k2 * sinp * cosp * sqrt(1 - k2 * s2) * ellint_rj_imp(T(0), kp, T(1), T(1 - k2 * s2), pol) / (3 * ellint_k_imp(k, pol));
52 return invert ? T(-result) : result;
57 template <class T1, class T2, class Policy>
58 inline typename tools::promote_args<T1, T2>::type jacobi_zeta(T1 k, T2 phi, const Policy& pol)
60 typedef typename tools::promote_args<T1, T2>::type result_type;
61 typedef typename policies::evaluation<result_type, Policy>::type value_type;
62 return policies::checked_narrowing_cast<result_type, Policy>(detail::jacobi_zeta_imp(static_cast<value_type>(phi), static_cast<value_type>(k), pol), "boost::math::jacobi_zeta<%1%>(%1%,%1%)");
65 template <class T1, class T2>
66 inline typename tools::promote_args<T1, T2>::type jacobi_zeta(T1 k, T2 phi)
68 return boost::math::jacobi_zeta(k, phi, policies::policy<>());
73 #endif // BOOST_MATH_ELLINT_D_HPP