Solving Systems of Linear Equations (lib601.le)¶
Tools for solving systems of linear equations
-
lib601.le.gauss_solve(A, b, verbose=False)¶ Solve \(Ax = b\) using Gauss-Jordan elimination
Parameters: - A – the matrix \(A\), as a list of lists
- b – the vector \(b\), as a list
- verbose – If
True, prints extra information
Returns: the solution vector \(x\), as a list
-
lib601.le.solve_equations(eqnlist, verbose=False)¶ Solve a system of linear equations. Raises an exception if the number of variables is not equal to the number of equations.
Parameters: - eqnlist – The list of equations to be solved. Each equation is a
list of tuples
(coefficient, variable)such that the sum ofcoeff*varfor each pair equals to zero. If variable isNone, then the associated coefficient is taken to be a constant term - verbose – If
True, prints extra information
Returns: A dictionary mapping from variable names to solutions.
- eqnlist – The list of equations to be solved. Each equation is a
list of tuples