Solving Linear Systems
🧮 Solving Linear Systems with the Gauss–Jordan Method​
A linear system of equations can be written in matrix form as:
where
The Gauss–Jordan method transforms the matrix into the identity matrix by using row operations, producing the solution vector .
In practice, we can use numerical libraries (like NumPy) that implement efficient algorithms based on LU/Gaussian elimination.
🔹 Example in Python​
import numpy as np
# Coefficient matrix (3x3)
A = np.array([[2, 1, -1],
[-3, -1, 2],
[-2, 1, 2]], dtype=float)
# Constants vector (1D is common for np.linalg.solve)
b = np.array([8, -11, -3], dtype=float)
# Solve the system A * x = b
x = np.linalg.solve(A, b)
print("Solution:")
print(x)
Output:
[ 2. 3. -1.]
📘 Mathematical Explanation​
We are solving the system:
By applying Gauss–Jordan elimination we reduce the augmented matrix
to the identity matrix on the left:
Therefore, the solution is: