NAG CL Interface
s22cac (mathieu_​ang_​periodic_​real)

Settings help

CL Name Style:


1 Purpose

s22cac 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

#include <nag.h>
void  s22cac (Integer ordval, double q, Integer parity, Integer mode, Integer n, const double x[], double f[], double f_deriv[], double *a, NagError *fail)
The function may be called by the names: s22cac or nag_specfun_mathieu_ang_periodic_real.

3 Description

s22cac 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 function 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 double 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] const double Input
On entry: the values of x at which to compute Mathieu function or derivative values.
7: f[n] double 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] double 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 double * Output
On exit: a, the characteristic value for the Mathieu function.
10: fail NagError * Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).

6 Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_INT
On entry, mode=value.
Constraint: mode=0, 1, 2 or 3.
On entry, n=value.
Constraint: n0.
On entry, parity=value.
Constraint: parity=0 or 1.
NE_INT_2
On entry, ordval=value and parity=value.
Constraint: if parity=0, ordval0 or if parity=1, ordval1.
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.

7 Accuracy

Not applicable.

8 Parallelism and Performance

Background information to multithreading can be found in the Multithreading documentation.
s22cac is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
s22cac 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 function. 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 (s22cace.c)

10.2 Program Data

Program Data (s22cace.d)

10.3 Program Results

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