# NAG FL Interfaces21daf (ellipint_​general_​2)

## ▸▿ Contents

Settings help

FL Name Style:

FL Specification Language:

## 1Purpose

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.

## 2Specification

Fortran Interface
 Function s21daf ( z, akp, a, b,
 Complex (Kind=nag_wp) :: s21daf Integer, Intent (Inout) :: ifail Real (Kind=nag_wp), Intent (In) :: akp, a, b Complex (Kind=nag_wp), Intent (In) :: z
#include <nag.h>
 Complex s21daf_ (const Complex *z, const double *akp, const double *a, const double *b, Integer *ifail)
The routine may be called by the names s21daf or nagf_specfun_ellipint_general_2.

## 3Description

s21daf evaluates an approximation to the general elliptic integral of the second kind $F\left(z,{k}^{\prime },a,b\right)$ given by
 $F(z,k′,a,b)=∫0za+bζ2 (1+ζ2)(1+ζ2)(1+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
 $F(z,k′,1,k′2)=∫0z1+k′2ζ2 (1+ζ2)1+ζ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

## 5Arguments

1: $\mathbf{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: $\mathbf{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: $\mathbf{a}$Real (Kind=nag_wp) Input
On entry: the argument $a$ of the function.
4: $\mathbf{b}$Real (Kind=nag_wp) Input
On entry: the argument $b$ of the function.
5: $\mathbf{ifail}$Integer Input/Output
On entry: ifail must be set to $0$, $-1$ or $1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $-1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value $-1$ or $1$ is recommended. If message printing is undesirable, then the value $1$ is recommended. Otherwise, the value $0$ is recommended. When the value $-\mathbf{1}$ 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).

## 6Error Indicators and Warnings

If on entry ${\mathbf{ifail}}=0$ or $-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, $|{\mathbf{akp}}|$ is too large: $|{\mathbf{akp}}|=⟨\mathit{\text{value}}⟩$. It must not exceed $⟨\mathit{\text{value}}⟩$.
On entry, $|\mathrm{Im}\left({\mathbf{z}}\right)|$ is too large: $|\mathrm{Im}\left({\mathbf{z}}\right)|=⟨\mathit{\text{value}}⟩$. It must not exceed $⟨\mathit{\text{value}}⟩$.
On entry, $\mathrm{Re}\left({\mathbf{z}}\right)<0.0$: $\mathrm{Re}\left({\mathbf{z}}\right)=⟨\mathit{\text{value}}⟩$.
On entry, $\mathrm{Re}\left({\mathbf{z}}\right)$ is too large: $\mathrm{Re}\left({\mathbf{z}}\right)=⟨\mathit{\text{value}}⟩$. It must not exceed $⟨\mathit{\text{value}}⟩$.
${\mathbf{ifail}}=2$
The iterative procedure used to evaluate the integral has failed to converge.
${\mathbf{ifail}}=-99$
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-399$
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
${\mathbf{ifail}}=-999$
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.

## 7Accuracy

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.

## 8Parallelism and Performance

s21daf is not threaded in any implementation.

None.

## 10Example

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

### 10.1Program Text

Program Text (s21dafe.f90)

### 10.2Program Data

Program Data (s21dafe.d)

### 10.3Program Results

Program Results (s21dafe.r)