scipy.special.mathieu_se#

scipy.special.mathieu_se(m, q, x, out=None) = <wrapped_ufunc 'mathieu_se'>#

Odd Mathieu function and its derivative.

Returns the odd Mathieu function, \(\mathrm{se}_m(x, q)\), of order \(m\) and parameter \(q\) evaluated at \(x\) (given in radians). Also returns its derivative with respect to \(x\).

Parameters:
marray_like

Order of the function. Must be a non-negative integer.

qarray_like

Parameter of the function.

xarray_like

Argument of the function, given in radians.

outtuple of ndarray, optional

Optional output arrays for the function results.

Returns:
yscalar or ndarray

Value of the function.

ypscalar or ndarray

Derivative with respect to x (per radian).

Notes

Odd Mathieu functions are the solutions to Mathieu’s differential equation

\[\frac{d^2y}{dx^2} + (b_m - 2q \cos(2x))y = 0\]

for which the characteristic number \(b_m\) (calculated with mathieu_b) results in an odd, periodic solution \(y(x)\) with period \(\pi\) (for even \(m\)) or \(2\pi\) (for odd \(m\)).

For \(m = 0\), both outputs are zero.

Added in version 2.0.0.

Array API Standard Support

mathieu_se has support for Python Array API Standard compatible backends in addition to NumPy. The following combinations of backend and device (or other capability) are supported.

Library

CPU

GPU

NumPy

✅

n/a

CuPy

n/a

⛔

PyTorch

✅

⛔

JAX

✅

⛔

Dask

⛔

n/a

For the NumPy backend, this function supports all NumPy ufunc keyword arguments. Other backends may support out, but typically none of the other ufunc kwargs. out is typically supported for CuPy and PyTorch, but not currently in cases where SciPy relies on a generic Array API implementation or, for PyTorch on CPU, falls back to the NumPy backend. out is never supported for JAX because JAX arrays are immutable. mathieu_se does not currently support out for the PyTorch backend.

See Support for the array API standard for more information.

References

[1]

‘Mathieu function’. Wikipedia. https://en.wikipedia.org/wiki/Mathieu_function

[2]

Stuart Brorson, A New Implementation of the Mathieu Functions for SciPy. brorson/ScipyMathieuPaper

Examples

Plot odd Mathieu functions of orders \(m = 2\) and \(m = 4\).

>>> import numpy as np
>>> from scipy import special
>>> import matplotlib.pyplot as plt
>>> m = np.asarray([2, 4])
>>> q = 50
>>> x = np.linspace(-np.pi, np.pi, 300)[:, np.newaxis]
>>> y, _ = special.mathieu_se(m, q, x)
>>> plt.plot(x, y)
>>> plt.xticks(
...     [-np.pi, -np.pi/2, 0, np.pi/2, np.pi],
...     [r"$-\pi$", r"$-\pi/2$", r"$0$", r"$\pi/2$", r"$\pi$"]
... )
>>> plt.xlabel('x (radians)')
>>> plt.ylabel('y')
>>> plt.legend(('m = 2', 'm = 4'))
>>> plt.show()
../../_images/scipy-special-mathieu_se-1_00_00.png

Because the orders \(2\) and \(4\) are even, the period of each function is \(\pi\).

Now plot the functions of odd orders \(m = 1\) and \(m = 3\).

>>> m = np.asarray([1, 3])
>>> y, _ = special.mathieu_se(m, q, x)
>>> plt.figure()
>>> plt.plot(x, y)
>>> plt.xticks(
...     [-np.pi, -np.pi/2, 0, np.pi/2, np.pi],
...     [r"$-\pi$", r"$-\pi/2$", r"$0$", r"$\pi/2$", r"$\pi$"]
... )
>>> plt.xlabel('x (radians)')
>>> plt.ylabel('y')
>>> plt.legend(('m = 1', 'm = 3'))
>>> plt.show()
../../_images/scipy-special-mathieu_se-1_01_00.png

Because the orders \(1\) and \(3\) are odd, the period of each function is \(2\pi\).