Skip to content
DeepForgeby svx
All problems
MediumOptimizationop-144

Smoothness Constant

Problem

Estimate the smoothness constant from sampled Hessians.

For each symmetric 2x2 matrix compute the largest absolute eigenvalue as abs(mid) + sqrt(((a - d) / 2) ** 2 + b ** 2) and return the maximum over the list. An empty list returns 0.0.

Hint

The smoothness constant is the largest absolute Hessian eigenvalue.

Test cases

case 1
in: [[[[2,1],[1,2]],[[4,1],[1,3]]]]
expected: 4.618033988749895
case 2
in: [[[[1,0],[0,1]]]]
expected: 1
case 3
in: [[[[-3,0],[0,1]]]]
expected: 3
case 4
in: [[]]
expected: 0
Starter codePython
def smoothness_constant(hessians):
    # Your code here
    pass

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