{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "bc695c4c",
            "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": "8bb1539e",
            "cell_type": "markdown",
            "source": "This function can find a downward convex region of a function:\n",
            "metadata": {}
        },
        {
            "id": "133decf5",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.optimize import bracket\ndef f(x):\n    return 10*x**2 + 3*x + 5\nx = np.linspace(-2, 2)\ny = f(x)\ninit_xa, init_xb = 0.1, 1\nxa, xb, xc, fa, fb, fc, funcalls = bracket(f, xa=init_xa, xb=init_xb)\nplt.axvline(x=init_xa, color=\"k\", linestyle=\"--\")\nplt.axvline(x=init_xb, color=\"k\", linestyle=\"--\")\nplt.plot(x, y, \"-k\")\nplt.plot(xa, fa, \"bx\")\nplt.plot(xb, fb, \"rx\")\nplt.plot(xc, fc, \"bx\")\nplt.show()",
            "outputs": []
        },
        {
            "id": "ac883064",
            "cell_type": "markdown",
            "source": "Note that both initial points were to the right of the minimum, and the\nthird point was found in the \"downhill\" direction: the direction\nin which the function appeared to be decreasing (to the left).\nThe final points are strictly ordered, and the function value\nat the middle point is less than the function values at the endpoints;\nit follows that a minimum must lie within the bracket.\n",
            "metadata": {}
        }
    ]
}