All problems
Gradient of Log-Determinant
Problem
Return the gradient of the log-determinant f(A) = log(det(A)) with respect to the 2x2 matrix A:
grad = inv(A)^T
Return None if det(A) == 0.
Hint
d/dA log det(A) = A^-T, the inverse transpose.
Test cases
case 1
in: [[[1,2],[3,4]]]
expected: [[-2,1.5],[1,-0.5]]
case 2
in: [[[2,0],[0,3]]]
expected: [[0.5,0],[0,0.3333333333333333]]
case 3
in: [[[1,0],[0,1]]]
expected: [[1,0],[0,1]]
case 4
in: [[[1,2],[2,4]]]
expected: null
Starter codePython
def grad_log_det_2x2(A):
# Your code here
pass4 test cases · run your code against them in the editor