Challenge - 5 Problems
Cholesky Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of Cholesky decomposition with scipy
What is the output of the following code that performs Cholesky decomposition on a positive definite matrix?
SciPy
import numpy as np from scipy.linalg import cholesky A = np.array([[4, 2], [2, 3]]) L = cholesky(A, lower=True) print(L)
Attempts:
2 left
💡 Hint
Remember that the Cholesky decomposition returns a lower triangular matrix L such that A = L * L.T
✗ Incorrect
The matrix A is decomposed into L where L is lower triangular. The first element is sqrt(4) = 2, and the (2,1) element is 2/2 = 1. The (2,2) element is sqrt(3 - 1^2) = sqrt(2) ≈ 1.4142.
❓ data_output
intermediate1:30remaining
Shape of Cholesky factor matrix
Given a 3x3 positive definite matrix, what is the shape of the matrix returned by scipy.linalg.cholesky with lower=True?
SciPy
import numpy as np from scipy.linalg import cholesky A = np.array([[6, 3, 4], [3, 6, 5], [4, 5, 10]]) L = cholesky(A, lower=True) print(L.shape)
Attempts:
2 left
💡 Hint
The Cholesky decomposition returns a matrix of the same size as the input matrix.
✗ Incorrect
The Cholesky factor L has the same dimensions as the original matrix A, so it is 3x3.
🔧 Debug
advanced2:00remaining
Error raised by Cholesky on non-positive definite matrix
What error does the following code raise when trying to compute the Cholesky decomposition of a non-positive definite matrix?
SciPy
import numpy as np from scipy.linalg import cholesky A = np.array([[1, 2], [2, 1]]) L = cholesky(A, lower=True)
Attempts:
2 left
💡 Hint
Cholesky decomposition requires the matrix to be positive definite.
✗ Incorrect
The matrix is symmetric but not positive definite, so scipy.linalg.cholesky raises a LinAlgError indicating the matrix is not positive definite.
🚀 Application
advanced3:00remaining
Using Cholesky decomposition to solve linear systems
Which code snippet correctly uses Cholesky decomposition to solve the system Ax = b for x?
Attempts:
2 left
💡 Hint
Use solve_triangular twice: first for Ly = b, then for L.T x = y.
✗ Incorrect
Cholesky decomposition gives A = L L.T. To solve Ax = b, solve Ly = b for y, then L.T x = y for x using solve_triangular.
🧠 Conceptual
expert1:30remaining
Cholesky decomposition properties and usage
Which statement about Cholesky decomposition is TRUE?
Attempts:
2 left
💡 Hint
Think about the conditions on the matrix for Cholesky to work.
✗ Incorrect
Cholesky decomposition only works on symmetric, positive definite matrices and returns a lower (or upper) triangular matrix L such that A = L L.T.