Lesson 3 of 15
QR Decomposition
QR Decomposition
Every matrix can be factored as where:
- has orthonormal columns ()
- is upper triangular with positive diagonal entries
QR decomposition is the foundation for numerically stable least-squares, eigenvalue algorithms, and more.
Algorithm via Gram-Schmidt
Process each column of left-to-right:
- Apply Gram-Schmidt to produce orthonormal column
- for (how much of each previous is in )
- (the norm of the residual)
Example
Verify: and .
Your Task
Implement qr_decompose(A) returning (Q, R). Use Gram-Schmidt on the columns of A.
Python runtime loading...
Loading...
Click "Run" to execute your code.