The Hessian
Implement hessian_at(x, y) returning the Hessian as a nested list.
Examples
At (2, 1) both off-diagonal entries are 4, as symmetry requires
- Input
- hessian_at(2, 1)
- Output
- [[2, 4], [4, 6]]
At the origin the Hessian is all zeros: flat to second order too
- Input
- hessian_at(0, 0)
- Output
- [[0, 0], [0, 0]]
Negative y curves the surface downward along both diagonal entries
- Input
- hessian_at(1, -1)
- Output
- [[-2, 2], [2, -6]]
Hints
Hint 1
Work directly with the arguments x, y and return the result rather than printing it.
Hint 2
Watch for this: produces an asymmetric matrix.
Requirements
x: first coordinatey: second coordinateReturn 2x2 nested list, symmetric
Constraints
Standard library only, no imports required
Time limit: 200 ms, Memory: 64 MB
Try similar problems(4)
Gradients, Jacobians and Hessians · ~14 min
Gradients, Jacobians and Hessians · ~15 min
Gradients, Jacobians and Hessians · ~12 min
Gradients, Jacobians and Hessians · ~12 min
Where this shows up
6 employers weight this skill
4 quant funds, 1 big tech firm, 1 frontier lab. Top match scores 92.
def hessian_at(x, y):
"""
Hessian of f(x, y) = x^2*y + y^3.
Args:
x: first coordinate
y: second coordinate
Returns:
2x2 nested list, symmetric
"""
# YOUR CODE HERE
pass