Skip to content

Commit 5048b81

Browse files
committed
Updates
1 parent 6af032b commit 5048b81

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

src/06_Direct_methods.jl

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ which leads to the following algorithm:
857857
3. Solve $\mathbf U \mathbf x = \mathbf z$ for $\mathbf x$
858858
using *backward* substitution.
859859
860-
860+
When we use Julia's backslash `\`-operator, effectively this **Algorithm 5** is executed under the hood.
861861
"""
862862

863863
# ╔═╡ 40f6f4c5-dc86-4834-a6c2-51852d87a3bb
@@ -904,22 +904,6 @@ md"""**Verify result:** This solves the problem $\mathbf{D} \mathbf{x}_D = \math
904904
# ╔═╡ 25f18e3c-a00b-4d3a-9b5e-60d40eeb5596
905905
D * xD - b
906906

907-
# ╔═╡ cdaead03-fbd7-4ff6-9f31-6296e8d5230f
908-
md"""
909-
## Conclusion: What backslash \ really does to solve
910-
911-
To conclude this discussion we return to our starting question:
912-
What does the `\` operator do in Julia.
913-
914-
- We already saw that julia essentially solves `A \ b` by replacing it by `lu(A) \ b`.
915-
- Julia's `lu` by default also performs a row-pivoted LU factorisation,
916-
providing thus a factorisation $\textbf P \mathbf{A} = \mathbf{L} \mathbf{U}$.
917-
- The returned object (an `LinearAlgebra.LU` object) internally stores
918-
both the `L`, the `U` and the permutation matrix `P`
919-
- When we use `\` with an `LU` object it, Julia immediately exploits the factorised form and performs first (permuted) forward substitution (step 2.) then backward substitution (step 3.).
920-
- Therefore overall `A \ b` exactly performs Algorithm 5 above.
921-
"""
922-
923907
# ╔═╡ 48979215-458c-40f5-82e4-a4485390bca4
924908
md"""
925909
## Optional: More details on pivoting
@@ -1312,10 +1296,10 @@ Before we look at the LU algorithm (Algorithm 4) we first understand a few simpl
13121296
# ╔═╡ c0b02aa0-642c-4a6f-ac21-cdb8e27d9279
13131297
md"""
13141298
### Scalar product
1315-
Given two vectors $x, y \in \mathbb{R}^n$ consider computing
1299+
Given two vectors $\textbf x, \textbf y \in \mathbb{R}^n$ consider computing
13161300
the scalar product
13171301
```math
1318-
x \cdot y = x^T y = \sum_{i=1}^n x_i \, y_i
1302+
\textbf x \cdot \textbf y = \textbf x^T \textbf y = \sum_{i=1}^n x_i \, y_i
13191303
```
13201304
which in code is achieved as
13211305
"""
@@ -1340,8 +1324,8 @@ If we take the dimensionality $n=1000$ the number of operations is $O(1000)$. On
13401324
md"""
13411325
### Matrix-vector product
13421326
1343-
Given a matrix $A \in \mathbb{R}^{n\times n}$ and a vector $x \in \mathbb{R}^n$
1344-
the matrix-vector product $y = Ax$ is computed as
1327+
Given a matrix $\textbf A \in \mathbb{R}^{n\times n}$ and a vector $\textbf x \in \mathbb{R}^n$
1328+
the matrix-vector product $\textbf y = \textbf A \textbf x$ is computed as
13451329
```math
13461330
y_i = \sum_{j=1}^{n} A_{ij} x_j \qquad \text{for $i = 1, \ldots, n$}
13471331
```
@@ -1366,8 +1350,8 @@ In the innermost loop we observe again that we require
13661350
$1$ addition and $1$ multiplication per iteration.
13671351
This instruction is performed once for each combination of $i$ and $j$,
13681352
so we look at the limits of each of the nested loops.
1369-
The loop over $i$ runs over $n$ values (the number of rows of $A$)
1370-
and the loop over $j$ over $n$ values as well (the number of columns of $A$).
1353+
The loop over $i$ runs over $n$ values (the number of rows of $\textbf A$)
1354+
and the loop over $j$ over $n$ values as well (the number of columns of $\textbf A$).
13711355
In total the inner most instruction `(*)` is thus run $n^2$ times,
13721356
each times costing $2$ operations.
13731357
The total **cost is thus $O(n^2)$**.
@@ -2412,7 +2396,6 @@ version = "17.4.0+2"
24122396
# ╠═e13c4c6e-b55c-4360-9ec4-501042490d59
24132397
# ╟─38deeaeb-0596-48d5-b671-2d1fc2e73a27
24142398
# ╠═25f18e3c-a00b-4d3a-9b5e-60d40eeb5596
2415-
# ╟─cdaead03-fbd7-4ff6-9f31-6296e8d5230f
24162399
# ╟─48979215-458c-40f5-82e4-a4485390bca4
24172400
# ╟─827a75c2-2e3c-4da4-8deb-6c8a999596f2
24182401
# ╟─f4a02392-ca42-44ac-bd1c-13cb3d6fafa2

0 commit comments

Comments
 (0)