{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "e814af70",
            "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": "15d8fb23",
            "cell_type": "markdown",
            "source": "Compute the triple integral of ``x * y * z``, over ``x`` ranging\nfrom 1 to 2, ``y`` ranging from 2 to 3, ``z`` ranging from 0 to 1.\nThat is, $\\int^{x=2}_{x=1} \\int^{y=3}_{y=2} \\int^{z=1}_{z=0} x y z\n\\,dz \\,dy \\,dx$.\n",
            "metadata": {}
        },
        {
            "id": "ba386c75",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nfrom scipy import integrate\nf = lambda z, y, x: x*y*z\nintegrate.tplquad(f, 1, 2, 2, 3, 0, 1)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "(1.8749999999999998, 3.3246447942574074e-14)"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "b18d6c9b",
            "cell_type": "markdown",
            "source": "Calculate $\\int^{x=1}_{x=0} \\int^{y=1-2x}_{y=0}\n\\int^{z=1-x-2y}_{z=0} x y z \\,dz \\,dy \\,dx$.\nNote: `qfun`/`rfun` takes arguments in the order (x, y), even though ``f``\ntakes arguments in the order (z, y, x).\n",
            "metadata": {}
        },
        {
            "id": "18d3efab",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "f = lambda z, y, x: x*y*z\nintegrate.tplquad(f, 0, 1, 0, lambda x: 1-2*x, 0, lambda x, y: 1-x-2*y)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "(0.05416666666666668, 2.1774196738157757e-14)"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "d46fbfd5",
            "cell_type": "markdown",
            "source": "Calculate $\\int^{x=1}_{x=0} \\int^{y=1}_{y=0} \\int^{z=1}_{z=0}\na x y z \\,dz \\,dy \\,dx$ for $a=1, 3$.\n",
            "metadata": {}
        },
        {
            "id": "e89ac638",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "f = lambda z, y, x, a: a*x*y*z\nintegrate.tplquad(f, 0, 1, 0, 1, 0, 1, args=(1,))",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "    (0.125, 5.527033708952211e-15)"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "a230a6ec",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "integrate.tplquad(f, 0, 1, 0, 1, 0, 1, args=(3,))",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "    (0.375, 1.6581101126856635e-14)"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "7ef99543",
            "cell_type": "markdown",
            "source": "Compute the three-dimensional Gaussian Integral, which is the integral of\nthe Gaussian function $f(x,y,z) = e^{-(x^{2} + y^{2} + z^{2})}$, over\n$(-\\infty,+\\infty)$. That is, compute the integral\n$\\iiint^{+\\infty}_{-\\infty} e^{-(x^{2} + y^{2} + z^{2})} \\,dz\n\\,dy\\,dx$.\n",
            "metadata": {}
        },
        {
            "id": "3c095ca4",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "f = lambda x, y, z: np.exp(-(x ** 2 + y ** 2 + z ** 2))\nintegrate.tplquad(f, -np.inf, np.inf, -np.inf, np.inf, -np.inf, np.inf)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "    (5.568327996830833, 4.4619078828029765e-08)"
                    },
                    "execution_count": null
                }
            ]
        }
    ]
}