Skip to content

A Python module that can solve systems of linear equations.

Notifications You must be signed in to change notification settings

tomas7770/linsys-solver

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

System of linear equations solver

A Python module that can solve systems of linear equations using Gauss-Jordan elimination.

Developed for fun and as a coding exercise; better alternatives certainly exist.

Tested with Python 3.10.1, untested with other versions.

Usage:

# (Assuming the file is named "solver.py")
import solver

# Solve the system {x-2y=4, -2x+3y=0}
solution = solver.solve([ [1, -2, 4], [-2, 3, 0] ])
# solution = ('-12.0', '-8.0') ; x = -12, y = -8

# Solve the system {y+4z=2}
solution = solver.solve([ [0, 1, 4, 2] ])
# solution = ('X0', '-4.0*X2+2.0', 'X2') ; x = x, y = -4z+2, z = z
# Variables in a solution are named as 'Xn', where n is an integer
# starting at 0

# Example of an impossible system {x=1, x=2}
solution = solver.solve([ [1, 1], [1, 2] ])
# solution = ()

About

A Python module that can solve systems of linear equations.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages