Lesson 48 of 55
10 mins readPython Matrix Factorizations & Solving Linear Systems (A \ b)
In Plain English
Solve linear systems Ax = b accurately and efficiently with the backslash operator (A \ b), and decompose matrices using LU, QR, Cholesky, and Eigendecompositions (eigen).
Deep Dive: How It Works
Solving Linear Systems: x = A \ b computes the exact solution without forming an unstable matrix inverse.
Eigenvalues & Eigenvectors: F = eigen(A) computes eigenvalues (F.values) and eigenvectors (F.vectors).
LU & QR Factorization: lu(A) and qr(A) provide factorized representations for repeated efficient solves.
Core Rules to Remember

Backslash Operator (\): Numerically stable solver for linear systems Ax = b.

eigen(A): Computes spectral decomposition into eigenvalues and eigenvectors.
Live Interactive Example
Hit Run Code to see it liveSolving Linear System and Eigendecomposition
Python 3.12
1
2
3
4
5
6
7
8
9
10
11
12
13
Output Console
Click "Run Code" to view the rendered output.
How it works: 2(1) + 1(3) = 5; 1(1) + 3(3) = 10. Solution is verified.
Your Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Micro Exercise
Solve 2x2 Linear System
Import `LinearAlgebra`.
Set `A = [1.0 0.0; 0.0 2.0]` and `b = [4.0, 8.0]`.
Solve `x = A \ b` and print `"Solution: $x"`.
1
2
3
4
5
Sandbox Output
Click "Run & Check" to test your solution.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.