{
    "nbformat": 4,
    "nbformat_minor": 5,
    "metadata": {
        "kernelspec": {
            "display_name": "Python",
            "language": "python",
            "name": "python"
        },
        "language_info": {
            "name": "python"
        }
    },
    "cells": [
        {
            "id": "b1452646",
            "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": "01f9c4b9",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "import numpy as np\nfrom scipy.special import bernoulli, zeta\nbernoulli(4)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([ 1.        , -0.5       ,  0.16666667,  0.        , -0.03333333])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "e2f3b0fd",
            "cell_type": "markdown",
            "source": "The Wikipedia article ([2]) points out the relationship between the\nBernoulli numbers and the zeta function, ``B_n^+ = -n * zeta(1 - n)``\nfor ``n > 0``:\n",
            "metadata": {}
        },
        {
            "id": "7019d8b7",
            "cell_type": "code",
            "metadata": {},
            "execution_count": null,
            "source": "n = np.arange(1, 5)\n-n * zeta(1 - n)",
            "outputs": [
                {
                    "output_type": "execute_result",
                    "metadata": {},
                    "data": {
                        "text/plain": "array([ 0.5       ,  0.16666667, -0.        , -0.03333333])"
                    },
                    "execution_count": null
                }
            ]
        },
        {
            "id": "9ec78188",
            "cell_type": "markdown",
            "source": "Note that, in the notation used in the wikipedia article,\n`bernoulli` computes ``B_n^-`` (i.e. it used the convention that\n``B_1`` is -1/2).  The relation given above is for ``B_n^+``, so the\nsign of 0.5 does not match the output of ``bernoulli(4)``.",
            "metadata": {}
        }
    ]
}