GaussSimple.py solves a system of linear equations of the form Ax = b. You enter the coefficient matrix A and the results vector b interactively in the console, and the program prints the solution vector x.
Despite its name, the program delegates the actual solving to
numpy.linalg.solve rather than implementing Gaussian elimination steps manually.Prerequisites
You need NumPy installed:How to run
Functions
IngresarMatriz(T1, matriz)
IngresarMatriz(T1, matriz)
Prompts you to fill every cell of the square coefficient matrix.
T1 is the matrix size, and matriz is the pre-allocated NumPy zero matrix passed in from the main script.Only square matrices are supported. Both the row loop and the column loop iterate
T1 times, so rectangular inputs are not possible.IngresarRes(T1, res)
IngresarRes(T1, res)
Prompts you to fill the results column vector b.
res is a T × 1 NumPy zero matrix; each element corresponds to the right-hand side of one equation.MostrarMatriz(matriz)
MostrarMatriz(matriz)
Prints any matrix or vector row by row. The
*m unpacking removes brackets and commas for clean output. Works for both the coefficient matrix and the solution vector.Main script flow
Worked example: 2×2 system
Consider this system of two equations:Constraints and limitations
| Constraint | Detail |
|---|---|
| Square matrices only | Both IngresarMatriz and IngresarRes iterate T1 times in both dimensions; non-square input is not supported |
| Integer input only | Values are cast with int(input(...)) — decimal coefficients will raise a ValueError |
| Single run | There is no loop or menu; the program exits after printing the solution |
| NumPy required | numpy must be installed; the program imports it as np at the top of the file |
If the coefficient matrix is singular (i.e., the system has no unique solution),
numpy.linalg.solve will raise a LinAlgError. The program does not catch this exception.