{
  "aliases": null,
  "backlinks": null,
  "body": "\n## Statement\n\nLet $\\varphi \\colon \\R \\to (-1, 1)$ be $\\varphi(t) = \\tanh\\big(\\tfrac{\\pi}{2} \\sinh t\\big)$, so that\n$$\\varphi'(t) = \\frac{\\frac{\\pi}{2} \\cosh t}{\\cosh^2\\big(\\frac{\\pi}{2} \\sinh t\\big)}.$$\nThen:\n\n1. $\\varphi$ is a smooth increasing bijection of $\\R$ onto $(-1, 1)$, and for every Lebesgue integrable $f$ on $(-1, 1)$,\n$$\\int_{-1}^{1} f(x) \\, dx = \\int_{-\\infty}^{\\infty} f(\\varphi(t)) \\, \\varphi'(t) \\, dt;$$\n2. if moreover $\\abs{f(x)} \\le M$ for all $x \\in (-1, 1)$, then for all real $t$,\n$$\\abs{f(\\varphi(t)) \\, \\varphi'(t)} \\le 2 \\pi M \\cosh t \\; e^{-\\pi \\sinh \\abs{t}}.$$\n\nThe *tanh-sinh rule* with step $h \u003e 0$ and $2N + 1$ points is $T_{h,N}(f) = h \\sum_{k=-N}^{N} \\varphi'(kh) \\, f(\\varphi(kh))$, the [[trapezoidal rule|FH0538XCZR]] for the transformed integral, cut off at $\\abs{t} \\le Nh$.\n\n## Remarks\n\nClause 1 is the change of variables formula, since $\\varphi' \u003e 0$ and $\\varphi(t) \\to \\pm 1$ as $t \\to \\pm\\infty$.\nClause 2 follows from $\\cosh u \\ge \\frac12 e^{\\abs{u}}$, which gives $\\cosh^{-2}\\big(\\frac{\\pi}{2}\\sinh t\\big) \\le 4 e^{-\\pi \\sinh\\abs{t}}$.\nSo the transformed integrand decays double exponentially, and the cut-off at $\\abs{t} \\le Nh$ loses almost nothing; this is why the method is also called double exponential quadrature.\nThe trapezoidal rule on $\\R$ is extremely accurate for functions analytic in a strip around the real axis.\nFor integrands analytic in a suitable region around $(-1, 1)$, the error of $T_{h,N}$ with a good choice of $h$ decreases roughly like $e^{-cN/\\log N}$ for some $c \u003e 0$.\nExample: for $f(x) = (1 - x^2)^{-1/2}$, which is unbounded, the transformed integrand is $\\frac{\\pi}{2} \\cosh t / \\cosh\\big(\\frac{\\pi}{2} \\sinh t\\big)$, still double exponentially decaying, and its integral is $\\pi$.\nThe method was introduced by Hidetosi Takahashi and Masatake Mori in 1974.\n\n## Explanations\n\n### L1 human\n\nTanh-sinh quadrature stretches the interval $(-1, 1)$ to the whole real line with a clever change of variable.\nAfter the change, the function to be integrated dies off extremely fast at both ends, even if the original one blew up at an endpoint.\nThen the simplest rule, adding equally spaced samples, gives an excellent answer.\n\n### L2 human\n\nThe method is robust against endpoint singularities, which defeat Gaussian rules, and it reuses all old samples when the step $h$ is halved.\nFor these reasons it is a standard choice in arbitrary-precision computation, where hundreds of correct digits are needed.\nIt needs care near the endpoints in floating-point arithmetic, since $\\varphi(kh)$ is extremely close to $\\pm 1$ and $1 \\mp \\varphi(kh)$ should be computed directly.\nRelated double exponential substitutions treat integrals over $[0, \\infty)$ and $\\R$.\n",
  "commit": "ff8a40749dc16545e3d2fc637f6b0196e81d0bfa",
  "front": {
    "about": [
      "7HYF6YG0RS"
    ],
    "kind": "statement",
    "msc": [
      "65D32",
      "65D30"
    ],
    "name": "Tanh-sinh quadrature",
    "role": "proposition",
    "same_as": {
      "wikidata": "Q7683194",
      "wikipedia": "Tanh-sinh quadrature"
    },
    "sources": [
      {
        "url": "https://en.wikipedia.org/wiki/Tanh-sinh_quadrature"
      }
    ],
    "tag": "X4EXEGM2BV",
    "uses": [
      "7HYF6YG0RS",
      "FH0538XCZR"
    ]
  },
  "kind": "statement",
  "link": "https://tamnd.github.io/math2/node/X4EXEGM2BV/",
  "links": [
    {
      "field": "about",
      "target": "7HYF6YG0RS"
    },
    {
      "field": "uses",
      "target": "7HYF6YG0RS"
    },
    {
      "field": "uses",
      "target": "FH0538XCZR"
    }
  ],
  "markdown": "https://tamnd.github.io/math2/node/X4EXEGM2BV.md",
  "msc": [
    "65D32",
    "65D30"
  ],
  "name": "Tanh-sinh quadrature",
  "prov": null,
  "role": "proposition",
  "source": "https://github.com/tamnd/math2/blob/main/nodes/X4E/X4EXEGM2BV.md",
  "status": null,
  "tag": "X4EXEGM2BV",
  "uri": "m2://X4EXEGM2BV",
  "url": "https://tamnd.github.io/math2/wiki/tanh-sinh-quadrature/",
  "writing": {
    "tag": "X4EXEGM2BV",
    "kind": "statement",
    "level": "W0",
    "next": [
      {
        "what": "a source with a locator",
        "have": 0,
        "want": 1
      }
    ]
  }
}
