NAG FL Interface
s21cbf (jacellip_​complex)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

s21cbf evaluates the Jacobian elliptic functions snz, cnz and dnz for a complex argument z.

2 Specification

Fortran Interface
Subroutine s21cbf ( z, ak2, sn, cn, dn, ifail)
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: ak2
Complex (Kind=nag_wp), Intent (In) :: z
Complex (Kind=nag_wp), Intent (Out) :: sn, cn, dn
C Header Interface
#include <nag.h>
void  s21cbf_ (const Complex *z, const double *ak2, Complex *sn, Complex *cn, Complex *dn, Integer *ifail)
The routine may be called by the names s21cbf or nagf_specfun_jacellip_complex.

3 Description

s21cbf evaluates the Jacobian elliptic functions sn(zk), cn(zk) and dn(zk) given by
sn(zk) = sinϕ cn(zk) = cosϕ dn(zk) = 1-k2sin2ϕ,  
where z is a complex argument, k is a real argument (the modulus) with k21 and ϕ (the amplitude of z) is defined by the integral
z=0ϕdθ 1-k2sin2θ .  
The above definitions can be extended for values of k2>1 (see Salzer (1962)) by means of the formulae
sn(zk) = k1sn(kzk1) cn(zk) = dn(kzk1) dn(zk) = cn(kzk1),  
where k1=1/k.
Special values include
sn(z0) = sinz cn(z0) = cosz dn(z0) = 1 sn(z1) = tanhz cn(z1) = sechz dn(z1) = sechz.  
These functions are often simply written as snz, cnz and dnz, thereby avoiding explicit reference to the argument k. They can also be expressed in terms of Jacobian theta functions (see s21ccf).
Another nine elliptic functions may be computed via the formulae
cdz = cnz/dnz sdz = snz/dnz ndz = 1/dnz dcz = dnz/cnz ncz = 1/cnz scz = snz/cnz nsz = 1/snz dsz = dnz/snz csz = cnz/snz  
(see Abramowitz and Stegun (1972)).
The values of snz, cnz and dnz are obtained by calls to s21caf. Further details can be found in Section 9.

4 References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Salzer H E (1962) Quick calculation of Jacobian elliptic functions Comm. ACM 5 399

5 Arguments

1: z Complex (Kind=nag_wp) Input
On entry: the argument z of the functions.
Constraints:
  • abs(Re(z))=λ;
  • abs(Im(z))λ, where λ=1/x02amf.
2: ak2 Real (Kind=nag_wp) Input
On entry: the value of k2.
Constraint: 0.0ak21.0.
3: sn Complex (Kind=nag_wp) Output
4: cn Complex (Kind=nag_wp) Output
5: dn Complex (Kind=nag_wp) Output
On exit: the values of the functions snz, cnz and dnz, respectively.
6: 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 -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, |Im(z)| is too large: |Im(z)|=value. It must be less than value.
On entry, |Re(z)| is too large: |Re(z)|=value. It must be less than value.
On entry, ak2=value.
Constraint: ak21.0.
On entry, ak2=value.
Constraint: ak20.0.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
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.
ifail=-999
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface 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

s21cbf is not threaded in any implementation.

9 Further Comments

The values of snz, cnz and dnz are computed via the formulae
snz = sn(u,k)dn(v,k) 1-dn2(u,k)sn2(v,k) + i cn(u,k)dn(u,k)sn(v,k)cn(v,k) 1-dn2(u,k)sn2(v,k) cnz = cn(u,k)cn(v,k) 1-dn2(u,k)sn2(v,k) - i sn(u,k)dn(u,k)sn(v,k)dn(v,k) 1-dn2(u,k)sn2(v,k) dnz = dn(u,k)cn(v,k)dn(v,k) 1-dn2(u,k)sn2(v,k) - i k2sn(u,k)cn(u,k)sn(v,k) 1-dn2(u,k)sn2(v,k) ,  
where z=u+iv and k=1-k2 (the complementary modulus).

10 Example

This example evaluates snz, cnz and dnz at z=-2.0+3.0i when k=0.5, and prints the results.

10.1 Program Text

Program Text (s21cbfe.f90)

10.2 Program Data

Program Data (s21cbfe.d)

10.3 Program Results

Program Results (s21cbfe.r)