NAG Library Routine Document

s21caf  (jacellip_real)

 Contents

    1  Purpose
    7  Accuracy

1
Purpose

s21caf evaluates the Jacobian elliptic functions sn, cn and dn.

2
Specification

Fortran Interface
Subroutine s21caf ( u, m, sn, cn, dn, ifail)
Integer, Intent (Inout):: ifail
Real (Kind=nag_wp), Intent (In):: u, m
Real (Kind=nag_wp), Intent (Out):: sn, cn, dn
C Header Interface
#include nagmk26.h
void  s21caf_ ( const double *u, const double *m, double *sn, double *cn, double *dn, Integer *ifail)

3
Description

s21caf evaluates the Jacobian elliptic functions of argument u and argument m,
snum = sinϕ, cnum = cosϕ, dnum = 1-msin2ϕ,  
where ϕ, called the amplitude of u, is defined by the integral
u=0ϕdθ 1-msin2θ .  
The elliptic functions are sometimes written simply as snu, cnu and dnu, avoiding explicit reference to the argument m.
Another nine elliptic functions may be computed via the formulae
cdu = cnu/dnu sdu = snu/dnu ndu = 1/dnu dcu = dnu/cnu ncu = 1/cnu scu = snu/cnu nsu = 1/snu dsu = dnu/snu csu = cnu/snu  
(see Abramowitz and Stegun (1972)).
s21caf is based on a procedure given by Bulirsch (1960), and uses the process of the arithmetic-geometric mean (16.9 in Abramowitz and Stegun (1972)). Constraints are placed on the values of u and m in order to avoid the possibility of machine overflow.

4
References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Bulirsch R (1960) Numerical calculation of elliptic integrals and elliptic functions Numer. Math. 7 76–90

5
Arguments

1:     u – Real (Kind=nag_wp)Input
2:     m – Real (Kind=nag_wp)Input
On entry: the argument u and the argument m of the functions, respectively.
Constraints:
  • absu λ , where λ = 1 / x02amf;
  • if absu < 1 / λ , absm λ .
3:     sn – Real (Kind=nag_wp)Output
4:     cn – Real (Kind=nag_wp)Output
5:     dn – Real (Kind=nag_wp)Output
On exit: the values of the functions snu, cnu and dnu, respectively.
6:     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,absu>λ, where λ=1/x02amf.
ifail=2
On entry,absm>λ and absu<1/λ.
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 SIN and COS.

8
Parallelism and Performance

s21caf is not threaded in any implementation.

9
Further Comments

None.

10
Example

This example reads values of the argument u and argument m from a file, evaluates the function and prints the results.

10.1
Program Text

Program Text (s21cafe.f90)

10.2
Program Data

Program Data (s21cafe.d)

10.3
Program Results

Program Results (s21cafe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017