| Home | Libraries | People | FAQ | More

### Elliptic Integrals of the Third Kind - Legendre Form

##### Synopsis

    #include <boost/math/special_functions/ellint_3.hpp>

    namespace boost { namespace math {

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

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

    template <class T1, class T2>
    calculated-result-type ellint_3(T1 k, T2 n);

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

    }} // namespaces

##### Description

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

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

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

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

Returns the incomplete elliptic integral of the third kind Π(n, φ, k):

Requires k2sin2(phi) < 1 and n < 1/sin2(φ), otherwise returns the result of domain_error (outside this range the result would be complex).

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 T1, class T2>
    calculated-result-type ellint_3(T1 k, T2 n);

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

Returns the complete elliptic integral of the first kind Π(n, k):

Requires |k| < 1 and n < 1, otherwise returns the result of domain_error (outside this range the result would be complex).

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.65. Error rates for ellint_3

| 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 PI: Mathworld Data | Max = 475ε (Mean = 86.3ε) (<cmath>: Max = +INFε (Mean = +INFε) And other failures.) | Max = 0ε (Mean = 0ε) (GSL 2.1: Max = 1.48e+05ε (Mean = 2.54e+04ε) And other failures.) | Max = 475ε (Mean = 86.3ε) | Max = 565ε (Mean = 102ε)
Elliptic Integral PI: Random Data | Max = 4.54ε (Mean = 0.895ε) (<cmath>: Max = 3.37e+20ε (Mean = 3.47e+19ε) And other failures.) | Max = 0ε (Mean = 0ε) (GSL 2.1: Max = 633ε (Mean = 50.1ε)) | Max = 4.49ε (Mean = 0.885ε) | Max = 8.33ε (Mean = 0.971ε)
Elliptic Integral PI: Large Random Data | Max = 3.7ε (Mean = 0.893ε) (<cmath>: Max = 2.52e+18ε (Mean = 4.83e+17ε) And other failures.) | Max = 0.557ε (Mean = 0.0389ε) (GSL 2.1: Max = 40.1ε (Mean = 7.77ε)) | Max = 3.7ε (Mean = 0.892ε) | Max = 2.86ε (Mean = 0.944ε)

##### 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

The implementation for Π(n, φ, k) first siphons off the special cases:

> Π(0, φ, k) = F(φ, k)

> Π(n, π/2, k) = Π(n, k)

and

Then if n < 0 the relations (A&S 17.7.15/16):

are used to shift n to the range [0, 1].

Then the relations:

> Π(n, -φ, k) = -Π(n, φ, k)

> Π(n, φ+mπ, k) = Π(n, φ, k) + 2mΠ(n, k) ; n <= 1

> Π(n, φ+mπ, k) = Π(n, φ, k) ; n > 1 [4]

are used to move φ to the range [0, π/2].

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

and

[4] I haven't been able to find a literature reference for this relation, but it appears to be the convention used by Mathematica. Intuitively the first 2 * m * Π(n, k) terms cancel out as the derivative alternates between +∞ and -∞.