Trying to compute by hand a matrix determinant (I know the value is 28 and can be obtained by m.det()):
from sympy import symbols, Matrix, summation
i = symbols('i', integer=True)
m = Matrix([[3, 2, -1],
[2, -1, -3],
[1, 3, -2]])
D = summation(m[i,0]*m.cofactor(i,0), (i, 0, 2))
It raises:
File ... \sympy\matrices\matrices.py:140 in minor_submatrix
return _minor_submatrix(self, i, j)
File ... \sympy\matrices\determinant.py:890 in _minor_submatrix
if i < 0:
File ... \sympy\core\relational.py:511 in __bool__
raise TypeError("cannot determine truth value of Relational")
TypeError: cannot determine truth value of Relational
Pinpointing:
summation(m[i,0], (i, 0, 2)) # Works
summation(m.cofactor(i,0), (i, 0, 2)) # Raises the error
I'm lost.