Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Elliptic Integrals of the First Kind - Legendre Form

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

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

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

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

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

}} // namespaces
Description

These two functions evaluate the incomplete elliptic integral of the first kind F(φ, k) and its complete counterpart K(k) = F(π/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_1(T1 k, T2 phi);

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

Returns the incomplete elliptic integral of the first kind F(φ, k):

Requires k2sin2(phi) < 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_1(T k);

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

Returns the complete elliptic integral of the first kind K(k):

Requires |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 8.63. Error rates for ellint_1

GNU C++ version 7.1.0
linux
long double

GNU C++ version 7.1.0
linux
double

Sun compiler version 0x5150
Sun Solaris
long double

Microsoft Visual C++ version 14.1
Win32
double

Elliptic Integral F: Mathworld Data

Max = 0.94ε (Mean = 0.509ε)

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

Max = 0ε (Mean = 0ε)

(GSL 2.1: Max = 0.919ε (Mean = 0.544ε))

Max = 0.94ε (Mean = 0.509ε)

Max = 0.919ε (Mean = 0.542ε)

Elliptic Integral F: Random Data

Max = 1.57ε (Mean = 0.56ε)

(<cmath>: Max = 2.56ε (Mean = 0.816ε))

Max = 0ε (Mean = 0ε)

(GSL 2.1: Max = 2.99ε (Mean = 0.797ε))

Max = 1.57ε (Mean = 0.561ε)

Max = 2.26ε (Mean = 0.631ε)


The following error plot are based on an exhaustive search of the functions domain, MSVC-15.5 at double precision, and GCC-7.1/Ubuntu for long double and __float128.

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

For up to 80-bit long double precision the complete versions of these functions are implemented as Taylor series expansions as in: "Fast computation of complete elliptic integrals and Jacobian elliptic functions", Celestial Mechanics and Dynamical Astronomy, April 2012.

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

and


PrevUpHomeNext