NAG Library Routine Document

s21daf (ellipint_general_2)

1
Purpose

s21daf returns the value of the general elliptic integral of the second kind Fz,k,a,b for a complex argument z, via the function name.

2
Specification

Fortran Interface
Function s21daf ( z, akp, a, b, ifail)
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
C Header Interface
#include <nagmk26.h>
Complex  s21daf_ (const Complex *z, const double *akp, const double *a, const double *b, Integer *ifail)

3
Description

s21daf evaluates an approximation to the general elliptic integral of the second kind Fz,k,a,b given by
Fz,k,a,b=0za+bζ2 1+ζ21+ζ21+k2ζ2 dζ,  
where a and b are real arguments, z is a complex argument whose real part is non-negative and k 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 F1z,k (the elliptic integral of the first kind) and
Fz,k,1,k2=0z1+k2ζ2 1+ζ21+ζ2 dζ,  
or F2z,k (the elliptic integral of the second kind). Note that the values of F1z,k and F2z,k are equal to tan-1z in the trivial case k=1.
s21daf is derived from an Algol 60 procedure given by Bulirsch (1960). Constraints are placed on the values of z and k in order to avoid the possibility of machine overflow.

4
References

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

5
Arguments

1:     z – Complex (Kind=nag_wp)Input
On entry: the argument z of the function.
Constraints:
  • 0.0Re(z)λ;
  • absIm(z)λ, where λ6=1/x02amf.
2:     akp – Real (Kind=nag_wp)Input
On entry: the argument k of the function.
Constraint: absakp λ .
3:     a – Real (Kind=nag_wp)Input
On entry: the argument a of the function.
4:     b – Real (Kind=nag_wp)Input
On entry: the argument b of the function.
5:     ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1 or 1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1 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 argument, the recommended value is 0. When the value -1 or 1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry 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:
ifail=1
On entry, akp is too large: akp=value. It must not exceed value.
On entry, Im(z) is too large: Im(z)=value. It must not exceed value.
On entry, Re(z)<0.0: Re(z)=value.
On entry, Re(z) is too large: Re(z)=value. It must not exceed value.
ifail=2
The iterative procedure used to evaluate the integral has failed to converge.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation 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.

8
Parallelism and Performance

s21daf is not threaded in any implementation.

9
Further Comments

None.

10
Example

This example evaluates the elliptic integral of the first kind F1z,k given by
F1z,k=0zdζ 1+ζ21+k2ζ2 ,  
where z=1.2+3.7i and k=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)