How to derive with respect to a Matrix element with Sympy
问题 Given the product of a matrix and a vector A.v with A of shape (m,n) and v of dim n, where m and n are symbols, I need to calculate the Derivative with respect to the matrix elements. I haven't found the way to use a proper vector, so I started with 2 MatrixSymbol : n, m = symbols('n m') j = tensor.Idx('j') i = tensor.Idx('i') l = tensor.Idx('l') h = tensor.Idx('h') A = MatrixSymbol('A', n,m) B = MatrixSymbol('B', m,1) C=A*B Now, if I try to derive with respect to one of A's elements with the