{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "59218aef",
            "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": "cbbfc07f",
            "cell_type": "markdown",
            "source": "The Laguerre polynomials $L_n$ are the special case\n$\\alpha = 0$ of the generalized Laguerre polynomials\n$L_n^{(\\alpha)}$.\nLet's verify it on the interval $[-1, 1]$:\n",
            "metadata": {}
        },
        {
            "id": "73dccb90",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nfrom scipy.special import genlaguerre\nfrom scipy.special import laguerre\nx = np.arange(-1.0, 1.0, 0.01)\nnp.allclose(genlaguerre(3, 0)(x), laguerre(3)(x))",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "True"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "866da96a",
            "cell_type": "markdown",
            "source": "The polynomials $L_n$ also satisfy the recurrence relation:\n\n$$ (n + 1)L_{n+1}(x) = (2n +1 -x)L_n(x) - nL_{n-1}(x) $$\nThis can be easily checked on $[0, 1]$ for $n = 3$:\n",
            "metadata": {}
        },
        {
            "id": "9111b33d",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "x = np.arange(0.0, 1.0, 0.01)\nnp.allclose(4 * laguerre(4)(x),\n            (7 - x) * laguerre(3)(x) - 3 * laguerre(2)(x))",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "True"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "875b4c68",
            "cell_type": "markdown",
            "source": "This is the plot of the first few Laguerre polynomials $L_n$:\n",
            "metadata": {}
        },
        {
            "id": "c3f15037",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import matplotlib.pyplot as plt\nx = np.arange(-1.0, 5.0, 0.01)\nfig, ax = plt.subplots()\nax.set_ylim(-5.0, 5.0)\nax.set_title(r'Laguerre polynomials $L_n$')\nfor n in np.arange(0, 5):\n    ax.plot(x, laguerre(n)(x), label=rf'$L_{n}$')\nplt.legend(loc='best')\nplt.show()",
            "outputs": []
        }
    ]
}