All problems
Cholesky Solve
Problem
Solve A*x = b for symmetric positive definite A using its Cholesky factorization A = L*L^T.
Factor A into lower triangular L, solve L*y = b by forward substitution, then L^T*x = y by back substitution. Return x as a list of floats.
Hint
Forward substitution uses L; back substitution uses the transpose via L[j][i].
Test cases
case 1
in: [[[4,2],[2,3]],[1,2]]
expected: [-0.125,0.75]
case 2
in: [[[25,15,5],[15,18,0],[5,0,11]],[1,2,3]]
expected: [-0.19851851851851848,0.2765432098765432,0.36296296296296293]
case 3
in: [[[1,0,0],[0,1,0],[0,0,1]],[1,2,3]]
expected: [1,2,3]
case 4
in: [[[9,0],[0,16]],[18,32]]
expected: [2,2]
Starter codePython
def cholesky_solve(A, b):
# Your code here
pass4 test cases · run your code against them in the editor