Skip to content

Commit 4b35e3f

Browse files
committed
Post-lecture updates
1 parent e165e79 commit 4b35e3f

4 files changed

+50
-18
lines changed

src/03_Preliminaries.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### A Pluto.jl notebook ###
2-
# v0.20.5
2+
# v0.20.6
33

44
using Markdown
55
using InteractiveUtils
@@ -477,6 +477,9 @@ md"""
477477
```
478478
"""
479479

480+
# ╔═╡ 69b0a1cf-a1dd-48e4-8d00-564509902e3e
481+
TODO("Triangle inequality, triangle inequality for sums")
482+
480483
# ╔═╡ 831aef2e-e129-4183-95c2-b6f98afb6b44
481484
let
482485
RobustLocalResource("https://teaching.matmat.org/numerical-analysis/sidebar.md", "sidebar.md")
@@ -897,6 +900,7 @@ version = "17.4.0+2"
897900
# ╟─e363da18-0001-4870-adb5-ef7d73514a36
898901
# ╟─bd53a113-a153-405e-9340-da78a61b775a
899902
# ╟─f8720ba3-9f6e-476c-adf2-bf66e07c3755
903+
# ╠═69b0a1cf-a1dd-48e4-8d00-564509902e3e
900904
# ╟─831aef2e-e129-4183-95c2-b6f98afb6b44
901905
# ╟─00000000-0000-0000-0000-000000000001
902906
# ╟─00000000-0000-0000-0000-000000000002

src/08_Eigenvalue_problems.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### A Pluto.jl notebook ###
2-
# v0.20.5
2+
# v0.20.6
33

44
using Markdown
55
using InteractiveUtils
@@ -1117,7 +1117,7 @@ PlutoUI = "~0.7.56"
11171117
PLUTO_MANIFEST_TOML_CONTENTS = """
11181118
# This file is machine-generated - editing it directly is not advised
11191119
1120-
julia_version = "1.11.4"
1120+
julia_version = "1.11.5"
11211121
manifest_format = "2.0"
11221122
project_hash = "ed4b990b71c74481d1b3d103b825239737d31586"
11231123
@@ -1658,7 +1658,7 @@ version = "0.3.27+1"
16581658
[[deps.OpenLibm_jll]]
16591659
deps = ["Artifacts", "Libdl"]
16601660
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
1661-
version = "0.8.1+4"
1661+
version = "0.8.5+0"
16621662
16631663
[[deps.OpenSSL]]
16641664
deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"]
@@ -2310,6 +2310,7 @@ version = "1.4.1+2"
23102310
# ╟─34beda8f-7e5f-42eb-b32c-73cfc724062e
23112311
# ╠═4949225a-ccf2-11ee-299b-9b834eb6bd42
23122312
# ╟─13298dc4-9800-476d-9474-182359a7671b
2313+
# ╟─1980cffb-4b56-4b66-8100-a730da0c89f5
23132314
# ╟─a138fb39-aae0-41b4-bd7b-d2f7eaad7a53
23142315
# ╟─a702d4b6-e70c-417d-ac98-92c534d52770
23152316
# ╟─73889935-2e4c-4a15-a281-b155cf1ca1c9

src/09_Numerical_integration.jl

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ and
239239
```math
240240
I = \int_0^1 e^x\,dx = e - 1
241241
```
242-
which is approximately $(exact).
242+
which is approximately $(round(exact; digits=7)).
243243
244244
We 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
323323
md"""
324324
Considering the construction of the trapezoidal rule
325325
we 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
&= \frac h6 f(t_0) + \frac h3 \sum_{i=1}^{n-1} f(t_i) + \frac {2h}3 \sum_{i=0}^{n-1} f(m_i) + \frac h6 f(t_n).
341341
\end{aligned}
342342
```
343+
"""
344+
345+
# ╔═╡ 5ee0ec01-54c3-48d8-8ba8-4460144002dd
346+
md"""
343347
While a little harder to see, this formula can also be brought into the form of (2):
344348
it employs **$2n + 1$ equispaced nodes**
345349
--- namely the collection of both the $t_i$ for $i=0, \ldots, n$ *and* the $m_i$ for $i=0,\ldots n-1$.
346350
Therefore $N = 2n$ in (2) leading to a **nodal distance** of $\frac{b-a}{2n} = \frac{h}{2}$, where we used that $h = t_{i+1} - t_i = \frac{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+
\int_a^b p_{2,h}(x)\, dx = \sum_{i=1}^n \frac h6 \big( f(t_{i-1}) + 4f(m_{i-1}) + f(t_i) \big)
359+
```
360+
"""
347361

362+
# ╔═╡ 277ec8d1-949b-457a-8c1a-12d357a76efc
363+
md"""
348364
A 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]$.
437453
Assume for simplicity that the function $f$ is smooth and we can thus
438454
build a Taylor expansion
439455
```math
440-
\tag{5}
441456
f(x) = \sum_{k=0}^\infty \frac{1}{k!} f^{(k)}(m_i) \, (x-m_i)^k
442457
```
443458
around the midpoint $m_i = \frac{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)
475490
The difference between these expressions is exactly the error
476491
contribution from the interval $[t_{i}, t_{i+1}]$, namely
477492
```math
493+
\tag{5}
478494
\begin{aligned}
479495
\int_{t_i}^{t_{i+1}} f(x)\,dx - Q_{t_i}^{t_{i+1}}(f)
480496
&= \sum_{k=0}^\infty \frac{1}{k!} f^{(k)}(m) \left[ \int_{t_i}^{t_{i+1}} q_k(x) - Q_{t_i}^{t_{i+1}}(q_k) \right].
@@ -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
509525
md"""
510526
Note that the polynomial $q_k = ( x - m_i )^{k}$
511527
only features monomials $x^s$ with $0 \leq s \leq k$.
512528
Therefore a formula with degree of exactness $r$ will have
513529
$\int_{t_i}^{t_{i+1}} q_k(x) - Q_{t_i}^{t_{i+1}}(q_k) = 0$ for $k \leq r$.
514-
The first non-zero error term is thus
530+
In (5) the first non-zero error term is thus
515531
```math
516532
\begin{aligned}
517533
\left|\int_{t_i}^{t_{i+1}} q_{r+1}(x) - Q_{t_i}^{t_{i+1}}(q_{r+1})\right|
@@ -522,20 +538,27 @@ The first non-zero error term is thus
522538
```
523539
where 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,
524540
which are optional and will be presented below.
541+
This is also the leading-order error term, such that
542+
```math
543+
\left|\int_{t_i}^{t_{i+1}} f(x)\,dx - Q_{t_i}^{t_{i+1}}(f)\right| ≤ \widetilde{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,
527550
such that combining with (4) and using the triangle inequality
528551
we obtain the total error as
529552
```math
530553
\begin{aligned}
531554
\left|\int_a^b f(x)\,dx - Q_a^b(f)\right|
532555
&\leq \sum_{i=0}^{N-1} \left|\int_{t_i}^{t_{i+1}} f(x)\,dx - Q_{t_i}^{t_{i+1}}(f)\right|\\
533-
&\leq h^{r+2} \underbrace{\sum_{i=0}^{N-1} \tilde{C}_i}_\text{$N$ terms}\\
534-
&\leq h^{r+1} \frac{b-a}{N} N \, \max_i \tilde{C}_i \\
556+
&\leq h^{r+2} \underbrace{\sum_{i=0}^{N-1} \widetilde{C}_i}_\text{$N$ terms}\\
557+
&\leq h^{r+1} \frac{b-a}{N} N \, \max_i \widetilde{C}_i \\
535558
&= C \, h^{r+1}
536559
\end{aligned}
537560
```
538-
where $C = (b-a) \max_i \tilde{C}_i$.
561+
where $C = (b-a)\, \max_i \widetilde{C}_i$.
539562
540563
We notice:
541564
"""
@@ -768,7 +791,7 @@ this scheme is able to **increase the convergence order**.
768791

769792
# ╔═╡ 15b22584-5f21-4f00-ac04-0643fb1dfd56
770793
md"""
771-
Let us apply this to the trapezoidal formula for approximating the integral $I = \int_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 = \int_a^b f(x)\, dx$. We use $n+1$ quadrature nodes of equal separation $h = (b-a)/n$.
772795
As we have discussed above the trapezoidal formula is of order $2$,
773796
so the leading-order error term is $h^2$.
774797
However, 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
10451068
R80 = (16S80 - 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
10511074
begin
@@ -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

src/11_Initial_value_problems.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ Often (but not always) $t$ plays the role of time and (1) thus models the time-d
134134

135135
# ╔═╡ 1dbe5d72-17d9-4f20-b365-ad913cd607c3
136136
md"""
137-
## Numerical solution in DifferentialEquations.jl
137+
## Solving initial value problems numerically
138138
For simple examples like the Duck problem above
139139
analytic solutions can still be found with a little practice.
140140
However, initial value problems quickly become more involved.

0 commit comments

Comments
 (0)