linear_algebra.gauss_jordan =========================== .. py:module:: linear_algebra.gauss_jordan Functions --------- .. autoapisummary:: linear_algebra.gauss_jordan.gauss_jordan Module Contents --------------- .. py:function:: gauss_jordan(coefficients: numpy.ndarray, vertices: numpy.ndarray) -> tuple[numpy.ndarray, numpy.ndarray] Performs Gauss-Jordan elimination on the system Ax = b to reduce A to its Reduced Row Echelon Form (RREF) and transform b accordingly. Args: coefficients: A 2D NumPy array representing the coefficient matrix A. vertices: A column vector (2D NumPy array) representing the RHS b. Returns: A tuple containing: - RREF of matrix A - Transformed RHS vector b Raises: ValueError: If shapes of A and b are incompatible. See Also: https://en.wikibooks.org/wiki/Linear_Algebra/Gauss-Jordan_Reduction Examples: >>> import numpy as np >>> A = np.array([[1, 2, -1], [2, 4, -2], [3, 6, -3]]) >>> b = np.array([[1], [2], [3]]) >>> rref_A, rref_b = gauss_jordan(A, b) >>> np.allclose(rref_A, np.array([[1., 2., -1.], [0., 0., 0.], [0., 0., 0.]])) True >>> np.allclose(rref_b, np.array([[1.], [0.], [0.]])) True