Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

Chapter Contents
Chapter Introduction
NAG Toolbox

# NAG Toolbox: nag_specfun_ellipint_complete_2 (s21bj)

## Purpose

nag_specfun_ellipint_complete_2 (s21bj) returns a value of the classical (Legendre) form of the complete elliptic integral of the second kind, via the function name.

## Syntax

[result, ifail] = s21bj(dm)
[result, ifail] = nag_specfun_ellipint_complete_2(dm)

## Description

nag_specfun_ellipint_complete_2 (s21bj) calculates an approximation to the integral
 $Em = ∫0 π2 1-m sin2⁡θ 12 dθ ,$
where $m\le 1$.
The integral is computed using the symmetrised elliptic integrals of Carlson (Carlson (1979) and Carlson (1988)). The relevant identity is
 $Em = RF 0,1-m,1 - 13 mRD 0,1-m,1 ,$
where ${R}_{F}$ is the Carlson symmetrised incomplete elliptic integral of the first kind (see nag_specfun_ellipint_symm_1 (s21bb)) and ${R}_{D}$ is the Carlson symmetrised incomplete elliptic integral of the second kind (see nag_specfun_ellipint_symm_2 (s21bc)).

## References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Carlson B C (1979) Computing elliptic integrals by duplication Numerische Mathematik 33 1–16
Carlson B C (1988) A table of elliptic integrals of the third kind Math. Comput. 51 267–280

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{dm}$ – double scalar
The argument $m$ of the function.
Constraint: ${\mathbf{dm}}\le 1.0$.

None.

### Output Parameters

1:     $\mathrm{result}$ – double scalar
The result of the function.
2:     $\mathrm{ifail}$int64int32nag_int scalar
${\mathbf{ifail}}={\mathbf{0}}$ unless the function detects an error (see Error Indicators and Warnings).

## Error Indicators and Warnings

Errors or warnings detected by the function:
${\mathbf{ifail}}=1$
Constraint: ${\mathbf{dm}}\le 1.0$.
${\mathbf{ifail}}=-99$
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.

## Accuracy

In principle nag_specfun_ellipint_complete_2 (s21bj) is capable of producing full machine precision. However round-off errors in internal arithmetic will result in slight loss of accuracy. This loss should never be excessive as the algorithm does not involve any significant amplification of round-off error. It is reasonable to assume that the result is accurate to within a small multiple of the machine precision.

You should consult the S Chapter Introduction, which shows the relationship between this function and the Carlson definitions of the elliptic integrals. In particular, the relationship between the argument-constraints for both forms becomes clear.
For more information on the algorithms used to compute ${R}_{F}$ and ${R}_{D}$, see the function documents for nag_specfun_ellipint_symm_1 (s21bb) and nag_specfun_ellipint_symm_2 (s21bc), respectively.

## Example

This example simply generates a small set of nonextreme arguments that are used with the function to produce the table of results.
```function s21bj_example

fprintf('s21bj example results\n\n');

m = [0.25     0.5     0.75];
result = m;

for j=1:numel(m)
[result(j), ifail] = s21bj(m(j));
end

disp('      m        E(m)');
fprintf('%8.2f%12.4f\n',[m; result]);

```
```s21bj example results

m        E(m)
0.25      1.4675
0.50      1.3506
0.75      1.2111
```