Skip to content
DeepForgeby svx
All problems
HardOptimizationop-180

Sensitivity Rank

Problem

Estimate the numerical rank of a 2x2 sensitivity matrix.

Compute p = sum of squared entries, q = det(A), lmax = (p + sqrt(p ** 2 - 4 * q ** 2)) / 2, and lmin = (p - sqrt(p ** 2 - 4 * q ** 2)) / 2. The singular values are sqrt(lmax) and sqrt(lmin); return how many exceed tol.

Hint

Singular values are square roots of the eigenvalues of A transpose A.

Test cases

case 1
in: [[[1,0],[0,1]],0.000001]
expected: 2
case 2
in: [[[1,2],[2,4]],0.000001]
expected: 1
case 3
in: [[[0,0],[0,0]],0.000001]
expected: 0
case 4
in: [[[1,0],[0,1e-9]],0.000001]
expected: 1
Starter codePython
def sensitivity_rank(A, tol):
    # Your code here
    pass

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