NAG FL Interface
s21ccf (jactheta_​real)

Settings help

FL Name Style:

FL Specification Language:

1 Purpose

s21ccf returns the value of one of the Jacobian theta functions θ0(x,q), θ1(x,q), θ2(x,q), θ3(x,q) or θ4(x,q) for a real argument x and non-negative q<1, via the function name.

2 Specification

Fortran Interface
Function s21ccf ( k, x, q, ifail)
Real (Kind=nag_wp) :: s21ccf
Integer, Intent (In) :: k
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: x, q
C Header Interface
#include <nag.h>
double  s21ccf_ (const Integer *k, const double *x, const double *q, Integer *ifail)
The routine may be called by the names s21ccf or nagf_specfun_jactheta_real.

3 Description

s21ccf evaluates an approximation to the Jacobian theta functions θ0(x,q), θ1(x,q), θ2(x,q), θ3(x,q) and θ4(x,q) given by
θ0(x,q) = 1+2n=1(-1)nqn2cos(2nπx), θ1(x,q) = 2n=0(-1)nq (n+12) 2sin{(2n+1)πx}, θ2(x,q) = 2n=0q (n+12) 2cos{(2n+1)πx}, θ3(x,q) = 1+2n=1qn2cos(2nπx), θ4(x,q) = θ0(x,q),  
where x and q (the nome) are real with 0q<1.
These functions are important in practice because every one of the Jacobian elliptic functions (see s21cbf) can be expressed as the ratio of two Jacobian theta functions (see Whittaker and Watson (1990)). There is also a bewildering variety of notations used in the literature to define them. Some authors (e.g., Section 16.27 of Abramowitz and Stegun (1972)) define the argument in the trigonometric terms to be x instead of πx. This can often lead to confusion, so great care must, therefore, be exercised when consulting the literature. Further details (including various relations and identities) can be found in the references.
s21ccf is based on a truncated series approach. If t differs from x or -x by an integer when 0t12 , it follows from the periodicity and symmetry properties of the functions that θ1(x,q)=±θ1(t,q) and θ3(x,q)=±θ3(t,q). In a region for which the approximation is sufficiently accurate, θ1 is set equal to the first term (n=0) of the transformed series
θ1(t,q)=2λπe-λt2n=0(-1)ne-λ (n+12) 2sinh{(2n+1)λt}  
and θ3 is set equal to the first two terms (i.e., n1) of
θ3(t,q)=λπe-λt2 {1+2n=1e-λn2cosh(2nλt)} ,  
where λ= π2/ |logeq| . Otherwise, the trigonometric series for θ1(t,q) and θ3(t,q) are used. For all values of x, θ0 and θ2 are computed from the relations θ0(x,q)=θ3(12-|x|,q) and θ2(x,q)=θ1(12-|x|,q).

4 References

Abramowitz M and Stegun I A (1972) Handbook of Mathematical Functions (3rd Edition) Dover Publications
Byrd P F and Friedman M D (1971) Handbook of Elliptic Integrals for Engineers and Scientists pp. 315–320 (2nd Edition) Springer–Verlag
Magnus W, Oberhettinger F and Soni R P (1966) Formulas and Theorems for the Special Functions of Mathematical Physics 371–377 Springer–Verlag
Tølke F (1966) Praktische Funktionenlehre (Bd. II) 1–38 Springer–Verlag
Whittaker E T and Watson G N (1990) A Course in Modern Analysis (4th Edition) Cambridge University Press

5 Arguments

1: k Integer Input
On entry: denotes the function θk(x,q) to be evaluated. Note that k=4 is equivalent to k=0.
Constraint: 0k4.
2: x Real (Kind=nag_wp) Input
On entry: the argument x of the function.
3: q Real (Kind=nag_wp) Input
On entry: the argument q of the function.
Constraint: 0.0q<1.0.
4: 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:
On entry, k=value.
Constraint: k4.
On entry, k=value.
Constraint: k0.
On entry, q=value.
Constraint: q<1.0.
On entry, q=value.
Constraint: q0.0.
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.
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.
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

Background information to multithreading can be found in the Multithreading documentation.
s21ccf is not threaded in any implementation.

9 Further Comments


10 Example

This example evaluates θ2(x,q) at x=0.7 when q=0.4, and prints the results.

10.1 Program Text

Program Text (s21ccfe.f90)

10.2 Program Data

Program Data (s21ccfe.d)

10.3 Program Results

Program Results (s21ccfe.r)