Skip to content

Commit 6109f69

Browse files
committed
Post-lecture updates
1 parent 96337ab commit 6109f69

File tree

2 files changed

+31
-11
lines changed

2 files changed

+31
-11
lines changed

src/09_Numerical_integration.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -976,7 +976,7 @@ On the others the function values are already known (as they were needed at the
976976
"""
977977

978978
# ╔═╡ 57e9518b-b8d8-4d4e-911c-9034afd807f6
979-
RobustLocalResource("https://raw.githubusercontent.com/epfl-matmat/numerical-analysis/master/notes/img/node-doubling.svg", "img/node-doubling.svg", :width => 600)
979+
RobustLocalResource("https://github.com/epfl-matmat/numerical-analysis/blob/30a76271c3fa3be9d24896ecd2450d18fa505df3/src/img/node-doubling.svg", "img/node-doubling.svg", :width => 600)
980980

981981
# ╔═╡ d5885f27-7171-4a78-a32f-ead4a4791b0b
982982
md"""

src/12_Boundary_value_problems.jl

Lines changed: 30 additions & 10 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
@@ -68,7 +68,7 @@ md"""
6868
"""
6969

7070
# ╔═╡ 93b28014-c767-4f40-b27c-4646f63faa89
71-
RobustLocalResource("https://raw.githubusercontent.com/epfl-matmat/numerical-analysis/master/notes/img/node-doubling.svg", "img/heat-equation.svg", :width => 500)
71+
RobustLocalResource("https://raw.githubusercontent.com/epfl-matmat/numerical-analysis/30a76271c3fa3be9d24896ecd2450d18fa505df3/src/img/heat-equation.svg", "img/heat-equation.svg", :width => 500)
7272

7373
# ╔═╡ f1b662de-b4cf-4a73-9c00-580a2ea8a428
7474
md"""
@@ -180,7 +180,7 @@ Similar to our approach when [solving initial value problems (chapter 11)](https
180180
we **divide the full interval $[0, L]$ into $N+1$ subintervals** $[x_j, x_{j+1}]$
181181
of uniform size $h$, i.e.
182182
```math
183-
x_j = j\, h \quad j = 0, \ldots, N, \qquad h = \frac{L}{N+1}.
183+
x_j = j\, h \quad j = 0, \ldots, N+1, \qquad h = \frac{L}{N+1}.
184184
```
185185
Our goal is thus to find approximate points $u_j$ such that $u_j ≈ u(x_j)$ at the nodes $x_j$.
186186
"""
@@ -762,7 +762,7 @@ The original problem (17) is additionally called the **strong form** of the heat
762762
!!! info "Observation: Strong and weak solutions"
763763
If $u$ is a solution to the strong form (17) of a BVP,
764764
than it is also a solution to the weak form (19).
765-
However, **not every weak solution as also a strong solution**.
765+
However, **not every weak solution is also a strong solution**.
766766
"""
767767

768768
# ╔═╡ 79816267-531b-4b99-bdea-1194574dd160
@@ -1070,22 +1070,42 @@ end
10701070
md"""We see that already for 5 $\sin$ basis functions it becomes visually very hard to see the difference to the reference solution with $300$ basis functions.
10711071
10721072
Numerically we observe a **quadratic convergence** in a log-log plot:
1073+
1074+
- Show finite difference approximation of same size ($N = m$) $(@bind show_fd CheckBox(; default=false))
10731075
"""
10741076

10751077
# ╔═╡ 1d55c98e-4ed9-4ac4-a847-b18432483472
10761078
let
10771079
x = range(0, π; length=1000)
1078-
reference(x) = sine_solution(300, x)
1080+
reference(x) = sine_solution(800, x)
10791081

1080-
ms = [5, 10, 20, 40, 50, 60, 80, 100]
1082+
ms = [5, 10, 20, 40, 50, 60, 80, 100, 300]
10811083
errors = Float64[]
10821084
for m in ms
10831085
error = [abs(sine_solution(m, xᵢ) - reference(xᵢ)) for xᵢ in x]
10841086
push!(errors, maximum(error))
10851087
end
10861088

1087-
p = plot(ms, errors, yaxis=:log, xaxis=:log, lw=2, mark=:o, title=L"Convergence in $m$", xlabel=L"m", ylabel="maximal error", label="Error")
1089+
p = plot(ms, errors, yaxis=:log, xaxis=:log, lw=2, mark=:o, title=L"Convergence in $m$", xlabel=L"m", ylabel="maximal error", label="Error sin Galerkin")
10881090
plot!(p, ms, 1 ./ms.^2, ls=:dash, lw=2, label=L"O(m^2)")
1091+
1092+
ylims!(p, (1e-6, 1e-1))
1093+
xticks!(p, 10.0 .^ (0:0.5:3))
1094+
yticks!(p, 10.0 .^ (0:-1:-6))
1095+
1096+
if show_fd
1097+
errors_fd = Float64[]
1098+
for N in ms
1099+
res_fd = fd_dirichlet(f, L, α, β, N)
1100+
x = res_fd.x
1101+
u = res_fd.u
1102+
error = [ u_exact(x[j]) - u[j] for j in 1:length(x)]
1103+
push!(errors_fd, maximum(error))
1104+
end
1105+
plot!(p, ms, errors_fd; lw=2, mark=:o, c=3, label="Error finite-differences")
1106+
end
1107+
1108+
p
10891109
end
10901110

10911111
# ╔═╡ 3348115a-2fd4-4935-9dba-b85d9e0c95f5
@@ -1118,7 +1138,7 @@ PlutoUI = "~0.7.59"
11181138
PLUTO_MANIFEST_TOML_CONTENTS = """
11191139
# This file is machine-generated - editing it directly is not advised
11201140
1121-
julia_version = "1.11.4"
1141+
julia_version = "1.11.5"
11221142
manifest_format = "2.0"
11231143
project_hash = "386992f2ee9496aea372b754edcbbad6c546e5b7"
11241144
@@ -1659,7 +1679,7 @@ version = "0.3.27+1"
16591679
[[deps.OpenLibm_jll]]
16601680
deps = ["Artifacts", "Libdl"]
16611681
uuid = "05823500-19ac-5b8b-9628-191a04bc5112"
1662-
version = "0.8.1+4"
1682+
version = "0.8.5+0"
16631683
16641684
[[deps.OpenSSL]]
16651685
deps = ["BitFlags", "Dates", "MozillaCACerts_jll", "OpenSSL_jll", "Sockets"]
@@ -2376,7 +2396,7 @@ version = "1.4.1+2"
23762396
# ╟─d0a2133c-47d0-40d5-8508-18bb046d92d1
23772397
# ╟─aa589aa5-1a5c-4782-af66-2509f21ac891
23782398
# ╟─4fee47fc-077d-4921-8572-7820ab84988e
2379-
# ╟─1d55c98e-4ed9-4ac4-a847-b18432483472
2399+
# ╠═1d55c98e-4ed9-4ac4-a847-b18432483472
23802400
# ╟─3348115a-2fd4-4935-9dba-b85d9e0c95f5
23812401
# ╟─00000000-0000-0000-0000-000000000001
23822402
# ╟─00000000-0000-0000-0000-000000000002

0 commit comments

Comments
 (0)