{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "926dd679",
            "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": "38f04d02",
            "cell_type": "markdown",
            "source": "The Jacobi polynomials satisfy the recurrence relation:\n\n$$ P_n^{(\\alpha, \\beta-1)}(x) - P_n^{(\\alpha-1, \\beta)}(x) = P_{n-1}^{(\\alpha, \\beta)}(x) $$\nThis can be verified, for example, for $\\alpha = \\beta = 2$\nand $n = 1$ over the interval $[-1, 1]$:\n",
            "metadata": {}
        },
        {
            "id": "392d60fb",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nfrom scipy.special import jacobi\nx = np.arange(-1.0, 1.0, 0.01)\nnp.allclose(jacobi(0, 2, 2)(x),\n            jacobi(1, 2, 1)(x) - jacobi(1, 1, 2)(x))",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "True"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "e3a67392",
            "cell_type": "markdown",
            "source": "Plot of the Jacobi polynomial $P_5^{(\\alpha, -0.5)}$ for\ndifferent values of $\\alpha$:\n",
            "metadata": {}
        },
        {
            "id": "3de3b706",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import matplotlib.pyplot as plt\nx = np.arange(-1.0, 1.0, 0.01)\nfig, ax = plt.subplots()\nax.set_ylim(-2.0, 2.0)\nax.set_title(r'Jacobi polynomials $P_5^{(\\alpha, -0.5)}$')\nfor alpha in np.arange(0, 4, 1):\n    ax.plot(x, jacobi(5, alpha, -0.5)(x), label=rf'$\\alpha={alpha}$')\nplt.legend(loc='best')\nplt.show()",
            "outputs": []
        }
    ]
}