diff --git a/README.md b/README.md index bf018b82..13c53b4b 100644 --- a/README.md +++ b/README.md @@ -58,10 +58,14 @@ julia format_myst.jl lectures/getting_started_julia/getting_started.md ``` As a helper, you can call a shell script to do it for an entire folder + ```bash bash format_all_directory.sh lectures/dynamic_programming ``` + or to also do the unicode substitutions + +```bash bash format_all_directory.sh lectures/dynamic_programming true ``` diff --git a/lectures/tools_and_techniques/numerical_linear_algebra.md b/lectures/tools_and_techniques/numerical_linear_algebra.md index f4cda6f9..b4f81c25 100644 --- a/lectures/tools_and_techniques/numerical_linear_algebra.md +++ b/lectures/tools_and_techniques/numerical_linear_algebra.md @@ -54,7 +54,7 @@ The theme of this lecture, and numerical linear algebra in general, comes down t --- tags: [hide-output] --- -using LinearAlgebra, Statistics, BenchmarkTools, SparseArrays, Random, Parameters +using LinearAlgebra, Statistics, BenchmarkTools, SparseArrays, Random Random.seed!(42); # seed random numbers for reproducibility ``` @@ -491,14 +491,11 @@ To manually use the QR decomposition in solving linear least squares: ```{code-cell} julia Af = qr(A) -Q = Af.Q -R = [Af.R; zeros(N - M, M)] # Stack with zeros -@show Q * R ≈ A -x = R \ Matrix(Q)' * b # simplified QR solution for least squares +@show Af.Q * Af.R ≈ A +x = Af.R \ (Matrix(Af.Q)' * b) # simplified QR solution for least squares ``` -This stacks the `R` with zeros, but the more specialized algorithm would not multiply directly -in that way. +See [here](https://discourse.julialang.org/t/qr-decomposition-with-julia-how-to/92508/8) for more, thought keep in mind that more specialized algorithm would be more efficient. In some cases, if an LU is not available for a particular matrix structure, the QR factorization can also be used to solve systems of equations (i.e., not just LLS). This tends to be about 2 times slower than the LU