The Hessian

~14 mincode completion

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 coordinate

  • y: second coordinate

  • Return 2x2 nested list, symmetric

Constraints

  • Standard library only, no imports required

  • Time limit: 200 ms, Memory: 64 MB

Where this shows up

~14 min

6 employers weight this skill

4 quant funds, 1 big tech firm, 1 frontier lab. Top match scores 92.

Python
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
Loading docs…

The AI Mentor needs an account

It reads your code and the failing tests and nudges you toward the fix without handing you the answer. Free accounts get it on every problem you're working on today.