NAG FL Interface
s22caf (mathieu_​ang_​periodic_​real)

Settings help

FL Name Style:


FL Specification Language:


1 Purpose

s22caf calculates real-valued periodic angular Mathieu functions (cem(x,q) or sem(x,q)) and/or their first derivatives, where cem(x,q) and sem(x,q) are solutions to the Mathieu differential equation d2y dx2 + [a-2qcos(2x)] y =0 .

2 Specification

Fortran Interface
Subroutine s22caf ( ordval, q, parity, mode, n, x, f, f_deriv, a, ifail)
Integer, Intent (In) :: ordval, parity, mode, n
Integer, Intent (Inout) :: ifail
Real (Kind=nag_wp), Intent (In) :: q, x(n)
Real (Kind=nag_wp), Intent (Out) :: f(n), f_deriv(n), a
C Header Interface
#include <nag.h>
void  s22caf_ (const Integer *ordval, const double *q, const Integer *parity, const Integer *mode, const Integer *n, const double x[], double f[], double f_deriv[], double *a, Integer *ifail)
The routine may be called by the names s22caf or nagf_specfun_mathieu_ang_periodic_real.

3 Description

s22caf calculates an approximation to cem(x,q) and/or cem(x,q), or sem(x,q) and/or sem(x,q), where cem(x,q) and sem(x,q) are respectively the even and odd parity real-valued periodic angular Mathieu functions, for an array of values of x, and for integer order value m, where m0 for even parity, and m1 for odd parity. The routine also returns values of a for these periodic Mathieu functions, this is known as the characteristic value or eigenvalue.
The solutions are computed by approximating Mathieu functions as Fourier series, where expansion coefficients are obtained by solving the eigenvalue problem generated from the relevant recurrence relation, see Chapter 28 in NIST Digital Library of Mathematical Functions.

4 References

NIST Digital Library of Mathematical Functions

5 Arguments

1: ordval Integer Input
On entry: m, the order number of the Mathieu function to be computed.
Constraints:
  • if parity=0 (even Mathieu function), ordval0;
  • if parity=1 (odd Mathieu function), ordval1.
2: q Real (Kind=nag_wp) Input
On entry: q, the Mathieu function parameter.
3: parity Integer Input
On entry: specifies whether to compute even or odd Mathieu function.
parity=0
Compute even Mathieu function, cem(x,q).
parity=1
Compute odd Mathieu function, sem(x,q).
Constraint: parity=0 or 1.
4: mode Integer Input
On entry: specifies whether the Mathieu function or its derivative is required.
mode=0
Compute Mathieu function values.
mode=1
Compute derivative values of Mathieu function.
mode=2
Compute both Mathieu function and derivative values.
mode=3
Compute neither Mathieu functions nor derivative values, returns only a (the characteristic value).
Constraint: mode=0, 1, 2 or 3.
5: n Integer Input
On entry: n, the number of values to compute.
Constraint: n0.
6: x(n) Real (Kind=nag_wp) array Input
On entry: the values of x at which to compute Mathieu function or derivative values.
7: f(n) Real (Kind=nag_wp) array Output
On exit: if mode=0 or 2, the Mathieu function values cem(x,q) or sem(x,q). If mode=1 or 3, f is not used.
8: f_deriv(n) Real (Kind=nag_wp) array Output
On exit: if mode=1 or 2, the Mathieu function derivative values cem(x,q) or sem(x,q). If mode=0 or 3, f_deriv is not used.
9: a Real (Kind=nag_wp) Output
On exit: a, the characteristic value for the Mathieu function.
10: 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, ordval=value and parity=value.
Constraint: if parity=0, ordval0 or if parity=1, ordval1.
ifail=2
On entry, parity=value.
Constraint: parity=0 or 1.
ifail=3
On entry, mode=value.
Constraint: mode=0, 1, 2 or 3.
ifail=4
On entry, n=value.
Constraint: n0.
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

Not applicable.

8 Parallelism and Performance

s22caf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
s22caf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the Users' Note for your implementation for any additional implementation-specific information.

9 Further Comments

None.

10 Example

This example calculates the first four even and odd function and derivative values at x=0 for q=2.0.

10.1 Program Text

Program Text (s22cafe.f90)

10.2 Program Data

Program Data (s22cafe.d)

10.3 Program Results

Program Results (s22cafe.r)
GnuplotProduced by GNUPLOT 5.0 patchlevel 3 Values Returned for First Four Orders with q = 2.0 −1 0 1 0 1 2 3 4 5 6 cem(x,q) Order 0 Order 0 Order 1 Order 1 Order 2 Order 2 Order 3 Order 3 −1 0 1 0 1 2 3 4 5 6 sem(x,q) Order 1 Order 1 Order 2 Order 2 Order 3 Order 3 Order 4 Order 4 −4 0 4 0 1 2 3 4 5 6 cem'(x,q) Order 0 Order 0 Order 1 Order 1 Order 2 Order 2 Order 3 Order 3 −4 0 4 0 1 2 3 4 5 6 sem'(x,q) Order 1 Order 1 Order 2 Order 2 Order 3 Order 3 Order 4 Order 4