{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "c70a11ca",
            "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": "d8567c48",
            "cell_type": "markdown",
            "source": "Evaluate the function of order 0 at one point.\n",
            "metadata": {}
        },
        {
            "id": "14ed0738",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy.special import iv\niv(0, 1.)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "1.2660658777520084"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "6bee56b4",
            "cell_type": "markdown",
            "source": "Evaluate the function at one point for different orders.\n",
            "metadata": {}
        },
        {
            "id": "c741e14a",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "iv(0, 1.), iv(1, 1.), iv(1.5, 1.)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "(1.2660658777520084, 0.565159103992485, 0.2935253263474798)"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "37756ad2",
            "cell_type": "markdown",
            "source": "The evaluation for different orders can be carried out in one call by\nproviding a list or NumPy array as argument for the `v` parameter:\n",
            "metadata": {}
        },
        {
            "id": "af7f671c",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "iv([0, 1, 1.5], 1.)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([1.26606588, 0.5651591 , 0.29352533])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "fc564696",
            "cell_type": "markdown",
            "source": "Evaluate the function at several points for order 0 by providing an\narray for `z`.\n",
            "metadata": {}
        },
        {
            "id": "ada7d175",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\npoints = np.array([-2., 0., 3.])\niv(0, points)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([2.2795853 , 1.        , 4.88079259])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "4d0153fe",
            "cell_type": "markdown",
            "source": "If `z` is an array, the order parameter `v` must be broadcastable to\nthe correct shape if different orders shall be computed in one call.\nTo calculate the orders 0 and 1 for an 1D array:\n",
            "metadata": {}
        },
        {
            "id": "278a4d47",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "orders = np.array([[0], [1]])\norders.shape",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "(2, 1)"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "4de8b12d",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "iv(orders, points)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([[ 2.2795853 ,  1.        ,  4.88079259],\n       [-1.59063685,  0.        ,  3.95337022]])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "27e1bc27",
            "cell_type": "markdown",
            "source": "Plot the functions of order 0 to 3 from -5 to 5.\n",
            "metadata": {}
        },
        {
            "id": "8a3c143e",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import matplotlib.pyplot as plt\nfig, ax = plt.subplots()\nx = np.linspace(-5., 5., 1000)\nfor i in range(4):\n    ax.plot(x, iv(i, x), label=f'$I_{i!r}$')\nax.legend()\nplt.show()",
            "outputs": []
        }
    ]
}