Skip to content
DeepForgeby svx
All problems
MediumOptimizationop-142

Strong Convexity Modulus

Problem

Compute the strong convexity modulus of a 2x2 Hessian, which is its smallest eigenvalue.

For the symmetric matrix A = [[a, b], [b, d]] return mid - sqrt(((a - d) / 2) ** 2 + b ** 2) with mid = (a + d) / 2. The result can be negative when A is not positive semidefinite.

Hint

mid minus the eigenvalue spread gives the smaller eigenvalue.

Test cases

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

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