.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/special_functions/mathieu/plot_01_mathieu_functions.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_special_functions_mathieu_plot_01_mathieu_functions.py: Mathieu functions and their characteristic values ======================================================= Plots the first even Mathieu functions ce_m(x, q) and how the characteristic values a_m(q), b_m(q) split away from m^2 as q grows -- the band structure behind the Mathieu stability chart. .. GENERATED FROM PYTHON SOURCE LINES 11-16 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from mathematicskit.special_functions import mathieu_characteristic_a, mathieu_characteristic_b, mathieu_even .. GENERATED FROM PYTHON SOURCE LINES 17-19 Even Mathieu functions at q = 2 ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 19-30 .. code-block:: Python x = np.linspace(0, np.pi, 300) q = 2.0 fig, ax = plt.subplots() for m in range(3): ax.plot(x, mathieu_even(m, q, x), label=rf"$\mathrm{{ce}}_{m}(x, {q:g})$") ax.plot(x, mathieu_even(m, 0.0, x), ":", color=f"C{m}") ax.set_xlabel("x (radians)") ax.set_title("Even Mathieu functions (dotted: q = 0, i.e. cosines)") ax.legend() .. image-sg:: /api/gallery/special_functions/mathieu/images/sphx_glr_plot_01_mathieu_functions_001.png :alt: Even Mathieu functions (dotted: q = 0, i.e. cosines) :srcset: /api/gallery/special_functions/mathieu/images/sphx_glr_plot_01_mathieu_functions_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 31-33 Characteristic values versus q ----------------------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 33-45 .. code-block:: Python qs = np.linspace(0, 10, 200) fig, ax = plt.subplots() for m in range(4): ax.plot(qs, [mathieu_characteristic_a(m, qq) for qq in qs], f"C{m}", label=f"$a_{m}$") if m >= 1: ax.plot(qs, [mathieu_characteristic_b(m, qq) for qq in qs], f"C{m}--", label=f"$b_{m}$") ax.set_xlabel("q") ax.set_ylabel("characteristic value") ax.legend(ncol=2) for m in range(4): print(f"a_{m}(0) = {mathieu_characteristic_a(m, 0.0) + 0.0:.1f}, a_{m}(10) = {mathieu_characteristic_a(m, 10.0):.4f}") .. image-sg:: /api/gallery/special_functions/mathieu/images/sphx_glr_plot_01_mathieu_functions_002.png :alt: plot 01 mathieu functions :srcset: /api/gallery/special_functions/mathieu/images/sphx_glr_plot_01_mathieu_functions_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none a_0(0) = 0.0, a_0(10) = -13.9370 a_1(0) = 1.0, a_1(10) = -2.3991 a_2(0) = 4.0, a_2(10) = 7.7174 a_3(0) = 9.0, a_3(10) = 15.5028 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.058 seconds) .. _sphx_glr_download_api_gallery_special_functions_mathieu_plot_01_mathieu_functions.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_mathieu_functions.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_mathieu_functions.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_mathieu_functions.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_