english improved

This commit is contained in:
2026-03-05 20:09:16 +01:00
parent c6609d15f5
commit 733fe8c290
21 changed files with 954 additions and 1042 deletions

View File

@@ -15,9 +15,9 @@ using InteractiveUtils
using LinearAlgebra
```
The `LinearAlgebra` package provides among other things:
The `LinearAlgebra` package provides, among other things:
- additional subtypes of `AbstractMatrix`: usable like other matrices, e.g.,
- additional subtypes of `AbstractMatrix` which are usable like other matrices, among them:
- `Tridiagonal`
- `SymTridiagonal`
@@ -44,7 +44,7 @@ The `LinearAlgebra` package provides among other things:
- Access to BLAS/LAPACK functions
## Matrix Types
## Special Matrix Types
@@ -68,20 +68,20 @@ Read-only index access is possible,
A[1,4]
```
write operations not necessarily:
Write operations are not necessarily possible:
```{julia}
#| error: true
A[1,3] = 17
```
Conversion to a 'normal' matrix is possible, for example, with `collect()`:
Conversion to a 'normal' matrix is possible using `collect()`:
```{julia}
A2 = collect(A)
```
### The Identity Matrix `I`
`I` denotes an identity matrix (square, diagonal elements = 1, all others = 0) of the respective required size
`I` denotes an identity matrix (square, diagonal elements = 1, all others = 0) of the required size
```{julia}
@@ -91,7 +91,7 @@ A + 4I
## Norms
To be able to study questions such as conditioning or convergence of an algorithm, we need a metric. For linear spaces, it is appropriate to define the metric via a norm:
To study questions such as conditioning or convergence of an algorithm, we need a metric. For linear spaces, it is appropriate to define the metric via a norm:
$$
d(x,y) := \lVert x-y\rVert
$$
@@ -109,12 +109,12 @@ which generalize the Euclidean norm $p=2$.
## The Max-Norm $p=\infty$
Let $x_{\text{max}}$ be the _largest in absolute value_ component of $\mathbf{x}\in ^n$. Then always
Let $x_{\text{max}}$ be the component of $\mathbf{x}\in ^n$ with the largest absolute value. Then always
$$ \lvert x_{\text{max}}\rvert \le \lVert\mathbf{x}\rVert_p \le n^\frac{1}{p} \lvert x_{\text{max}}\rvert
$$
(Consider a vector whose components are all equal to $x_{\text{max}}$ respectively a vector whose components are all equal to zero except $x_{\text{max}}$.)
Thus follows
It follows that
$$
\lim_{p \rightarrow \infty} \lVert\mathbf{x}\rVert_p = \lvert x_{\text{max}}\rvert =: \lVert\mathbf{x}\rVert_\infty.
$$
@@ -132,7 +132,7 @@ w = [-1, 2, 33.2]
- If the 2nd argument `p` is missing, `p=2` is set.
- The 2nd argument can also be `Inf` (i.e., $+\infty$).
- The 1st argument can be any container full of numbers. The sum $\sum \lvert x_i\rvert^p$ extends over *all* elements of the container.
- The 1st argument can be any numerical container. The sum $\sum \lvert x_i\rvert^p$ extends over *all* elements of the container.
- Thus, for a matrix `norm(A)` is equal to the _Frobenius norm_ of the matrix `A`.
```{julia}
@@ -163,9 +163,9 @@ for p ∈ (0.8, 1, 1.5, 2, 3.001, 1000)
end
fig1
```
As one can see, $p\ge 1$ must hold so that the unit ball is convex and $\lVert.\rVert_p$ is a norm.
We see that, $p\ge 1$ must hold so that the unit ball is convex and $\lVert.\rVert_p$ is a norm.
However, the Julia function `norm(v, p)` returns a result for arbitrary parameters `p`.
However, the Julia function `norm(v, p)` also works for parameters `p<1`.
### Induced Norms (Operator Norms)
@@ -185,7 +185,7 @@ $$
$$
:::
Induced norms can only be calculated with difficulty for general $p$. Exceptions are the cases
Induced norms are difficult to calculate for general $p$. Exceptions are the cases
- $p=1$: column sum norm
- $p=2$: spectral norm and
@@ -260,7 +260,7 @@ $$
## Matrix Factorizations
Basic tasks of numerical linear algebra:
The basic tasks of numerical linear algebra:
- Solve a system of linear equations $A\mathbf{x} = \mathbf{b}$.
- If no solution exists, find the best approximation, i.e., the vector $\mathbf{x}$ that minimizes $\lVert A\mathbf{x} - \mathbf{b}\rVert$.
@@ -270,12 +270,11 @@ These tasks can be solved using matrix factorizations. Some fundamental matrix f
- **LU decomposition** $A=L\cdot U$
- factorizes a matrix as a product of a _lower_ and an _upper_ triangular matrix
- in German also called LR decomposition (but the Julia function is called `lu()`)
- always works (possibly after row exchanges - pivoting)
- **Cholesky decomposition** $A=L\cdot L^*$
- the upper triangular matrix is the conjugate of the lower,
- half the effort compared to LU
- only works if $A$ is Hermitian and positive definite
- only works if $A$ is Hermitian and positive definite
- **QR decomposition** $A=Q\cdot R$
- decomposes $A$ as a product of an orthogonal (or unitary in the complex case) matrix and an upper triangular matrix
- $Q$ is length-preserving (rotations and/or reflections); the scalings are described by $R$
@@ -287,8 +286,7 @@ These tasks can be solved using matrix factorizations. Some fundamental matrix f
### LU Factorization
LU factorization is Gaussian elimination. The result of Gaussian elimination is the upper triangular matrix $U$. The lower triangular matrix $L$ contains ones on the diagonal and the non-diagonal entries $l_{ij}$ are equal to minus the coefficients by which row $Z_j$ is multiplied and added to row $Z_i$ in the Gaussian algorithm.
An example:
LU factorization is Gaussian elimination. The result of Gaussian elimination is the upper triangular matrix $U$. The lower triangular matrix $L$ contains ones on the diagonal and the non-diagonal entries $l_{ij}$ are equal to minus the coefficients by which row $Z_j$ is multiplied and added to row $Z_i$ in Gaussian elimination:
:::{.content-visible unless-format="typst"}
$$
@@ -394,9 +392,9 @@ $
:::
- Often in practice: $A\mathbf{x}=\mathbf{b}$ must be solved for one $A$ and many right-hand sides $\mathbf{b}$.
- The factorization, whose effort grows cubically $\sim n^3$ with the matrix size $n$, only needs to be done once.
- The subsequent effort of forward/backward substitution for each $\mathbf{b}$ is only quadratically $\sim n^2$.
- In practice, it is often necessary to solve $A\mathbf{x}=\mathbf{b}$ for a fixed matrix $A$ and multiple right-hand sides $\mathbf{b}$.
- The factorization of $A$, which has a cubic complexity $\sim n^3$ relative to the size $n$ of the matrix, needs to be performed only once.
- For each subsequent right-hand side $\mathbf{b}$, the forward and backward substitution steps have quadratic complexity $\sim n^2$.
The `LinearAlgebra` package of Julia contains the function `lu(A, options)` for calculating an LU decomposition:
```{julia}
@@ -447,9 +445,9 @@ $
```
:::
The goal is to make the entry $a_{i+1,j}$ disappear by adding an appropriate multiple of row $Z_i$ to row $Z_{i+1}$. This only works if the _pivot element_ ${\color{red}a_{ij}}$ is not zero. If ${\color{red}a_{ij}}=0$, we must exchange rows to fix this.
The goal is to make the entry $a_{i+1,j}$ disappear by adding an appropriate multiple of row $Z_i$ to row $Z_{i+1}$. This only works if the *pivot element* ${\color{red}a_{ij}}$ is not zero. If ${\color{red}a_{ij}}=0$, we must exchange rows to fix this.
Furthermore, the conditioning of the algorithm is best if we arrange the matrix at each step so that the pivot element is the largest in absolute value in the corresponding column of the remaining submatrix. In (row) pivoting, rows are exchanged at each step to ensure that
Furthermore, the conditioning of the algorithm is best if we arrange the matrix at each step so that the pivot element is the largest in absolute value in the corresponding column of the remaining submatrix. In (row) pivoting, rows are exchanged to ensure that
:::{.content-visible unless-format="typst"}
$$
@@ -485,7 +483,8 @@ L, U, p = lu(A);
p
```
The permutation vector indicates how the rows of the matrix have been permuted. It holds: $$ L\cdot U = PA$$. The syntax of indirect indexing allows applying the row permutation with the notation `A[p,:]`:
The permutation vector indicates how the rows of the matrix have been permuted. It holds: $$ L\cdot U = P A$$
Julia's syntax of indirect indexing allows applying the row permutation with the notation `A[p,:]`:
```{julia}
display(A)
display(A[p,:])
@@ -503,18 +502,17 @@ Verification:
A * x - b
```
In Julia, the `\` operator hides a quite universal "matrix solver", and it can also be applied directly:
In Julia, the `\` operator hides a quite universal "matrix solver" which perfoms implicitely an appropriate matrix factorization:
```{julia}
A \ b
```
An appropriate factorization is performed implicitly, but its result is not saved.
### QR Decomposition
The function `qr()` returns a special QR object that contains the components $Q$ and $R$. The orthogonal (or unitary) matrix $Q$ is
[in an optimized form](https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#man-linalg-abstractq) stored. Conversion to a "normal" matrix is, as always, possible with `collect()` if needed.
[in an optimized form](https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#man-linalg-abstractq). Conversion to a "normal" matrix is, as always, possible with `collect()` if needed.
```{julia}
F = qr(A)
@show typeof(F) typeof(F.Q)
@@ -525,10 +523,7 @@ display(F.R)
### Appropriate Factorization
The function `factorize()` returns a factorization form adapted to the matrix type, see [documentation](https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#LinearAlgebra.factorize) for details.
If solutions for several right-hand sides $\mathbf{b_1}, \mathbf{b_2},...$ are needed, the factorization should only be performed once:
The function `factorize()` returns a factorization appropriate for the given matrix type; see [documentation](https://docs.julialang.org/en/v1/stdlib/LinearAlgebra/#LinearAlgebra.factorize) for details. This factorization can subsequently be utilized for multiple right-hand sides $\mathbf{b_1}, \mathbf{b_2},\ldots$.
```{julia}
Af = factorize(A)
```