{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"\n",
"\n",
"\n",
"# Numerical integration \n",
"\n",
" \n",
"**Anne Kværnø, André Massing**\n",
"\n",
"Date: **Jan 25, 2021**\n",
"\n",
"If you want to have a nicer theme for your jupyter notebook,\n",
"download the [cascade stylesheet file tma4125.css](https://www.math.ntnu.no/emner/TMA4125/2020v/part_II/notebooks/tma4125.css)\n",
"and execute the next cell:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [
{
"data": {
"text/html": [
" \n",
"\n"
],
"text/plain": [
""
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from math import factorial\n",
"\n",
"from IPython.core.display import HTML\n",
"from matplotlib.pyplot import *\n",
"from numpy import *\n",
"\n",
"\n",
"def css_styling():\n",
" try:\n",
" with open(\"tma4125.css\") as f:\n",
" styles = f.read()\n",
" return HTML(styles)\n",
" except FileNotFoundError:\n",
" pass # Do nothing\n",
"\n",
"\n",
"# Comment out next line and execute this cell to restore the default notebook style\n",
"css_styling()"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Introduction\n",
"Imagine you want to compute the finite integral\n",
"\n",
"$$\n",
"I[f](a,b) = \\int_a^b f(x) {\\,\\mathrm{d}x}.\n",
"$$\n",
"\n",
"The \"usual\" way is to find a primitive function $F$\n",
"(also known as the indefinite integral of $f$)\n",
"satisfying $F'(x) = f(x)$ and then to compute\n",
"\n",
"$$\n",
"\\int_a^b f(x) {\\,\\mathrm{d}x} = F(b) - F(a).\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"While there are many analytical integration techniques and extensive\n",
"tables to determine definite integral for many integrands,\n",
"more often than not it may not feasible or possible to compute the\n",
"integral. For instance, what about\n",
"\n",
"$$\n",
"f(x) = \\dfrac{\\log(2 + \\sin(1/2 - \\sqrt(x))^6)}{\\log(\\pi + \\arctan(\\sqrt{1-\\exp(-2x-\\sin(x)))}}?\n",
"$$\n",
"\n",
"Finding the corresponding primitive is highly likely a hopeless\n",
"endeavor. And sometimes there even innocent looking functions\n",
"like $e^{-x^2}$ for which there is not primitive functions which\n",
"can expressed as a composition of standard functions such\n",
"as $\\sin, \\cos.$ etc."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"A **numerical quadrature** or a **quadrature rule** is a formula for\n",
"approximating such definite integrals $I[f](a,b)$. Quadrature rules\n",
"are usually of the form\n",
"\n",
"$$\n",
"Q[f](a,b) = \\sum_{i=0}^n w_i f(x_i),\n",
"$$\n",
"\n",
"where $x_i$, $w_i$ for $i=0,1,\\dotsc,n$ are respectively the *nodes/points*\n",
"and the *weights* of the quadrature rule. To emphasize that\n",
"a quadrature rule is defined by some given quadrature points\n",
"$\\{x_i\\}_{i=0}^n$\n",
"and weights $\\{w_i\\}_{i=0}^n$."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"We sometimes might write\n",
"\n",
"$$\n",
"Q[f](\n",
"\\{x_i\\}_{i=0}^n,\\{w_i\\}_{i=0}^n\n",
") = \\sum_{i=0}^n w_i f(x_i).\n",
"$$\n",
"\n",
"If the function $f$ is given from the context, we will for simplicity\n",
"denote the integral and the quadrature simply as $I(a,b)$ and\n",
"$Q(a,b)$."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Example 1: Quadrature rules from previous math courses\n",
"\n",
"The \n",
"[trapezoidal rule, the midpoint rule and Simpson's rule](https://wiki.math.ntnu.no/tma4100/tema/numerics?&\\#numerisk_integrasjon)\n",
"known from previous courses are all examples of numerical quadratures,\n",
"and we quickly review them here:"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"* **Midpoint rule** is the simplest possible quadrature rule defined by\n",
"\n",
"$$\n",
"Q[f](a,b) := (b-a) f\\left(\\frac{a+b}{2}\\right).\n",
"$$\n",
"\n",
"The node is given by the midpoint, $x_0 = \\tfrac{a+b}{2}$ with the corresponding\n",
"weight $w_0 = b-a$.\n",
"\n",
"$$\n",
"Q[f](a,b) = w_0 f(x_0)\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"* **Trapezoidal rule** is given by\n",
"\n",
"$$\n",
"Q[f](a,b) := (b-a)\\left(\\frac{f(a)+f(b)}{2}\\right)\n",
"$$\n",
"\n",
"and thus the nodes are defined by $x_0 = a$, $x_1 = b$ with corresponding\n",
"weights $w_0 = w_1 = \\tfrac{b-a}{2}$."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"* Finally, **Simpson's rule** which you know from M1, is defined as follows:\n",
"\n",
"$$\n",
"Q[f](a,b)=\\frac{b-a}{6}\\left( f(a)+4f\\left( \\frac{a+b}{2}\\right) + f(b)\\right),\n",
"$$\n",
"\n",
"which we identify as quadrature rule with 3 points $x_0 = a, x_1 = \\tfrac{a+b}{2},\n",
"x_2 = b$ and corresponding weights $w_0 = w_2 = \\tfrac{b-a}{6}$ and $w_1 = \\tfrac{4(b-a)}{6}$."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"In this note we will see how quadrature rules can be constructed from\n",
"integration of interpolation polynomials. We will demonstrate how to\n",
"do error analysis and how to find error estimates. In the sequel, we\n",
"will use material from *Preliminaries*, section 3.2, 4 and 5.\n",
"\n",
"As usual, we import the necessary modules before we start computing."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"\n",
"newparams = {\n",
" \"figure.figsize\": (8.0, 4.0),\n",
" \"axes.grid\": True,\n",
" \"lines.markersize\": 8,\n",
" \"lines.linewidth\": 2,\n",
" \"font.size\": 14,\n",
"}\n",
"rcParams.update(newparams)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Quadrature based on polynomial interpolation.\n",
"This section relies on the content of the note on polynomial\n",
"interpolation, in particular the section on Lagrange polynomials."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Choose $n+1$ distinct nodes $x_i$, $i=0,\\dotsc,n$ in the interval $[a,b]$, and let $p_n(x)$ be the interpolation polynomial satisfying\n",
"the interpolation condition\n",
"\n",
"$$\n",
"p_n(x_i) = f(x_i), \\qquad i=0,1,\\ldots n.\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"We will then use $\\int_a^b p_n(x){\\,\\mathrm{d}x}$ as an approximation to $\\int_a^b\n",
"f(x){\\,\\mathrm{d}x}$. By using the Lagrange form of the polynomial\n",
"\n",
"$$\n",
"p_n(x) = \\sum_{i=0}^n f(x_i) \\ell_i(x)\n",
"$$\n",
"\n",
"with the cardinal functions $\\ell_i(x)$ given by\n",
"\n",
"$$\n",
"\\ell_i(x) = \\prod_{j=0,j\\not=i}^n \\frac{x-x_j}{x_i-x_j},\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"the following quadrature formula is obtained\n",
"\n",
"$$\n",
"\\begin{align*}\n",
"I[f](a, b)\n",
"\\approx\n",
"Q[f](a,b) &= \\int_a^b p_n(x){\\,\\mathrm{d}x}\n",
" \\\\\n",
" &= \\sum_{i=0}^n f(x_i) \\int_a^b \\ell_i(x) {\\,\\mathrm{d}x} \n",
" = \\sum_{i=0}^n w_i f(x_i) = Q(a,b),\n",
"\\end{align*}\n",
"$$\n",
"\n",
"where the weights in the quadrature are simply the integral of the\n",
"cardinal functions over the interval\n",
"\n",
"$$\n",
"w_i =\\int_a^b \\ell_i(x) {\\,\\mathrm{d}x} \\quad \\text{for } i = 0, \\ldots, n.\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Let us derive three schemes for integration over the interval $[0,1]$,\n",
"which we will finally apply to the integral\n",
"\n",
"$$\n",
"I(0,1) = \\int_0^1 \\cos\\left(\\frac{\\pi}{2}x\\right) = \\frac{2}{\\pi} = 0.636619\\dotsc.\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Example 2: The trapezoidal rule revisited\n",
"\n",
"\n",
"\n",
"Let $x_0=0$ and $x_1=1$. The cardinal functions and thus the weights are given by\n",
"\n",
"$$\n",
"\\begin{align*}\n",
"\\ell_0(x) &= 1-x, & w_0 &= \\int_0^1(1-x){\\,\\mathrm{d}x} = 1/2 \\\\ \n",
"\\ell_1(x) &= x, & w_1 &= \\int_0^1 x{\\,\\mathrm{d}x} = 1/2\n",
"\\end{align*}\n",
"$$\n",
"\n",
"\n",
"\n",
"and the corresponding quadrature rule is the trapezoidal rule (usually\n",
"denoted by $T$) recalled in Example [Example 1: Quadrature rules from previous math courses](#ex:qr-from-m1) with $[a,b] = [0,1]$:\n",
"\n",
"$$\n",
"T(0,1) = \\frac{1}{2} \\left[ f(0) + f(1) \\right].\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Example 3: Gauß-Legendre quadrature for $n=2$\n",
"\n",
"\n",
"Let $x_0=1/2 + \\sqrt{3}/6$ and $x_1 = 1/2 - \\sqrt{3}/6$. Then\n",
"\n",
"$$\n",
"\\begin{align*}\n",
"\\ell_0(x) &= -\\sqrt{3}x + \\frac{1+\\sqrt{3}}{2}, & w_0 &= \\int_0^1 \\ell_0(x){\\,\\mathrm{d}x}= 1/2, \\\\ \n",
"\\ell_1(x) &= \\sqrt{3}x + \\frac{1-\\sqrt{3}}{2}, & w_1 &= \\int_0^1 \\ell_1(x){\\,\\mathrm{d}x} = 1/2.\n",
"\\end{align*}\n",
"$$\n",
"\n",
"The quadrature rule is\n",
"\n",
"$$\n",
"Q(0,1) = \\frac{1}{2}\\left[f\\left(\\frac{1}{2}-\\frac{\\sqrt{3}}{6}\\right) + \n",
"f\\left(\\frac{1}{2}+\\frac{\\sqrt{3}}{6}\\right) \\right].\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Example 4: Simpson's rule revisited\n",
"\n",
"\n",
"We construct Simpson's rule on the interval $[0,1]$ by choosing\n",
"the nodes $x_0=0$, $x_1=0.5$ and $x_2=1$. \n",
"The corresponding cardinal\n",
"functions are\n",
"\n",
"$$\n",
"\\ell_0 = 2(x - 0.5)(x-1)\n",
"\\qquad\n",
"\\ell_1(x) = 4x(1-x)\n",
"\\qquad\n",
"\\ell_2(x) = 2x(x-0.5)\n",
"$$\n",
"\n",
"which gives the weights\n",
"\n",
"$$\n",
"w_0 = \\int_{0}^1 \\ell_0(x){\\,\\mathrm{d}x} = \\frac{1}{6}, \\qquad\n",
"w_1 = \\int_{0}^1 \\ell_1(x){\\,\\mathrm{d}x} = \\frac{4}{6}, \\qquad\n",
"w_2 = \\int_{0}^1 \\ell_2(x){\\,\\mathrm{d}x} = \\frac{1}{6}\n",
"$$\n",
"\n",
"such that\n",
"\n",
"$$\n",
"\\int_{0}^1 f(x) {\\,\\mathrm{d}x} \\approx \\int_{0}^1 p_2(x) {\\,\\mathrm{d}x}\n",
"= \\sum_{i=0}^2 w_i f(x_i) = \\frac{1}{6} \\left[\\; f(0) + 4 f(0.5) + f(1) \\; \\right].\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"\n",
"\n",
"## Exercise 1: Accuracy of some quadrature rules\n",
"\n",
"\n",
"Use the `QR` function"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"source": [
"def QR(f, xq, wq):\n",
" \"\"\"Computes an approximation of the integral f\n",
" for a given quadrature rule.\n",
"\n",
" Input:\n",
" f: integrand\n",
" xq: quadrature nodes\n",
" wq: quadrature weights\n",
" \"\"\"\n",
" n = len(xq)\n",
" if n != len(wq):\n",
" raise RuntimeError(\"Error: Need same number of quadrature nodes and weights!\")\n",
" return np.array(wq) @ f(np.array(xq))"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"to compute an approximate value of integral\n",
"\n",
"$$\n",
"I(0,1) = \\int_0^1 \\cos\\left(\\frac{\\pi}{2}x\\right) = \\frac{2}{\\pi} = 0.636619\\dotsc.\n",
"$$\n",
"\n",
"using the quadrature rules from Example [Example 2: The trapezoidal rule revisited](#ex:trapezoidalrule)-[Example 4: Simpson's rule revisited](#ex:simpson).\n",
"Tabulate the corresponding quadrature errors $I(0,1) - Q(0,1)$."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"source": [
"# Insert your code here."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"\n",
"\n",
"**Hint.**\n",
"You can start with (fill in values for any $\\ldots$)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"source": [
"# Define function\n",
"\n",
"\n",
"def f(x):\n",
" return ...\n",
"\n",
"\n",
"# Exact integral\n",
"int_f = ...\n",
"\n",
"# Trapezoidal rule\n",
"xq = [...]\n",
"wq = [..., ...]\n",
"\n",
"qr_f = QR(f, xq, wq)\n",
"print(f\"Q[f] = {qr_f}\")\n",
"print(f\"I[f] - Q[f] = {int_f - qr_f:.10e}\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"\n",
"\n",
"\n",
"\n",
"### Remarks\n",
"\n",
"We observe that with the same number of quadrature points,\n",
"the Gauß-Legendre quadrature gives a much more accurate answer\n",
"then the trapezoidal rule. So the choice of nodes clearly matters.\n",
"Simpon's rule gives very similar results\n",
"to Gauß-Legendre quadrature, but it uses 3 instead of 2 quadrature nodes.\n",
"\n",
"\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Degree of exactness and an estimate of the quadrature error\n",
"Motivated by the previous examples, we know take a closer look at how\n",
"assess the quality of a method. We start with the following definition."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Definition 1: The degree of exactness\n",
"\n",
"A numerical quadrature has degree of exactness $d$ if $Q[p](a,b) =\n",
"I[p](a,b)$ for all $p \\in \\mathbb{P}_d$ and there is at least one\n",
"$p\\in \\mathbb{P}_{d+1}$ such that $Q[p](a,b) \\not= I[p](a,b)$."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Since both integrals and quadratures are linear in the integrand $f$,\n",
"the degree of exactness is $d$ if\n",
"\n",
"$$\n",
"\\begin{align*}\n",
"I[x^j](a,b) &= Q[x^j](a,b), \\qquad j=0,1,\\dotsc, d, \\\\ \n",
"I[x^{d+1}](a,b) &\\not= Q[x^{d+1}](a,b).\n",
"\\end{align*}\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"**Observation:**\n",
"All quadratures constructed from Lagrange interpolation polynomials in\n",
"$n+1$ distinct nodes will automatically have a degree of exactness of least $n$.\n",
"This follows immediately from the fact the interpolation polynomial\n",
"$p_n \\in \\mathbb{P}_n$ of any polynomial $q \\in \\mathbb{P}_n$ is just the original\n",
"polynomial $q$ itself."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"\n",
"\n",
"## Exercise 2: Degree of exactness for some quadrature rules\n",
"\n",
"* Show that the trapezoidal and midpoint rule from Example [Example 1: Quadrature rules from previous math courses](#ex:qr-from-m1) is of precision 1\n",
"\n",
"* Show that the Gauß-Legendre quadrature for 2 points from Example\n",
" [Example 3: Gauß-Legendre quadrature for $n=2$](#ex:gauss-legend-quad) is of precision 3.\n",
"\n",
"* Show that Simpson's rule from Example [Example 4: Simpson's rule revisited](#ex:simpson) is also of precision 3."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"outputs": [],
"source": [
"# Insert your code here."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"\n",
"\n",
"**Hint.**\n",
"You can do this either using pen and paper (boring!) or numerically (more fun!),\n",
"using the code from Example [Exercise 1: Accuracy of some quadrature rules](#quad:ex:accuracy_qr)\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"**Solution.**"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"\n",
"\n",
"\n",
"\n",
"\n",
"## Error estimates\n",
"\n",
"\n",
"\n",
"## Theorem 1: Error estimate for quadrature rule with degree of exactness $n$"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Assume that $f \\in C^{n+1}(a,b)$ and\n",
"let $Q[\\cdot](\\{x_i\\}_{i=0}^n, \\{w_i\\}_{i=0}^n)$\n",
"be a quadrature rule which has degree of exactness\n",
"$n$.\n",
"Then the quadrature error $|I[f]-Q[f]|$ can be estimated by\n",
"\n",
"$$\n",
"|I[f]-Q[f]| \\leqslant \\frac{M}{(n+1)!}\\int_a^b \\prod_{i=0}^n |x-x_i|{\\,\\mathrm{d}x}\n",
"$$\n",
"\n",
"where $M=\\max_{\\xi \\in [a,b]} |f^{n+1}(\\xi)|$."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"**Proof.**\n",
"Let $p_n \\in \\mathbb{P}_n$ be the interpolation polynomial satisfying\n",
"$p_n(x_i) = f(x_i)$ for $i=0,\\ldots,n$.\n",
"Thanks to the error estimate for the interpolation error, we know that\n",
"\n",
"$$\n",
"f(x)-p_n(x)=\\frac{f^{n+1}(\\xi(x))}{(n+1)!}\\prod_{k=0}^{n}(x-x_{k}).\n",
"$$\n",
"\n",
"for some $\\xi(x) \\in (a,b)$.\n",
"Since $Q(a,b)$ has degree of exactness $n$ we have $I[p_n] = Q[p_n] = Q[f]$\n",
"and thus"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"$$\n",
"\\begin{align*}\n",
"|I[f]-Q[f]|\n",
"=\n",
"|I[f]-I[p_n]|\n",
"&\\leqslant\n",
"\\int_a^b\n",
"|f(x)-p_n(x)| {\\,\\mathrm{d}x}\n",
"\\\\ \n",
"&=\n",
"\\int_a^b\n",
"\\Biggl|\n",
"\\frac{f^{n+1}(\\xi(x))}{(n+1)!}\\prod_{k=0}^{n}(x-x_{k})\n",
"\\Biggr| {\\,\\mathrm{d}x}\n",
"\\leqslant\n",
"\\frac{M}{(n+1)!}\n",
"\\int_a^b\n",
"\\prod_{k=0}^{n}|(x-x_{k})|\n",
"{\\,\\mathrm{d}x},\n",
"\\end{align*}\n",
"$$\n",
"\n",
"which concludes the proof."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"The previous theorem often\n",
"The advantage of the previous theorem is\n",
"that it is easy to prove.\n",
"On downside is that the provided estimate can be rather\n",
"crude, and often sharper estimates can be established.\n",
"We give two examples here of some sharper estimates\n",
"(but without proof)."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Theorem 2: Error estimate for the trapezoidal rule\n",
"\n",
"For the trapezoidal rule, there is a $\\xi \\in (a,b)$ such that\n",
"\n",
"$$\n",
"I[f]-Q[f]=\\frac{(b-a)^3}{12}f''(\\xi).\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Theorem 3: Error estimate for Simpson's rule\n",
"\n",
"For Simpson's rule, there is a $\\xi \\in (a,b)$ such that\n",
"$$\n",
"I[f]-Q[f]=-\\frac{(b-a)^5}{2880} f^4(\\xi).\n",
"$$"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
}
},
"nbformat": 4,
"nbformat_minor": 4
}