The following row operations affects the determinant of a matrix but NOT THE MATRIX SINGULARITY .
We are going to make operations on the matrix M M M with d e t ( M ) = 8 det(M) = 8 d e t ( M ) = 8 :
M = [ 3 4 5 1 1 2 3 2 5 2 3 5 5 2 3 6 ] M = \begin{bmatrix}
3 & 4 & 5 & 1 \\
1 & 2 & 3 & 2 \\
5 & 2 & 3 & 5 \\
5 & 2 & 3 & 6
\end{bmatrix} M = 3 1 5 5 4 2 2 2 5 3 3 3 1 2 5 6
Output:
Swapping 2 rows
Swapping one position 2 rows of a matrix, changes the sign of its determinant.
r 1 ↔ r 2 r_{1} \leftrightarrow r_{2} r 1 ↔ r 2
M = [ 3 4 5 1 1 2 3 2 5 2 3 5 5 2 3 6 ] → r 1 ↔ r 2 M 1 = [ 3 4 5 1 5 2 3 5 1 2 3 2 5 2 3 6 ] M = \begin{bmatrix}
3 & 4 & 5 & 1 \\
\textcolor{green}{1} & \textcolor{green}{2} & \textcolor{green}{3} & \textcolor{green}{2} \\
\textcolor{red}{5} & \textcolor{red}{2} & \textcolor{red}{3} & \textcolor{red}{5} \\
5 & 2 & 3 & 6
\end{bmatrix} \xrightarrow{r_{1} \leftrightarrow r_{2}}
M_{1} = \begin{bmatrix}
3 & 4 & 5 & 1 \\
\textcolor{red}{5} & \textcolor{red}{2} & \textcolor{red}{3} & \textcolor{red}{5} \\
\textcolor{green}{1} & \textcolor{green}{2} & \textcolor{green}{3} & \textcolor{green}{2} \\
5 & 2 & 3 & 6
\end{bmatrix} M = 3 1 5 5 4 2 2 2 5 3 3 3 1 2 5 6 r 1 ↔ r 2 M 1 = 3 5 1 5 4 2 2 2 5 3 3 3 1 5 2 6
d e t ( M 1 ) = − d e t ( M ) = − 8 det(M_{1}) = -det(M) = -8 d e t ( M 1 ) = − d e t ( M ) = − 8
# Row Swapping: 1 position
# Swapping row 1 with row 2.
det_M1 = np.linalg.det(M1)
print ( f " { det_M1 = } is -1 * { det_M = } "
Output:
det_M1 = -8.0 is -1 * det_M = 8.0
Swapping two positions 4 rows of a matrix, changes the sign of its determinant.
r 0 ↔ r 1 r 2 ↔ r 3 r_{0} \leftrightarrow r_{1} \\
r_{2} \leftrightarrow r_{3} r 0 ↔ r 1 r 2 ↔ r 3
M = [ 3 4 5 1 1 2 3 2 5 2 3 5 5 2 3 6 ] → r 0 ↔ r 1 M 1 = [ 1 2 3 2 3 4 5 1 5 2 3 5 5 2 3 6 ] M = \begin{bmatrix}
\textcolor{red}{3} & \textcolor{red}{4} & \textcolor{red}{5} & \textcolor{red}{1} \\
\textcolor{green}{1} & \textcolor{green}{2} & \textcolor{green}{3} & \textcolor{green}{2} \\
5 & 2 & 3 & 5 \\
5 & 2 & 3 & 6
\end{bmatrix} \xrightarrow{r_{0} \leftrightarrow r_{1}}
M_{1} = \begin{bmatrix}
\textcolor{green}{1} & \textcolor{green}{2} & \textcolor{green}{3} & \textcolor{green}{2} \\
\textcolor{red}{3} & \textcolor{red}{4} & \textcolor{red}{5} & \textcolor{red}{1} \\
5 & 2 & 3 & 5 \\
5 & 2 & 3 & 6
\end{bmatrix} M = 3 1 5 5 4 2 2 2 5 3 3 3 1 2 5 6 r 0 ↔ r 1 M 1 = 1 3 5 5 2 4 2 2 3 5 3 3 2 1 5 6
d e t ( M 1 ) = d e t ( M ) ∗ − 1 det(M_{1}) = det(M) * -1 d e t ( M 1 ) = d e t ( M ) ∗ − 1
M 1 = [ 1 2 3 2 3 4 5 1 5 2 3 5 5 2 3 6 ] → r 2 ↔ r 3 M 2 = [ 1 2 3 2 3 4 5 1 5 2 3 6 5 2 3 5 ] M_{1} = \begin{bmatrix}
1 & 2 & 3 & 2 \\
3 & 4 & 5 & 1 \\
\textcolor{green}{5} & \textcolor{green}{2} & \textcolor{green}{3} & \textcolor{green}{5} \\
\textcolor{red}{5} & \textcolor{red}{2} & \textcolor{red}{3} & \textcolor{red}{6}
\end{bmatrix} \xrightarrow{r_{2} \leftrightarrow r_{3}}
M_{2} = \begin{bmatrix}
1 & 2 & 3 & 2 \\
3 & 4 & 5 & 1 \\
\textcolor{red}{5} & \textcolor{red}{2} & \textcolor{red}{3} & \textcolor{red}{6} \\
\textcolor{green}{5} & \textcolor{green}{2} & \textcolor{green}{3} & \textcolor{green}{5}
\end{bmatrix} M 1 = 1 3 5 5 2 4 2 2 3 5 3 3 2 1 5 6 r 2 ↔ r 3 M 2 = 1 3 5 5 2 4 2 2 3 5 3 3 2 1 6 5
d e t ( M 2 ) = d e t ( M 1 ) ∗ − 1 = ( d e t ( M ) ∗ − 1 ) ∗ − 1 = d e t ( M ) = 8 det(M_{2}) = det(M_{1}) * -1 = (det(M) * -1) * -1 = det(M) = 8 d e t ( M 2 ) = d e t ( M 1 ) ∗ − 1 = ( d e t ( M ) ∗ − 1 ) ∗ − 1 = d e t ( M ) = 8
# Row Swapping: 2 positions
# Swapping row 0 with row 1.
# Swapping row 2 with row 3.
print ( f " { np.linalg.det(M1) } "
Output:
Row Scaling
Scaling one row of a matrix by a scalar, scales the determinant of the matrix by the same scalar.
r 0 → k ∗ r 0 d e t ( A ) = k ∗ d e t ( M ) r_{0} \rightarrow k*r_{0} \\
det(A) = k * det(M) r 0 → k ∗ r 0 d e t ( A ) = k ∗ d e t ( M )
M = [ 3 4 5 1 1 2 3 2 5 2 3 5 5 2 3 6 ] → A = [ 3 k 4 k 5 k k 1 2 3 2 5 2 3 5 5 2 3 6 ] M = \begin{bmatrix}
\textcolor{red}{3} & \textcolor{red}{4} & \textcolor{red}{5} & \textcolor{red}{1} \\
1 & 2 & 3 & 2 \\
5 & 2 & 3 & 5 \\
5 & 2 & 3 & 6
\end{bmatrix} \xrightarrow{}
A = \begin{bmatrix}
\textcolor{red}{3k} & \textcolor{red}{4k} & \textcolor{red}{5k} & \textcolor{red}{k} \\
1 & 2 & 3 & 2 \\
5 & 2 & 3 & 5 \\
5 & 2 & 3 & 6
\end{bmatrix} M = 3 1 5 5 4 2 2 2 5 3 3 3 1 2 5 6 A = 3 k 1 5 5 4 k 2 2 2 5 k 3 3 3 k 2 5 6
d e t ( A ) = 8 k det(A) = 8k d e t ( A ) = 8 k
print ( f " { det_A = } is { k } times { det_M = } " )
Output:
det_A = 24.0 is 3 times det_M = 8.0
Row Addition
The adition of a row with another row scaled by a scalar, does not affect the determinant of the matrix.
r 0 → k 1 r 1 + k 2 r 2 + . . . r 0 → ∑ i = 1 n k i r i r_{0} \rightarrow k_{1}r_{1} + k_{2}r_{2} + ... \\
r_0 \rightarrow \sum_{i=1}^{n} k_i r_i r 0 → k 1 r 1 + k 2 r 2 + ... r 0 → i = 1 ∑ n k i r i
Where:
r 0 r_0 r 0 is the original row.
r i r_i r i are the rows to be added to r 0 r_0 r 0 with coefficients k i k_i k i
k i k_i k i are the coefficients of the rows r i r_i r i , where i = 1 , 2 , . . . , n i = 1, 2, ..., n i = 1 , 2 , ... , n
n n n is the total number of rows.
And the equation for the determinant remains the same:
det ( A ) = det ( M ) \text{det}(A) = \text{det}(M) det ( A ) = det ( M )
A[ 0 ] = A[ 0 ] + 2 * A[ 1 ] + 3 * A[ 2 ]
print ( f " { det_A = } is the same as { det_M = } " )
Output:
det_A = 8.0 is the same as det_M = 8.0