239239```math
240240I = \i nt_0^1 e^x\, dx = e - 1
241241```
242- which is approximately $(exact) .
242+ which is approximately $(round( exact; digits = 7 ) ) .
243243
244244We consider a sequence of results where we double the number of integration points:
245245"""
@@ -319,7 +319,7 @@ md"""
319319## Simpson's rule
320320"""
321321
322- # ╔═╡ fb9420e4-d49c-4cfe-b029-c3a0e92f9af2
322+ # ╔═╡ becdcc4e-ecff-46ad-8f3a-92d117e374f7
323323md"""
324324Considering the construction of the trapezoidal rule
325325we may easily wonder: why stop at using only linear polynomials
@@ -340,11 +340,27 @@ This is a little harder to compute and will be done as an exercise. The resultin
340340&= \f rac h6 f(t_0) + \f rac h3 \s um_{i=1}^{n-1} f(t_i) + \f rac {2h}3 \s um_{i=0}^{n-1} f(m_i) + \f rac h6 f(t_n).
341341\e nd{aligned}
342342```
343+ """
344+
345+ # ╔═╡ 5ee0ec01-54c3-48d8-8ba8-4460144002dd
346+ md"""
343347While a little harder to see, this formula can also be brought into the form of (2):
344348it employs **$2n + 1$ equispaced nodes**
345349--- namely the collection of both the $t_i $ for $i =0, \l dots, n$ *and* the $m_i $ for $i =0,\l dots n-1$.
346350Therefore $N = 2n$ in (2) leading to a **nodal distance** of $\f rac{b-a}{2n} = \f rac{h}{2}$, where we used that $h = t_{i+1} - t_i = \f rac{b-a}{n}$
351+ """
352+
353+ # ╔═╡ abcafa59-e8a1-4438-9ff6-3e8fc9fbd28d
354+ md"""
355+ !!! exercise
356+ Derive Simpson's rule, i.e. show that
357+ ```math
358+ \i nt_a^b p_{2,h}(x)\, dx = \s um_{i=1}^n \f rac h6 \b ig( f(t_{i-1}) + 4f(m_{i-1}) + f(t_i) \b ig)
359+ ```
360+ """
347361
362+ # ╔═╡ 277ec8d1-949b-457a-8c1a-12d357a76efc
363+ md"""
348364A Julia implementation of Simpson's rule is given below:
349365"""
350366
@@ -437,7 +453,6 @@ into error contributions from each of the intervals $[t_{i-1}, t_i]$.
437453Assume for simplicity that the function $f $ is smooth and we can thus
438454build a Taylor expansion
439455```math
440- \t ag{5}
441456f(x) = \s um_{k=0}^\i nfty \f rac{1}{k!} f^{(k)}(m_i) \, (x-m_i)^k
442457```
443458around the midpoint $m_i = \f rac{t_{i+1} + t_i}{2}$ of the interval $[t_i, t_{i+1}]$.
@@ -475,6 +490,7 @@ h\, \sum_{i=0}^1 w_i \, q_k(t_i)
475490The difference between these expressions is exactly the error
476491contribution from the interval $[t_{i}, t_{i+1}]$, namely
477492```math
493+ \t ag{5}
478494\b egin{aligned}
479495\i nt_{t_i}^{t_{i+1}} f(x)\, dx - Q_{t_i}^{t_{i+1}}(f)
480496&= \s um_{k=0}^\i nfty \f rac{1}{k!} f^{(k)}(m) \l eft[ \i nt_{t_i}^{t_{i+1}} q_k(x) - Q_{t_i}^{t_{i+1}}(q_k) \r ight].
@@ -505,13 +521,13 @@ One property of quadrature formulas is their **degree of exactness**:
505521 but not for $s = r+1$.
506522"""
507523
508- # ╔═╡ ca54c435-1a49-48e6-9fc9-d0f5a0fe12a4
524+ # ╔═╡ bc2043be-41e0-4083-9f8b-82b3ce6a13af
509525md"""
510526Note that the polynomial $q_k = ( x - m_i )^{k}$
511527only features monomials $x ^s$ with $0 \l eq s \l eq k$.
512528Therefore a formula with degree of exactness $r $ will have
513529$\i nt_{t_i}^{t_{i+1}} q_k(x) - Q_{t_i}^{t_{i+1}}(q_k) = 0$ for $k \l eq r$.
514- The first non-zero error term is thus
530+ In (5) the first non-zero error term is thus
515531```math
516532\b egin{aligned}
517533\l eft|\i nt_{t_i}^{t_{i+1}} q_{r+1}(x) - Q_{t_i}^{t_{i+1}}(q_{r+1})\r ight|
@@ -522,20 +538,27 @@ The first non-zero error term is thus
522538```
523539where in $(\ ast) $ all powers in $x $ less than $r +1$ drop again because of $Q $'s degree of exactness and in $(\ S) $ we skipped a few non-trivial steps,
524540which are optional and will be presented below.
541+ This is also the leading-order error term, such that
542+ ```math
543+ \l eft|\i nt_{t_i}^{t_{i+1}} f(x)\, dx - Q_{t_i}^{t_{i+1}}(f)\r ight| ≤ \w idetilde{C}_i h^{r+2}
544+ ```
545+ """
525546
526- We thus note that the individual intervals converge with $(r+ 2 ) $-th order,
547+ # ╔═╡ 9cb44731-9d50-4718-9d4d-8fffca3a387f
548+ md"""
549+ The error in each of the the $N $ subintervals thus converges with $(r+ 2 ) $-th order,
527550such that combining with (4) and using the triangle inequality
528551we obtain the total error as
529552```math
530553\b egin{aligned}
531554\l eft|\i nt_a^b f(x)\, dx - Q_a^b(f)\r ight|
532555&\l eq \s um_{i=0}^{N-1} \l eft|\i nt_{t_i}^{t_{i+1}} f(x)\, dx - Q_{t_i}^{t_{i+1}}(f)\r ight|\\
533- &\l eq h^{r+2} \u nderbrace{\s um_{i=0}^{N-1} \t ilde {C}_i}_\t ext{$N $ terms}\\
534- &\l eq h^{r+1} \f rac{b-a}{N} N \, \m ax_i \t ilde {C}_i \\
556+ &\l eq h^{r+2} \u nderbrace{\s um_{i=0}^{N-1} \w idetilde {C}_i}_\t ext{$N $ terms}\\
557+ &\l eq h^{r+1} \f rac{b-a}{N} N \, \m ax_i \w idetilde {C}_i \\
535558&= C \, h^{r+1}
536559\e nd{aligned}
537560```
538- where $C = (b-a) \m ax_i \t ilde {C}_i$.
561+ where $C = (b-a)\, \m ax_i \w idetilde {C}_i$.
539562
540563We notice:
541564"""
@@ -768,7 +791,7 @@ this scheme is able to **increase the convergence order**.
768791
769792# ╔═╡ 15b22584-5f21-4f00-ac04-0643fb1dfd56
770793md"""
771- Let us apply this to the trapezoidal formula for approximating the integral $I = \i nt_a^b f(x)\, dx$. We use $n +1$ quadrature nodes of equal separation $h = (b-a)/n$.
794+ Let us ** apply this to the trapezoidal formula** for approximating the integral $I = \i nt_a^b f(x)\, dx$. We use $n +1$ quadrature nodes of equal separation $h = (b-a)/n$.
772795As we have discussed above the trapezoidal formula is of order $2$,
773796so the leading-order error term is $h ^2$.
774797However, in this fortunate case one can even show
@@ -1045,7 +1068,7 @@ md"Finally, we perform one more level of extrapolation to get the sxth-order acc
10451068R80 = (16 S80 - S40) / 15
10461069
10471070# ╔═╡ cf6e7935-268e-458a-990a-39432ab3e9f3
1048- md" We compute all errors to 6 digits:"
1071+ md" We compute all errors to 10 digits:"
10491072
10501073# ╔═╡ cc54215f-3af2-48c0-83ec-04cc786fd2ce
10511074begin
@@ -2449,7 +2472,10 @@ version = "1.4.1+2"
24492472# ╟─f189cf70-d72e-483c-af61-a3346ddd201d
24502473# ╟─5f0178ad-c05b-4ac4-a008-b35d105cc7b2
24512474# ╟─c31c7012-6986-441f-ae99-5e2bb2b469e5
2452- # ╟─fb9420e4-d49c-4cfe-b029-c3a0e92f9af2
2475+ # ╟─becdcc4e-ecff-46ad-8f3a-92d117e374f7
2476+ # ╟─5ee0ec01-54c3-48d8-8ba8-4460144002dd
2477+ # ╟─abcafa59-e8a1-4438-9ff6-3e8fc9fbd28d
2478+ # ╟─277ec8d1-949b-457a-8c1a-12d357a76efc
24532479# ╠═538b816c-5cc3-4e5c-b259-33825bdc39c3
24542480# ╟─a255138c-74bd-4aad-b49a-0a16746f3bda
24552481# ╠═df5373cc-b997-4a80-906a-9bde0689c84b
@@ -2458,7 +2484,8 @@ version = "1.4.1+2"
24582484# ╟─adf895be-b9d1-40e1-9c2b-146b30b996be
24592485# ╟─4144570b-f8d9-49c8-af6b-732966864755
24602486# ╟─7812f9d7-cda7-4d05-a800-3f7bea2e0e8c
2461- # ╟─ca54c435-1a49-48e6-9fc9-d0f5a0fe12a4
2487+ # ╟─bc2043be-41e0-4083-9f8b-82b3ce6a13af
2488+ # ╟─9cb44731-9d50-4718-9d4d-8fffca3a387f
24622489# ╟─4a048166-315d-4bf6-b099-866c9e3f8813
24632490# ╟─9bad55de-c2d7-44f9-9478-7b66751bfbfe
24642491# ╟─a4cf020a-bb95-4fed-ad50-11ebae1934f5
0 commit comments