The Jacobian

~14 mincode completion

Implement jacobian_at(x, y) returning the Jacobian as a nested list [[df1/dx, df1/dy], [df2/dx, df2/dy]].

Examples

At (1, 0) the sine row contributes cos(0) = 1

Input
jacobian_at(1, 0)
Output
[[0, 1], [5, 1]]

At (2, 1) the top row is [2xy, x^2] = [4, 4]

Input
jacobian_at(2, 1)
Output
[[4, 4], [5, 0.5403]]

The constant 5 appears in every Jacobian regardless of position

Input
jacobian_at(0, 0)
Output
[[0, 0], [5, 1]]

Hints

Hint 1

Work directly with the arguments x, y and return the result rather than printing it.

Hint 2

Watch for this: transposes the matrix, putting inputs down and outputs across.

Requirements

  • x: first coordinate

  • y: second coordinate

  • Return 2x2 nested list: rows are outputs, columns are inputs

Constraints

  • Allowed library: NumPy only

  • 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
import numpy as np


def jacobian_at(x, y):
    """
    Jacobian of f(x, y) = [x^2*y, 5x + sin(y)].

    Args:
        x: first coordinate
        y: second coordinate

    Returns:
        2x2 nested list: rows are outputs, columns are inputs
    """
    # 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.