further work on translation
This commit is contained in:
@@ -93,14 +93,14 @@ A + 4I
|
||||
|
||||
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:
|
||||
$$
|
||||
d(x,y) := ||x-y||
|
||||
d(x,y) := \lVert x-y\rVert
|
||||
$$
|
||||
|
||||
### $p$-Norms
|
||||
|
||||
A simple class of norms in $ℝ^n$ are the $p$-norms
|
||||
$$
|
||||
||\mathbf{x}||_p = \left(\sum |x_i|^p\right)^\frac{1}{p},
|
||||
\lVert \mathbf{x} \rVert_p = \left(\sum |x_i|^p\right)^\frac{1}{p},
|
||||
$$
|
||||
which generalize the Euclidean norm $p=2$.
|
||||
|
||||
@@ -110,13 +110,13 @@ 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
|
||||
$$ |x_{\text{max}}| \le ||\mathbf{x}||_p \le n^\frac{1}{p} |x_{\text{max}}|
|
||||
$$ \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
|
||||
$$
|
||||
\lim_{p \rightarrow \infty} ||\mathbf{x}||_p = |x_{\text{max}}| =: ||\mathbf{x}||_\infty.
|
||||
\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 |x_i|^p$ extends over *all* elements of the container.
|
||||
- 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.
|
||||
- Thus, for a matrix `norm(A)` is equal to the _Frobenius norm_ of the matrix `A`.
|
||||
|
||||
```{julia}
|
||||
@@ -145,7 +145,7 @@ norm(A) # Frobenius norm
|
||||
|
||||
|
||||
Since norms are homogeneous under multiplication with scalars,
|
||||
$||\lambda \mathbf{x}|| = |\lambda|\cdot||\mathbf{x}||$, they are completely determined by the specification of the unit ball. Subadditivity of the norm (triangle inequality) is equivalent to the convexity of the unit ball
|
||||
$\lVert\lambda \mathbf{x}\rVert = |\lambda|\cdot\lVert\mathbf{x}\rVert$, they are completely determined by the specification of the unit ball. Subadditivity of the norm (triangle inequality) is equivalent to the convexity of the unit ball
|
||||
(code visible by clicking).
|
||||
```{julia}
|
||||
#| code-fold: true
|
||||
@@ -163,7 +163,7 @@ 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 $||.||_p$ is a norm.
|
||||
As one can see, $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`.
|
||||
|
||||
@@ -181,7 +181,7 @@ Due to the homogeneity of the norm under multiplication with scalars, it is suff
|
||||
Let $V$ be a vector space with dimension $0<n<\infty$ and
|
||||
$A$ an $n\times n$-matrix. Then
|
||||
$$
|
||||
||A||_p = \max_{||\mathbf{v}||_p=1} ||A\mathbf{v}||_p
|
||||
\lVert A\rVert_p = \max_{\lVert\mathbf{v}\rVert_p=1} \lVert A\mathbf{v}\rVert_p
|
||||
$$
|
||||
:::
|
||||
|
||||
@@ -214,16 +214,10 @@ CairoMakie.activate!(type = "svg")
|
||||
|
||||
```{julia}
|
||||
#| code-fold: true
|
||||
#| fig-cap: "Image of the unit ball under $v \\mapsto Av$ with $||A||\\approx 2.088$"
|
||||
#| fig-cap: "Image of the unit ball under $v \\mapsto Av$ with $\\lVert A\\rVert\\approx 2.088$"
|
||||
|
||||
using CairoMakie
|
||||
|
||||
# Makie bug https://github.com/MakieOrg/Makie.jl/issues/3255
|
||||
# Workaround https://github.com/MakieOrg/Makie.jl/issues/2607#issuecomment-1385816645
|
||||
tri = BezierPath([
|
||||
MoveTo(Point2f(-0.5, -1)), LineTo(0, 0), LineTo(0.5, -1), ClosePath()
|
||||
])
|
||||
|
||||
A = [ 0 1
|
||||
1.2 1.5 ]
|
||||
|
||||
@@ -241,14 +235,14 @@ Auv = A * [u,v]
|
||||
fig2 = Figure(size=(800, 400))
|
||||
lines(fig2[1, 1], xs, ys, color=t, linewidth=5, colormap=:hsv, axis=(; aspect = 1, limits=(-2,2, -2,2),
|
||||
title=L"$\mathbf{v}$", titlesize=30))
|
||||
arrows!(fig2[1,1], x, y, u, v, arrowsize=10, arrowhead=tri, colormap=:hsv, linecolor=range(0,11), linewidth=3)
|
||||
arrows2d!(fig2[1,1], x, y, u, v, tipwidth=10, colormap=:hsv, shaftcolor=range(0,11), shaftwidth=3)
|
||||
|
||||
Legend(fig2[1,2], MarkerElement[], String[], L"⟹", width=40, height=30, titlesize=30, framevisible=false)
|
||||
|
||||
lines(fig2[1,3], Axys[1], Axys[2], color=t, linewidth=5, colormap=:hsv, axis=(; aspect=1, limits=(-2,2, -2,2),
|
||||
title=L"$A\mathbf{v}$", titlesize=30))
|
||||
arrows!(fig2[1,3], x, y, Auv[1], Auv[2], arrowsize=10, arrowhead=tri, colormap=:hsv, linecolor=range(0,11),
|
||||
linewidth=3)
|
||||
arrows2d!(fig2[1,3], x, y, Auv[1], Auv[2], tipwidth=10, colormap=:hsv, shaftcolor=range(0,11),
|
||||
shaftwidth=3)
|
||||
|
||||
fig2
|
||||
```
|
||||
@@ -257,7 +251,7 @@ fig2
|
||||
|
||||
For p = 1, p = 2 (default) or p = Inf, `cond(A,p)` returns the condition number in the $p$-norm
|
||||
$$
|
||||
\text{cond}_p(A) = ||A||_p \cdot ||A^{-1}||_p
|
||||
\text{cond}_p(A) = \lVert A\rVert_p \cdot \lVert A^{-1}\rVert_p
|
||||
$$
|
||||
|
||||
```{julia}
|
||||
@@ -269,7 +263,7 @@ $$
|
||||
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 $||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$.
|
||||
- Find eigenvalues and eigenvectors $A\mathbf{x} = \lambda \mathbf{x}$ of $A$.
|
||||
|
||||
These tasks can be solved using matrix factorizations. Some fundamental matrix factorizations:
|
||||
@@ -295,6 +289,8 @@ These tasks can be solved using matrix factorizations. Some fundamental matrix f
|
||||
|
||||
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:
|
||||
|
||||
:::{.content-visible unless-format="typst"}
|
||||
$$
|
||||
A=\left[
|
||||
\begin{array}{ccc}
|
||||
@@ -325,6 +321,44 @@ A=\left[
|
||||
& & 8
|
||||
\end{array}\right] = U
|
||||
$$
|
||||
:::
|
||||
|
||||
:::{.content-hidden unless-format="typst"}
|
||||
```{=typst}
|
||||
$
|
||||
A = mat(
|
||||
1, 2, 2;
|
||||
3, -4, 4;
|
||||
-2, 1, 5; delim:"["
|
||||
)
|
||||
script(vec(
|
||||
#h(0pt),#h(0pt),#h(0pt),
|
||||
Z_2 arrow.bar Z_2 text(fill:#red, -) text(fill:#red, 3) Z_1,
|
||||
Z_3 arrow.bar Z_3 + text(fill:#red, 2) Z_1, delim:#none
|
||||
))
|
||||
&arrow.double.long
|
||||
mat(
|
||||
1, 2, 2;
|
||||
, -10, -2;
|
||||
, 5, 9
|
||||
)
|
||||
script(vec(
|
||||
#h(0pt),
|
||||
#h(0pt),
|
||||
#h(0pt),#h(0pt),
|
||||
Z_3 arrow.bar Z_3 + text(fill:#red, 1/2) Z_2, delim:#none
|
||||
))
|
||||
&arrow.double.long
|
||||
mat(
|
||||
1, 2, 2;
|
||||
, -10, -2;
|
||||
, , 8
|
||||
) = U
|
||||
$
|
||||
```
|
||||
:::
|
||||
|
||||
:::{.content-visible unless-format="typst"}
|
||||
$$
|
||||
A = \left[
|
||||
\begin{array}{ccc}
|
||||
@@ -340,6 +374,24 @@ A = \left[
|
||||
& & 8
|
||||
\end{array}\right]
|
||||
$$
|
||||
:::
|
||||
|
||||
:::{.content-hidden unless-format="typst"}
|
||||
```{=typst}
|
||||
$
|
||||
A = mat(
|
||||
1,,;
|
||||
text(fill:#red, +3),1,;
|
||||
text(fill:#red, -2),text(fill:#red, -1/2),1
|
||||
) dot.c
|
||||
mat(
|
||||
1,2,3;
|
||||
,-10,-2;
|
||||
,,8
|
||||
)
|
||||
$
|
||||
```
|
||||
:::
|
||||
|
||||
|
||||
- Often in practice: $A\mathbf{x}=\mathbf{b}$ must be solved for one $A$ and many right-hand sides $\mathbf{b}$.
|
||||
@@ -362,6 +414,8 @@ display(U)
|
||||
#### Pivoting
|
||||
|
||||
Let's look at one step of Gaussian elimination:
|
||||
|
||||
:::{.content-visible unless-format="typst"}
|
||||
$$
|
||||
\left[
|
||||
\begin{array}{cccccc}
|
||||
@@ -375,12 +429,41 @@ $$
|
||||
\end{array}
|
||||
\right]
|
||||
$$
|
||||
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_ $\textcolor{red}{a_{ij}}$ is not zero. If $\textcolor{red}{a_{ij}}=0$, we must exchange rows to fix this.
|
||||
:::
|
||||
|
||||
:::{.content-hidden unless-format="typst"}
|
||||
```{=typst}
|
||||
$
|
||||
mat(
|
||||
*, dots.c, *, *, dots.c, *;
|
||||
, dots.down, dots.v, dots.v, , dots.v;
|
||||
, , *, *, dots.c, *;
|
||||
, , , text(fill: #red, a_(i j)), dots.c, a_(i n);
|
||||
, , , text(fill: #blue, a_(i+1, j)), dots.c, a_(i+1, n);
|
||||
, , , text(fill: #blue, dots.v), , dots.v;
|
||||
, , , text(fill: #blue, a_(m j)), dots.c, a_(m n)
|
||||
)
|
||||
$
|
||||
```
|
||||
:::
|
||||
|
||||
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
|
||||
|
||||
:::{.content-visible unless-format="typst"}
|
||||
$$
|
||||
|\textcolor{red}{a_{ij}}|=\max_{k=i,...,m} |\textcolor{blue}{a_{kj}}|
|
||||
$$
|
||||
:::
|
||||
|
||||
:::{.content-hidden unless-format="typst"}
|
||||
```{=typst}
|
||||
$
|
||||
|text(fill:#red, a_(i j))| = max_(k=1,...,m) | text(fill:#blue, a_(k j)) |
|
||||
$
|
||||
```
|
||||
:::
|
||||
|
||||
#### LU in Julia
|
||||
|
||||
|
||||
Reference in New Issue
Block a user