Introduction
Which columns in a matrix actually carry independent information, and which are just redundant combinations of the others? ConvertMatrixToRowEchelonForm answers that by reducing a matrix to reduced row echelon form (RREF) via Gaussian elimination, using SymPy's symbolic computation for reliable results. Along the way it reports the matrix's rank and, optionally, the pivot column indices — the columns that are linearly independent — which is exactly the diagnostic you need before trusting a regression's coefficients or a system's solvability.
Teaching Note
Transforming a matrix to row echelon form is essential for:
- Detecting multicollinearity and identifying redundant features in a dataset
- Determining the rank of a data matrix to assess feature dimensionality
- Selecting linearly independent variables for stable predictive modeling
- Solving systems of linear constraints in business optimization problems
- Finding a basis for the row or column space to understand data variance
- Identifying pivot columns to pinpoint the most informative, non-redundant features
- Analyzing the structural reachability within network adjacency matrices
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
matrixrequired | | — | The input matrix to be converted. Can be a nested list or a 2D numpy.ndarray of any dimensions. |
show_pivot_columns | | False | If True, the function will print a list containing the indices of the pivot columns (the columns containing leading 1s). Defaults to False. |
Returns
A NumPy array representing the matrix in reduced row echelon form.
Example
python
from analysistoolbox.linear_algebra import ConvertMatrixToRowEchelonForm
# Convert a 2x3 matrix to reduced row echelon form
matrix = [[1, 2, 3], [4, 5, 6]]
rref_matrix = ConvertMatrixToRowEchelonForm(matrix)