All problems
Jacobian Matrix
Problem
Compute the Jacobian matrix of the vector-valued function f(x1, x2) = [x1^2, x1*x2] at a given point using central differences (h = 1e-6).
J is a 2x2 matrix where J[j][i] = d f_j / d x_i.
Hint
Perturb each input dimension independently; record how each output component changes.
Test cases
case 1
in: [[2,3]]
expected: [[4,0],[3,2]]
case 2
in: [[1,1]]
expected: [[2,0],[1,1]]
case 3
in: [[0,5]]
expected: [[0,0],[5,0]]
Starter codePython
def jacobian(point, h=1e-6):
# f(x1, x2) = [x1**2, x1*x2]
# Returns 2x2 Jacobian J[j][i] = d(f_j)/d(x_i)
# Your code here
pass3 test cases · run your code against them in the editor