{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "85225e00",
            "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": "ae4a3aa4",
            "cell_type": "markdown",
            "source": "This can be used for finding maxima of a curve:\n",
            "metadata": {}
        },
        {
            "id": "027baa5d",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy.interpolate import splrep, splder, sproot\nimport numpy as np\nx = np.linspace(0, 10, 70)\ny = np.sin(x)\nspl = splrep(x, y, k=4)",
            "outputs": []
        },
        {
            "id": "6b50bd72",
            "cell_type": "markdown",
            "source": "Now, differentiate the spline and find the zeros of the\nderivative. (NB: `sproot` only works for order 3 splines, so we\nfit an order 4 spline):\n",
            "metadata": {}
        },
        {
            "id": "06ea5205",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "dspl = splder(spl)\nsproot(dspl) / np.pi",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([ 0.50000001,  1.5       ,  2.49999998])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "23c621a9",
            "cell_type": "markdown",
            "source": "This agrees well with roots $\\pi/2 + n\\pi$ of\n$\\cos(x) = \\sin'(x)$.\n\nA comparison between `splev`, `splder` and `spalde` to compute the derivatives of a \nB-spline can be found in the `spalde` examples section.",
            "metadata": {}
        }
    ]
}