@@ -484,11 +484,11 @@ A_manual = Float64[ 2 1 0;
484
484
# ╔═╡ 039b93ac-0a0e-45c3-acf9-70ec49b077c3
485
485
md """ With this slider you can stop `factorise_lu` after 1, 2 or 3 steps, checking that agrees with the steps we computed manually:
486
486
487
- - `nstep_lu_A = ` $(@bind nstep_lu_A Slider(1 :3; default=1 , show_value=true))
487
+ - `nstep_lu_A = ` $(@bind nstep_lu_A Slider(0 :3; default=0 , show_value=true))
488
488
"""
489
489
490
490
# ╔═╡ c918c14f-1532-4f40-9857-127554aaaf42
491
- let
491
+ begin
492
492
function factorise_lu_steps (A; nstep= size (A, 1 ))
493
493
n = size (A, 1 )
494
494
L = zeros (n, n) # Initialise L and U by zeros
516
516
return (; Aᵏ, L)
517
517
end
518
518
519
- (; Aᵏ, L) = factorise_lu_steps (A_manual; nstep= nstep_lu_A)
519
+ factorise_lu_steps (A_manual; nstep= nstep_lu_A)
520
520
end
521
521
522
522
# ╔═╡ 4da6a534-6a8f-464d-bbd4-9a6eec942688
@@ -624,34 +624,43 @@ Applying **Algorithm 4** the first step ($k=1$) will zero out the first column i
624
624
```
625
625
As a result the element `Aᵏ[k, k]` (for $k = 2$) is zero as marked \t extcolor{red}{in red}. Continuing **Algorithm 4** for `k = 2` we would thus divide by zero
626
626
in the statement $L_{ik} = \f rac{A_{ik}^{(k)}}{A^{(k)}_{kk}}$
627
- --- which reflects above in the introduction of a `-Inf`
628
- in the matrix `L` that is returned by the algorithm:
627
+ --- which in the introduction of a `-Inf`
628
+ in the matrix `L` that is returned by the algorithm.
629
+
630
+ We run the algorithm step by step by advancing the slider:
631
+
632
+ - `nstep_lu_D = ` $(@bind nstep_lu_D Slider(0:3; default=0, show_value=true))
629
633
"""
630
634
631
- # ╔═╡ 0e403214-ddd3-4d3a-ae60-7b81951ab1b1
632
- let
633
- L, U = factorise_lu (D)
634
- L
635
- end
635
+ # ╔═╡ 716a0a8d-2bf4-4e3d-8044-09d542152cdc
636
+ factorise_lu_steps (D; nstep= nstep_lu_D)
636
637
637
- # ╔═╡ 8e3d0734-bf9f-459d-87e4-07c50685bab1
638
+ # ╔═╡ 9d5aab1f-3156-4c73-9e2f-b91f3ebe3984
638
639
md """
639
- From this point our computations are numerical garbage.
640
+ We observe that from step $k=1$ and onwards our computations are numerical garbage.
641
+
640
642
Due their central role in the Gaussian elimination algorithm
641
643
the elements $\l eft(A^{(k)}\r ight)_{kk}$
642
644
--- respectively `Aᵏ[k, k]` in the implementation ---
643
645
are usually referred to as **pivots**.
646
+ """
644
647
645
- Notice that if instead of considering the matrix $A$ we consider the **permuted matrix**
648
+ # ╔═╡ 58c13b75-006d-48e4-8ddf-290df272488b
649
+ md """
650
+ If instead of considering the matrix $A$ we factorise the **permuted matrix**
646
651
```math
647
652
\m athbf{P}\m athbf{D} = \b egin{pmatrix} 1 & 2 & 3\\
648
653
\t extcolor{orange}{7} &\t extcolor{orange}{8} &\t extcolor{orange}{9}\\
649
654
\t extcolor{blue}{2} & \t extcolor{blue}{4} & \t extcolor{blue}{5}
650
655
\e nd{pmatrix}
651
656
```
652
- which is the matrix `D` multiplied by the permutation matrix
657
+ which is the matrix `D` in which the last two rows are swapped,
658
+ the algorithm goes through as expected:
653
659
"""
654
660
661
+ # ╔═╡ 49f66db0-3757-431d-85d7-4fe75096f9cc
662
+ md " We remark that the permutation matrix $\m athbf P$ is given by ..."
663
+
655
664
# ╔═╡ 6f59c78d-7966-45ab-8b79-8443b82ba1df
656
665
P = [1 0 0 ;
657
666
0 0 1 ;
@@ -660,11 +669,6 @@ P = [1 0 0;
660
669
# ╔═╡ a85a3ad2-a89d-4e7c-8275-a2f3cd2921b0
661
670
P * D
662
671
663
- # ╔═╡ 5bdda18b-cd8d-49f6-a107-ad58697eab52
664
- md """
665
- the algorithm goes through and works as expected:
666
- """
667
-
668
672
# ╔═╡ 0ea63086-f090-4b5b-a7d5-d6a1b21b1fd8
669
673
let
670
674
L, U = factorise_lu (P* D)
@@ -673,12 +677,15 @@ let
673
677
@show L * U - P * D # show that L * U = P * D
674
678
end ;
675
679
680
+ # ╔═╡ 2d461a32-c40f-4670-9252-09baa5f3a6d5
681
+ md " ... and exactly achieves the task of swapping the last two rows, but leaving the rest of $\m athbf D$ intact as we saw above."
682
+
676
683
# ╔═╡ c42c3c63-b96c-4af0-a276-72ebd96fe23c
677
684
md """
678
- That is we obtain a factorisation $\m athbf{L} \m athbf{U} = \m athbf{P} \m athbf{D}$ into lower-triangular $ \m athbf L$ and upper-triangular $ \m athbf U$,
679
- just not of the original matrix $\m athbf D$, but a permuted form .
685
+ We notice that even though $ \m athbf D$ cannot be permuted it is possible to obtain an LU factorisation $\m athbf{L} \m athbf{U} = \m athbf{P} \m athbf{D}$
686
+ if we additionally allow the freedom to cleverly permute the rows of $\m athbf D$.
680
687
681
- This result is in fact rather general:
688
+ This is in fact a general result :
682
689
683
690
!!! info "Theorem 1"
684
691
Every non-singular matrix $\t extbf A \i n \m athbb{R}^{n\t imes n}$ admits a factorisation
@@ -692,7 +699,7 @@ This result is in fact rather general:
692
699
# ╔═╡ d85ab4d1-730b-4a6e-bd4d-46e450261f64
693
700
md """
694
701
That is to say, that while in general **factorising a matrix $\m athbf A$ can fail**,
695
- it always suceeds for non-singular matrices if we give ourselves the freedom to permute the rows of $\m athbf A$.
702
+ ** it always suceeds** for non-singular matrices if we ** give ourselves the freedom to permute the rows** of $\m athbf A$.
696
703
697
704
Finding a suitable $\m athbf P$ can be achieved by a small
698
705
modification of **Algorithm 4**.
@@ -2273,12 +2280,14 @@ version = "17.4.0+2"
2273
2280
# ╟─8c0d6843-6bde-4c14-8a98-6cf7cb9f244a
2274
2281
# ╟─2baa3355-f51b-464e-a55a-3471fb7e0100
2275
2282
# ╟─7bece62a-5da4-4a4c-9da8-dfcb797fb27a
2276
- # ╠═0e403214-ddd3-4d3a-ae60-7b81951ab1b1
2277
- # ╟─8e3d0734-bf9f-459d-87e4-07c50685bab1
2278
- # ╠═6f59c78d-7966-45ab-8b79-8443b82ba1df
2283
+ # ╟─716a0a8d-2bf4-4e3d-8044-09d542152cdc
2284
+ # ╟─9d5aab1f-3156-4c73-9e2f-b91f3ebe3984
2285
+ # ╟─58c13b75-006d-48e4-8ddf-290df272488b
2279
2286
# ╠═a85a3ad2-a89d-4e7c-8275-a2f3cd2921b0
2280
- # ╟─5bdda18b-cd8d-49f6-a107-ad58697eab52
2281
2287
# ╠═0ea63086-f090-4b5b-a7d5-d6a1b21b1fd8
2288
+ # ╟─49f66db0-3757-431d-85d7-4fe75096f9cc
2289
+ # ╠═6f59c78d-7966-45ab-8b79-8443b82ba1df
2290
+ # ╟─2d461a32-c40f-4670-9252-09baa5f3a6d5
2282
2291
# ╟─c42c3c63-b96c-4af0-a276-72ebd96fe23c
2283
2292
# ╟─d85ab4d1-730b-4a6e-bd4d-46e450261f64
2284
2293
# ╠═0de87398-22d4-4ba6-8831-bcf30e67a6db
0 commit comments