All problems
Hessian of a Quadratic Form
Problem
Return the constant Hessian matrix of f(x, y) = a * x^2 + b * x * y + c * y^2 as a 2x2 nested list.
The matrix is [[2a, b], [b, 2c]] since all second partials are constants.
Hint
Mixed partials are equal for this smooth function, so the Hessian is symmetric.
Test cases
case 1
in: [1,2,3]
expected: [[2,2],[2,6]]
case 2
in: [-1,0,2]
expected: [[-2,0],[0,4]]
case 3
in: [0,5,0]
expected: [[0,5],[5,0]]
case 4
in: [2,-3,2]
expected: [[4,-3],[-3,4]]
Starter codePython
def quadratic_hessian(a, b, c):
# Return [[H_xx, H_xy], [H_yx, H_yy]]
# Your code here
pass4 test cases · run your code against them in the editor