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_general_2 (s21da)

## Purpose

nag_specfun_ellipint_general_2 (s21da) returns the value of the general elliptic integral of the second kind $F\left(z,{k}^{\prime },a,b\right)$ for a complex argument $z$, via the function name.

## Syntax

[result, ifail] = s21da(z, akp, a, b)
[result, ifail] = nag_specfun_ellipint_general_2(z, akp, a, b)

## Description

nag_specfun_ellipint_general_2 (s21da) evaluates an approximation to the general elliptic integral of the second kind $F\left(z,{k}^{\prime },a,b\right)$ given by
 $Fz,k′,a,b=∫0za+bζ2 1+ζ21+ζ21+k′2ζ2 dζ,$
where $a$ and $b$ are real arguments, $z$ is a complex argument whose real part is non-negative and ${k}^{\prime }$ is a real argument (the complementary modulus). The evaluation of $F$ is based on the Gauss transformation. Further details, in particular for the conformal mapping provided by $F$, can be found in Bulirsch (1960).
Special values include
 $F z, k ′ ,1,1 = ∫ 0 z d ζ 1 + ζ 2 1 + k′ 2 ζ 2 ,$
or ${F}_{1}\left(z,{k}^{\prime }\right)$ (the elliptic integral of the first kind) and
 $Fz,k′,1,k′2=∫0z1+k′2ζ2 1+ζ21+ζ2 dζ,$
or ${F}_{2}\left(z,{k}^{\prime }\right)$ (the elliptic integral of the second kind). Note that the values of ${F}_{1}\left(z,{k}^{\prime }\right)$ and ${F}_{2}\left(z,{k}^{\prime }\right)$ are equal to ${\mathrm{tan}}^{-1}\left(z\right)$ in the trivial case ${k}^{\prime }=1$.
nag_specfun_ellipint_general_2 (s21da) is derived from an Algol 60 procedure given by Bulirsch (1960). Constraints are placed on the values of $z$ and ${k}^{\prime }$ in order to avoid the possibility of machine overflow.

## References

Bulirsch R (1960) Numerical calculation of elliptic integrals and elliptic functions Numer. Math. 7 76–90

## Parameters

### Compulsory Input Parameters

1:     $\mathrm{z}$ – complex scalar
The argument $z$ of the function.
Constraints:
• $0.0\le \mathrm{Re}\left({\mathbf{z}}\right)\le \lambda$;
• $\mathrm{abs}\left(\mathrm{Im}\left({\mathbf{z}}\right)\right)\le \lambda$, where ${\lambda }^{6}=1/{\mathbf{x02am}}$.
2:     $\mathrm{akp}$ – double scalar
The argument ${k}^{\prime }$ of the function.
Constraint: $\mathrm{abs}\left({\mathbf{akp}}\right)\le \lambda$.
3:     $\mathrm{a}$ – double scalar
The argument $a$ of the function.
4:     $\mathrm{b}$ – double scalar
The argument $b$ of the function.

None.

### Output Parameters

1:     $\mathrm{result}$ – complex 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$
 On entry, $\mathrm{Re}\left({\mathbf{z}}\right)<0.0$, or $\mathrm{Re}\left({\mathbf{z}}\right)>\lambda$, or $\left|\mathrm{Im}\left({\mathbf{z}}\right)\right|>\lambda$, or $\left|{\mathbf{akp}}\right|>\lambda$, where ${\lambda }^{6}=1/{\mathbf{x02am}}$.
${\mathbf{ifail}}=2$
The iterative procedure used to evaluate the integral has failed to converge. The result is returned as zero.
${\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 the function is capable of achieving full relative precision in the computed values. However, the accuracy obtainable in practice depends on the accuracy of the standard elementary functions such as atan2 and log.

None.

## Example

This example evaluates the elliptic integral of the first kind ${F}_{1}\left(z,{k}^{\prime }\right)$ given by
 $F1z,k′=∫0zdζ 1+ζ21+k′2ζ2 ,$
where $z=1.2+3.7i$ and ${k}^{\prime }=0.5$, and prints the results.
```function s21da_example

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

z =  1.2 + 3.7i;
kp = 0.5;
a = 1;
b = 1;

[result, ifail] = s21da(z, kp, a, b);

fprintf('%6s%13s%7s%7s%18s\n','z','k''','a','b','F(z,k'',a,b)');
fprintf('%5.1f%+5.1fi  %7.2f%7.2f%7.2f%10.5f%+10.5fi\n', real(z), imag(z), ...
kp, a, b, real(result), imag(result));

```
```s21da example results

z           k'      a      b       F(z,k',a,b)
1.2 +3.7i     0.50   1.00   1.00   1.97126  +0.50538i
```