Skip to content
DeepForgeby svx
All problems
MediumLinear Algebrala-116

Positive Definite via Leading Minors

Problem

Return True if A is symmetric positive definite using Sylvester's criterion: A must be symmetric and every leading principal minor must be positive (greater than 1e-9).

Otherwise return False.

Hint

Sylvester's criterion requires all leading principal minors to be positive, not just the determinant.

Test cases

case 1
in: [[[2,0],[0,3]]]
expected: true
case 2
in: [[[2,1],[1,2]]]
expected: true
case 3
in: [[[1,2],[2,1]]]
expected: false
case 4
in: [[[1,0],[0,-1]]]
expected: false
Starter codePython
def is_positive_definite(A):
    # Your code here
    pass

4 test cases · run your code against them in the editor