{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "588def58",
            "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": "ba42d089",
            "cell_type": "markdown",
            "source": "We can compute exponentially scaled Airy functions and their derivatives:\n",
            "metadata": {}
        },
        {
            "id": "ad1df299",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nfrom scipy.special import airye\nimport matplotlib.pyplot as plt\nz = np.linspace(0, 50, 500)\neAi, eAip, eBi, eBip = airye(z)\nf, ax = plt.subplots(2, 1, sharex=True)\nfor ind, data in enumerate([[eAi, eAip, [\"eAi\", \"eAip\"]],\n                            [eBi, eBip, [\"eBi\", \"eBip\"]]]):\n    ax[ind].plot(z, data[0], \"-r\", z, data[1], \"-b\")\n    ax[ind].legend(data[2])\n    ax[ind].grid(True)\nplt.show()",
            "outputs": []
        },
        {
            "id": "cf36ef80",
            "cell_type": "markdown",
            "source": "We can compute these using usual non-scaled Airy functions by:\n",
            "metadata": {}
        },
        {
            "id": "25190aa7",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "from scipy.special import airy\nAi, Aip, Bi, Bip = airy(z)\nnp.allclose(eAi, Ai * np.exp(2.0 / 3.0 * z * np.sqrt(z)))",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "True"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "4769b48a",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "np.allclose(eAip, Aip * np.exp(2.0 / 3.0 * z * np.sqrt(z)))",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "True"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "e19e24f1",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "np.allclose(eBi, Bi * np.exp(-abs(np.real(2.0 / 3.0 * z * np.sqrt(z)))))",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "True"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "a93071ad",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "np.allclose(eBip, Bip * np.exp(-abs(np.real(2.0 / 3.0 * z * np.sqrt(z)))))",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "True"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "4a64bdd6",
            "cell_type": "markdown",
            "source": "Comparing non-scaled and exponentially scaled ones, the usual non-scaled\nfunction quickly underflows for large values, whereas the exponentially\nscaled function does not.\n",
            "metadata": {}
        },
        {
            "id": "05db8a2c",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "airy(200)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "(0.0, 0.0, nan, nan)"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "4c41b1e7",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "airye(200)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "(0.07501041684381093, -1.0609012305109042, 0.15003188417418148, 2.1215836725571093)"
                    },
                    "execution_count": null
                }
            ]
        }
    ]
}