maths.simultaneous_linear_equation_solver¶
https://en.wikipedia.org/wiki/Augmented_matrix
This algorithm solves simultaneous linear equations of the form λa + λb + λc + λd + … = y as [λ, λ, λ, λ, …, y] Where λ & y are individual coefficients, the no. of equations = no. of coefficients - 1
Note in order to work there must exist 1 equation where all instances of λ and y != 0
Attributes¶
Functions¶
|
|
|
Module Contents¶
- maths.simultaneous_linear_equation_solver.simplify(current_set: list[list]) list[list] ¶
>>> simplify([[1, 2, 3], [4, 5, 6]]) [[1.0, 2.0, 3.0], [0.0, 0.75, 1.5]] >>> simplify([[5, 2, 5], [5, 1, 10]]) [[1.0, 0.4, 1.0], [0.0, 0.2, -1.0]]
- maths.simultaneous_linear_equation_solver.solve_simultaneous(equations: list[list]) list ¶
>>> solve_simultaneous([[1, 2, 3],[4, 5, 6]]) [-1.0, 2.0] >>> solve_simultaneous([[0, -3, 1, 7],[3, 2, -1, 11],[5, 1, -2, 12]]) [6.4, 1.2, 10.6] >>> solve_simultaneous([]) Traceback (most recent call last): ... IndexError: solve_simultaneous() requires n lists of length n+1 >>> solve_simultaneous([[1, 2, 3],[1, 2]]) Traceback (most recent call last): ... IndexError: solve_simultaneous() requires n lists of length n+1 >>> solve_simultaneous([[1, 2, 3],["a", 7, 8]]) Traceback (most recent call last): ... ValueError: solve_simultaneous() requires lists of integers >>> solve_simultaneous([[0, 2, 3],[4, 0, 6]]) Traceback (most recent call last): ... ValueError: solve_simultaneous() requires at least 1 full equation
- maths.simultaneous_linear_equation_solver.eq = [[2, 1, 1, 1, 1, 4], [1, 2, 1, 1, 1, 5], [1, 1, 2, 1, 1, 6], [1, 1, 1, 2, 1, 7], [1, 1, 1, 1, 2, 8]]¶