{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "5f6a7b5d",
            "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": "65d8c411",
            "cell_type": "markdown",
            "source": "Compute the first four roots of $Y_1'$ and the values of\n$Y_1$ at these roots.\n",
            "metadata": {}
        },
        {
            "id": "5361d912",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nfrom scipy.special import y1p_zeros\ny1grad_roots, y1_values = y1p_zeros(4)\nwith np.printoptions(precision=5):\n    print(f\"Y1' Roots: {y1grad_roots.real}\")\n    print(f\"Y1 values: {y1_values.real}\")",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "Y1' Roots: [ 3.68302  6.9415  10.1234  13.28576]\nY1 values: [ 0.41673 -0.30317  0.25091 -0.21897]"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "2e87e6f6",
            "cell_type": "markdown",
            "source": "`y1p_zeros` can be used to calculate the extremal points of $Y_1$\ndirectly. Here we plot $Y_1$ and the first four extrema.\n",
            "metadata": {}
        },
        {
            "id": "0d6accaa",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import matplotlib.pyplot as plt\nfrom scipy.special import y1, yvp\ny1_roots, y1_values_at_roots = y1p_zeros(4)\nreal_roots = y1_roots.real\nxmax = 15\nx = np.linspace(0, xmax, 500)\nx[0] += 1e-15\nfig, ax = plt.subplots()\nax.plot(x, y1(x), label=r'$Y_1$')\nax.plot(x, yvp(1, x, 1), label=r\"$Y_1'$\")\nax.scatter(real_roots, np.zeros((4, )), s=30, c='r',\n           label=r\"Roots of $Y_1'$\", zorder=5)\nax.scatter(real_roots, y1_values_at_roots.real, s=30, c='k',\n           label=r\"Extrema of $Y_1$\", zorder=5)\nax.hlines(0, 0, xmax, color='k')\nax.set_ylim(-0.5, 0.5)\nax.set_xlim(0, xmax)\nax.legend(ncol=2, bbox_to_anchor=(1., 0.75))\nplt.tight_layout()\nplt.show()",
            "outputs": []
        }
    ]
}