All problems
2x2 Determinant Gradient via Adjugate
Problem
For det(A) with A = [[a, b], [c, d]], the gradient with respect to A is the adjugate [[d, -c], [-b, a]].
Given the four entries, return the 2x2 gradient.
Hint
Each partial derivative is the cofactor of the matching entry.
Test cases
case 1
in: [1,2,3,4]
expected: [[4,-3],[-2,1]]
case 2
in: [0,1,1,0]
expected: [[0,-1],[-1,0]]
case 3
in: [2,-1,4,3]
expected: [[3,-4],[1,2]]
Starter codePython
def determinant_gradient_adjugate(a, b, c, d):
# Your code here
pass3 test cases · run your code against them in the editor