σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
Linear Algebra skill›Module 2 · Solving linear systems›Topic 2.2·~50 minIntermediate

LU decomposition

Skill positionModule 2 of 4 · Topic 2 of 3
2.2 LU decomposition
—Lab score— / 100Total XP—Streak—

Elimination, remembered

Gaussian elimination solves Ax=bA\mathbf{x}=\mathbf{b}Ax=b by subtracting multiples of one row from the rows below it until the matrix is upper triangular, UUU. The multipliers you used are worth keeping: put them below the diagonal of a lower triangular matrix LLL with ones on the diagonal, and then A=LUA=LUA=LU. The decomposition records the whole elimination, so the work is done once and reused.

A=LU,Ly=b,Ux=yA=LU,\qquad L\mathbf{y}=\mathbf{b},\qquad U\mathbf{x}=\mathbf{y}A=LU,Ly=b,Ux=y(1)

To solve, first Ly=bL\mathbf{y}=\mathbf{b}Ly=b by forward substitution (top to bottom), then Ux=yU\mathbf{x}=\mathbf{y}Ux=y by back substitution (bottom to top). Each costs about n2n^2n2 operations, while the factorisation costs about 23n3\tfrac{2}{3}n^332​n3. With many right-hand sides (many scenarios on the same matrix) you factor once and pay only n2n^2n2 per scenario.

An LU by handTake A=(2145)A=\begin{pmatrix}2&1\\4&5\end{pmatrix}A=(24​15​). The multiplier is 4/2=24/2=24/2=2: subtract 2 times row 1 from row 2 to get U=(2103)U=\begin{pmatrix}2&1\\0&3\end{pmatrix}U=(20​13​), and L=(1021)L=\begin{pmatrix}1&0\\2&1\end{pmatrix}L=(12​01​). Check: LU=(2142+3)=ALU=\begin{pmatrix}2&1\\4&2+3\end{pmatrix}=ALU=(24​12+3​)=A. Solve Ax=(3,9)A\mathbf{x}=(3,9)Ax=(3,9): Ly=bL\mathbf{y}=\mathbf{b}Ly=b gives y1=3y_1=3y1​=3, y2=9−2⋅3=3y_2=9-2\cdot3=3y2​=9−2⋅3=3; then Ux=yU\mathbf{x}=\mathbf{y}Ux=y gives x2=1x_2=1x2​=1, 2x1+1=32x_1+1=32x1​+1=3, so x=(1,1)\mathbf{x}=(1,1)x=(1,1).
  • LLL: lower triangular, ones on the diagonal, the elimination multipliers below it.
  • UUU: upper triangular, the result of the elimination; its diagonal holds the pivots.
  • Pivoting: swap rows so the pivot is large, giving PA=LUPA=LUPA=LU with a permutation matrix PPP.
A zero or tiny pivot needs a row swapFor (0111)\begin{pmatrix}0&1\\1&1\end{pmatrix}(01​11​) the first pivot is 0 and plain elimination divides by zero, yet the matrix is perfectly invertible. Swapping the rows fixes it. A pivot that is tiny rather than zero does not crash, but it produces huge multipliers and wrecks accuracy, so real libraries always pivot.

Lab · what's graded

  • The matrix L15 pts
  • The matrix U15 pts
  • A determinant from U15 pts
  • Solving with L and U15 pts
  • Why pivot15 pts
  • The steps of an LU solve10 pts
  • Why factor once15 pts
0/ 7 answered
Tasks
1Matrix · vector15 ptsNot answered

Let A=(2145)A=\begin{pmatrix}2&1\\4&5\end{pmatrix}A=(24​15​). Fill in the lower triangular factor LLL (ones on the diagonal) of A=LUA=LUA=LU without row swaps.

L=L =L=
2Matrix · vector15 ptsNot answered

Let A=(2145)A=\begin{pmatrix}2&1\\4&5\end{pmatrix}A=(24​15​). Fill in the upper triangular factor UUU.

U=U =U=
3Numeric answer15 ptsNot answered

The matrix A=(211433879)A=\begin{pmatrix}2&1&1\\4&3&3\\8&7&9\end{pmatrix}A=​248​137​139​​ factors without swaps as L=(100210431)L=\begin{pmatrix}1&0&0\\2&1&0\\4&3&1\end{pmatrix}L=​124​013​001​​, U=(211011002)U=\begin{pmatrix}2&1&1\\0&1&1\\0&0&2\end{pmatrix}U=​200​110​112​​. Find det⁡A\det AdetA.

det⁡A=\det A =detA=accepted: ± 0.001
4Numeric answer15 ptsNot answered

Let A=(2145)A=\begin{pmatrix}2&1\\4&5\end{pmatrix}A=(24​15​). Use L=(1021)L=\begin{pmatrix}1&0\\2&1\end{pmatrix}L=(12​01​) and U=(2103)U=\begin{pmatrix}2&1\\0&3\end{pmatrix}U=(20​13​) to solve Ax=(5,13)A\mathbf{x}=(5,13)Ax=(5,13). What is x1x_1x1​?

x1=x_1 =x1​=accepted: ± 0.001
5Choice15 ptsNot answered

What goes wrong if you run plain elimination, with no row swaps, on (0111)\begin{pmatrix}0&1\\1&1\end{pmatrix}(01​11​)?

6Order the steps10 ptsNot answered

Put the steps of solving Ax=bA\mathbf{x}=\mathbf{b}Ax=b with a pivoted LU in order.

Drag to reorder, or focus an item, press Space to lift it, the arrow keys to move it and Space to drop it.

  1. 1Forward substitution: solve Ly=PbL\mathbf{y}=P\mathbf{b}Ly=Pb
  2. 2Factor PA=LUPA=LUPA=LU
  3. 3Back substitution: solve Ux=yU\mathbf{x}=\mathbf{y}Ux=y
  4. 4Apply the row swaps to the right-hand side: PbP\mathbf{b}Pb
7Explain in words15 ptsNot answered

You must solve Ax=bA\mathbf{x}=\mathbf{b}Ax=b for 1,000 different vectors b\mathbf{b}b with the same AAA. In two sentences, say how LU helps.

Math modeKeyboard or LaTeX inputTask 1 of 7 · Ctrl ⏎ to check

Log in to run your code.

Every lecture is free to read. Create an account or log in to run code, run tests and submit this lab.

  • In-browser IDE with a bash terminal — nothing to install
  • Instant grading, XP and your place on the skill
Create an accountLog in
OR
Continue with GitHub