{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "22dc6b2d",
            "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": "0a515871",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.special import shichi, sici",
            "outputs": []
        },
        {
            "id": "8a23a8f4",
            "cell_type": "markdown",
            "source": "`shichi` accepts real or complex input:\n",
            "metadata": {}
        },
        {
            "id": "8e54ed7e",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "shichi(0.5)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "(0.5069967498196671, -0.05277684495649357)"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "fe5ee3b1",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "shichi(0.5 + 2.5j)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "((0.11772029666668238+1.831091777729851j),\n (0.29912435887648825+1.7395351121166562j))"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "9136e0a1",
            "cell_type": "markdown",
            "source": "The hyperbolic sine and cosine integrals Shi(z) and Chi(z) are\nrelated to the sine and cosine integrals Si(z) and Ci(z) by\n\n* Shi(z) = -i*Si(i*z)\n* Chi(z) = Ci(-i*z) + i*pi/2\n",
            "metadata": {}
        },
        {
            "id": "e496faa1",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "z = 0.25 + 5j\nshi, chi = shichi(z)\nshi, -1j*sici(1j*z)[0]            # Should be the same.",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "((-0.04834719325101729+1.5469354086921228j),\n (-0.04834719325101729+1.5469354086921228j))"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "67a17a63",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "chi, sici(-1j*z)[1] + 1j*np.pi/2  # Should be the same.",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "((-0.19568708973868087+1.556276312103824j),\n (-0.19568708973868087+1.556276312103824j))"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "bce8ba72",
            "cell_type": "markdown",
            "source": "Plot the functions evaluated on the real axis:\n",
            "metadata": {}
        },
        {
            "id": "ea2e7708",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "xp = np.geomspace(1e-8, 4.0, 250)\nx = np.concatenate((-xp[::-1], xp))\nshi, chi = shichi(x)",
            "outputs": []
        },
        {
            "id": "4eddf6d1",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "fig, ax = plt.subplots()\nax.plot(x, shi, label='Shi(x)')\nax.plot(x, chi, '--', label='Chi(x)')\nax.set_xlabel('x')\nax.set_title('Hyperbolic Sine and Cosine Integrals')\nax.legend(shadow=True, framealpha=1, loc='lower right')\nax.grid(True)\nplt.show()",
            "outputs": []
        }
    ]
}