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 coordinatey: second coordinateReturn 2x2 nested list: rows are outputs, columns are inputs
Constraints
Allowed library: NumPy only
Time limit: 200 ms, Memory: 64 MB
Try similar problems(4)
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