bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / special / _basic / mathieu_even_coef
function
scipy.special._basic:mathieu_even_coef
source: build-install/usr/lib/python3.14/site-packages/scipy/special/_basic.py:1689
Signature
def mathieu_even_coef(m, q)Summary
Fourier coefficients for even Mathieu and modified Mathieu functions.
Extended Summary
The Fourier series of the even solutions of the Mathieu differential equation are of the form
This function returns the coefficients for even input m=2n, and the coefficients for odd input m=2n+1.
Parameters
m: intOrder of Mathieu functions. Must be non-negative.
q: float (>=0)Parameter of Mathieu functions. Must be non-negative.
Returns
Ak: ndarrayEven or odd Fourier coefficients, corresponding to even or odd m. The number of coefficients returned is determined by an empirical formula that depends on
mandq[1].
Examples
We use the Fourier coefficients to construct an approximation of ``mathieu_cem(5, 14, x)``, the even Mathieu function of order `m = 5` and parameter `q = 14`.import numpy as np import matplotlib.pyplot as plt from scipy.special import mathieu_even_coef, mathieu_cem m = 5 q = 14✓
a = mathieu_even_coef(m, q) a.shape✓
(29,)Sum the Fourier cosine series on a grid of ``x`` values.
period = 180 if m % 2 == 0 else 360 x = np.linspace(0, period, 5000) # x has shape (5000,) k = np.arange(len(a)).reshape((-1, 1)) # k has shape (len(a), 1) c = np.cos((2*k + m % 2) * (np.pi/180) * x) # c has shape (len(a), 5000) y = a @ c # y has shape (5000,)✓
plt.plot(x, y, 'k--', label="Fourier sum")
✗[<matplotlib.lines.Line2D object at 0x7f3f591e97f0>]
ce, _dce = mathieu_cem(m, q, x)
✓plt.plot(x, ce, alpha=0.35, linewidth=3.5, label="mathieu_cem")
✗[<matplotlib.lines.Line2D object at 0x7f3f591e9940>]
plt.grid(True)
✓plt.title(f'Mathieu Function $\\rm{{ce_{m}}}(x, {q})$') plt.xlabel('x [degrees]') plt.legend(shadow=True, loc='upper left', bbox_to_anchor=(1, 1))✗
<matplotlib.legend.Legend object at 0x7f3f591e9550>
plt.tight_layout() plt.show()✓

See also
Aliases
scipy.special.mathieu_even_coef