Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Elliptic Integrals of the Second Kind - Legendre Form

Synopsis
#include <boost/math/special_functions/ellint_2.hpp>
namespace boost { namespace math {

template <class T1, class T2>
calculated-result-type ellint_2(T1 k, T2 phi);

template <class T1, class T2, class Policy>
calculated-result-type ellint_2(T1 k, T2 phi, const Policy&);

template <class T>
calculated-result-type ellint_2(T k);

template <class T, class Policy>
calculated-result-type ellint_2(T k, const Policy&);

}} // namespaces
Description

These two functions evaluate the incomplete elliptic integral of the second kind E(φ, k) and its complete counterpart E(k) = E(π/2, k).

The return type of these functions is computed using the result type calculation rules when T1 and T2 are different types: when they are the same type then the result is the same type as the arguments.

template <class T1, class T2>
calculated-result-type ellint_2(T1 k, T2 phi);

template <class T1, class T2, class Policy>
calculated-result-type ellint_2(T1 k, T2 phi, const Policy&);

Returns the incomplete elliptic integral of the second kind E(φ, k):

Requires -1 <= k <= 1, otherwise returns the result of domain_error.

The final Policy argument is optional and can be used to control the behaviour of the function: how it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

template <class T>
calculated-result-type ellint_2(T k);

template <class T>
calculated-result-type ellint_2(T k, const Policy&);

Returns the complete elliptic integral of the second kind E(k):

Requires -1 <= k <= 1, otherwise returns the result of domain_error.

The final Policy argument is optional and can be used to control the behaviour of the function: how it handles errors, what level of precision to use etc. Refer to the policy documentation for more details.

Accuracy

These functions are computed using only basic arithmetic operations, so there isn't much variation in accuracy over differing platforms. Note that only results for the widest floating point type on the system are given as narrower types have effectively zero error. All values are relative errors in units of epsilon.

Table 6.64. Error rates for ellint_2

Microsoft Visual C++ version 12.0
Win32
double

GNU C++ version 5.1.0
linux
long double

GNU C++ version 5.1.0
linux
double

Sun compiler version 0x5130
Sun Solaris
long double

Elliptic Integral E: Mathworld Data

Max = 1.31ε (Mean = 0.727ε)

Max = 0.656ε (Mean = 0.317ε)

(<tr1/cmath>: Max = +INFε (Mean = +INFε) And other failures.)

Max = 0ε (Mean = 0ε)

(GSL 1.16: Max = 0.63ε (Mean = 0.325ε))
(Cephes: Max = +INFε (Mean = +INFε) And other failures.)

Max = 0.656ε (Mean = 0.317ε)

Elliptic Integral E: Random Data

Max = 2.23ε (Mean = 0.639ε)

Max = 2.05ε (Mean = 0.632ε)

(<tr1/cmath>: Max = 3.08e+04ε (Mean = 3.84e+03ε))

Max = 0ε (Mean = 0ε)

(GSL 1.16: Max = 4.4ε (Mean = 1.16ε))
(Cephes: Max = 8.92ε (Mean = 1.48ε))

Max = 2.05ε (Mean = 0.632ε)


Testing

The tests use a mixture of spot test values calculated using the online calculator at functions.wolfram.com, and random test data generated using NTL::RR at 1000-bit precision and this implementation.

Implementation

These functions are implemented in terms of Carlson's integrals using the relations:

and


PrevUpHomeNext