S21DAF (PDF version)
S Chapter Contents
S Chapter Introduction
NAG Library Manual

# NAG Library Routine DocumentS21DAF

Note:  before using this routine, please read the Users' Note for your implementation to check the interpretation of bold italicised terms and other implementation-dependent details.

## 1  Purpose

S21DAF 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.

## 2  Specification

 FUNCTION S21DAF ( Z, AKP, A, B, IFAIL)
 COMPLEX (KIND=nag_wp) S21DAF
 INTEGER IFAIL REAL (KIND=nag_wp) AKP, A, B COMPLEX (KIND=nag_wp) Z

## 3  Description

S21DAF 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 parameters, $z$ is a complex argument whose real part is non-negative and ${k}^{\prime }$ is a real parameter (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$.
S21DAF 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.
Bulirsch R (1960) Numerical calculation of elliptic integrals and elliptic functions Numer. Math. 7 76–90

## 5  Parameters

1:     $\mathrm{Z}$ – COMPLEX (KIND=nag_wp)Input
On entry: 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{X02AMF}}$.
2:     $\mathrm{AKP}$ – REAL (KIND=nag_wp)Input
On entry: the argument ${k}^{\prime }$ of the function.
Constraint: $\mathrm{abs}\left({\mathbf{AKP}}\right)\le \lambda$.
3:     $\mathrm{A}$ – REAL (KIND=nag_wp)Input
On entry: the argument $a$ of the function.
4:     $\mathrm{B}$ – REAL (KIND=nag_wp)Input
On entry: the argument $b$ of the function.
5:     $\mathrm{IFAIL}$ – INTEGERInput/Output
On entry: IFAIL must be set to $0$, $-1\text{​ or ​}1$. If you are unfamiliar with this parameter you should refer to Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value $-1\text{​ or ​}1$ is recommended. If the output of error messages is undesirable, then the value $1$ is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is $0$. When the value $-\mathbf{1}\text{​ or ​}\mathbf{1}$ is used it is essential to test the value of IFAIL on exit.
On exit: ${\mathbf{IFAIL}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see Section 6).

## 6  Error Indicators and Warnings

If on entry ${\mathbf{IFAIL}}={\mathbf{0}}$ or $-{\mathbf{1}}$, explanatory error messages are output on the current error message unit (as defined by X04AAF).
Errors or warnings detected by the routine:
${\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{X02AMF}}$.
${\mathbf{IFAIL}}=2$
The iterative procedure used to evaluate the integral has failed to converge. The result is returned as zero.
${\mathbf{IFAIL}}=-99$
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.8 in the Essential Introduction for further information.
${\mathbf{IFAIL}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 3.7 in the Essential Introduction for further information.
${\mathbf{IFAIL}}=-999$
Dynamic memory allocation failed.
See Section 3.6 in the Essential Introduction for further information.

## 7  Accuracy

In principle the routine 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.

Not applicable.

None.

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

### 10.1  Program Text

Program Text (s21dafe.f90)

### 10.2  Program Data

Program Data (s21dafe.d)

### 10.3  Program Results

Program Results (s21dafe.r)

S21DAF (PDF version)
S Chapter Contents
S Chapter Introduction
NAG Library Manual