Row Echelon form
A matrix is in row-echelon form if
All rows that contain zeros are at the bottom of the matrix; correspondingly all rows that contain at least one nonzero element are on top of rows that contain only zeros.
Looking at nonzero rows only, the first nonzero number from the left(also called the pivot or the leading coefficient) is always strictly to the right of the pivot of the row above it.
The variables corresponds to the pivots in the row-echelon form are called basic variables and the other variables are free variables.The column which contains the pivot element are called pivot columns.
from sympy import Matrix
M = Matrix([[1,2,3,4], [5,6,3, 4],[7,8,1,5]])
display(M.echelon_form())
1002−403−1284−16−4
Reduced Row Echelon form
An equation is in reduced row-echelon form ( row reduced echelon form or row canonical form) if
It is in row-echelon form
Every pivot is 1
The pivot is the only nonzero entry in its column.
There's actually a built-in library in python called sympy. The function Matrix().rref() can be used to obtain the reduced row echelon form of a matrix. The return value of this function includes two things: 1) the reduced row echelon form of the given matrix and 2) the indices of the rows in the matrix which contain the pivots (note that rows are 0-indexed).
import sympy
M = Matrix([[1,2,3], [5,6,3],[7,8,1]])
R=M.rref()
display(R)
o/p
(Matrix
([
[1, 0, 0],
[0, 1, 0],
[0, 0, 1]]),
(0, 1, 2))
Comments
Post a Comment