Theorem DZRC. Determinant with Zero Row or Column.
Suppose that is a square matrix with a row where every entry is zero, or a column where every entry is zero. Then
xxxxxxxxxx
A = matrix(QQ, [[ 1, 0, 2, 1, 1, -3, 4, -6],
[ 0, 1, 0, 5, 3, -8, 0, 6],
[ 1, 1, 4, 4, 2, -8, 4, -2],
[ 0, 1, 6, 0, -2, -1, 1, 0],
[-1, 1, 0, 1, 0, -2, -1, 5],
[ 0, -1, -6, -3, 1, 4, 1, -5],
[-1, -1, -2, -3, -2, 7, -4, 2],
[ 0, 2, 0, 0, -2, -2, 0, 6]])
A.is_singular()
xxxxxxxxxx
A.determinant()
xxxxxxxxxx
B = matrix(QQ, [[ 2, -1, 0, 4, -6, -2, 8, -2],
[-1, 1, -1, -4, -1, 7, -7, -2],
[-1, 1, 1, 0, 7, -5, -6, 7],
[ 2, -1, -1, 3, -5, -2, 5, 2],
[ 1, -2, 0, 2, -1, -3, 8, 0],
[-1, 1, 0, -2, 6, -1, -8, 5],
[ 2, -1, -1, 2, -7, 1, 7, -3],
[-1, 0, 1, 0, 6, -4, -2, 4]])
B.is_singular()
xxxxxxxxxx
B.determinant()
C
to the fourth row, so by Theorem DERC, the determinant is zero.xxxxxxxxxx
C = matrix(QQ, [[-3, 4, 0, 1, 2, 0, 5, 0],
[ 4, 0, -4, 7, 0, 5, 0, 5],
[ 7, 4, 2, 2, 4, 0, -2, 8],
[ 5, -4, 8, 2, 6, -1, -4, -4],
[ 8, 0, 7, 4, 7, 5, 2, -3],
[ 6, 5, 3, 7, 4, 2, 4, -3],
[ 1, 6, -4, -4, 3, 8, 5, -2],
[ 2, 4, -2, 8, 2, 5, 2, 2]])
C[3] = C[5]
C
xxxxxxxxxx
C.determinant()
xxxxxxxxxx
A = matrix(QQ, [[-4, 7, -2, 6, 8, 0, -4, 6],
[ 1, 6, 5, 8, 2, 3, 1, -1],
[ 5, 0, 7, -3, 7, -3, 6, -3],
[-4, 5, 8, 3, 6, 8, -1, -1],
[ 0, 0, -3, -3, 4, 4, 2, 5],
[-3, -2, -3, 8, 8, -3, -1, 1],
[-4, 0, 2, 4, 4, 4, 7, 2],
[ 3, 3, -4, 5, -2, 3, -1, 5]])
B = matrix(QQ, [[ 1, 2, -4, 8, -1, 2, -1, -3],
[ 3, 3, -2, -4, -3, 8, 1, 6],
[ 1, 8, 4, 0, 4, -2, 0, 8],
[ 6, 8, 1, -1, -4, -3, -2, 5],
[ 0, 5, 1, 4, -3, 2, -3, -2],
[ 2, 4, 0, 7, 8, -1, 5, 8],
[ 7, 1, 1, -1, -1, 7, -2, 6],
[ 2, 3, 4, 7, 3, 4, 7, -2]])
C = A*B; C
xxxxxxxxxx
Adet = A.determinant(); Adet
xxxxxxxxxx
Bdet = B.determinant(); Bdet
xxxxxxxxxx
Cdet = C.determinant(); Cdet
xxxxxxxxxx
Adet*Bdet == Cdet
random_matrix()
constructor with the algorithm='unimodular'
keyword to create a nonsingular matrix. We can now reveal that in this context, “unimodular” means “with determinant 1.” So such a matrix will always be nonsingular by Theorem SMZD. But more can be said. It is not obvious at all, and Solution M20.1 has just a partial explanation, but the inverse of a unimodular matrix with all integer entries will have an inverse with all integer entries.upper_bound
keyword can be used to control the size of the entries of the matrix, though this will have little control over the inverse.xxxxxxxxxx
A = random_matrix(QQ, 5, algorithm='unimodular')
A, A.inverse() # random