{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "52e91cde",
            "cell_type": "markdown",
            "source": "<div class='alert alert-warning'>\n\nSciPy's interactive examples with Jupyterlite are experimental and may not always work as expected. Execution of cells containing imports may result in large downloads (up to 60MB of content for the first import from SciPy). Load times when importing from SciPy may take roughly 10-20 seconds. If you notice any problems, feel free to open an [issue](https://github.com/scipy/scipy/issues/new/choose).\n\n</div>",
            "metadata": {}
        },
        {
            "id": "92dd6744",
            "cell_type": "markdown",
            "source": "Compute the first four roots of $J_2'$.\n",
            "metadata": {}
        },
        {
            "id": "a566f4f3",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy.special import jnp_zeros\njnp_zeros(2, 4)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([ 3.05423693,  6.70613319,  9.96946782, 13.17037086])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "4d98e4ee",
            "cell_type": "markdown",
            "source": "As `jnp_zeros` yields the roots of $J_n'$, it can be used to\ncompute the locations of the peaks of $J_n$. Plot\n$J_2$, $J_2'$ and the locations of the roots of $J_2'$.\n",
            "metadata": {}
        },
        {
            "id": "65e179e9",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.special import jn, jnp_zeros, jvp\nj2_roots = jnp_zeros(2, 4)\nxmax = 15\nx = np.linspace(0, xmax, 500)\nfig, ax = plt.subplots()\nax.plot(x, jn(2, x), label=r'$J_2$')\nax.plot(x, jvp(2, x, 1), label=r\"$J_2'$\")\nax.hlines(0, 0, xmax, color='k')\nax.scatter(j2_roots, np.zeros((4, )), s=30, c='r',\n           label=r\"Roots of $J_2'$\", zorder=5)\nax.set_ylim(-0.4, 0.8)\nax.set_xlim(0, xmax)\nplt.legend()\nplt.show()",
            "outputs": []
        }
    ]
}