Skip to content
DeepForgeby svx
All problems
HardCalculusca-269

Gradient Lipschitz Constant

Problem

For the quadratic f(x, y) = 0.5*(a*x^2 + 2*b*x*y + c*y^2), the gradient is Lipschitz with constant equal to the largest eigenvalue of the Hessian [[a, b], [b, c]].

That eigenvalue is (a + c)/2 + sqrt(((a - c)/2)^2 + b^2). Given a, b, c, return the constant.

Hint

The gradient of a quadratic is a linear map, so its Lipschitz constant is the spectral norm.

Test cases

case 1
in: [4,0,1]
expected: 4
case 2
in: [2,1,2]
expected: 3
case 3
in: [1,0,1]
expected: 1
case 4
in: [5,0,3]
expected: 5
Starter codePython
def gradient_lipschitz(a, b, c):
    # Your code here
    pass

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