gaussian-elimination-co
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Gaussian Elimination

This simple library facilitates the solving of simultaneous equations and finding the inverse of matrices via Gaussian Elimination.

Docs: View Docs

Usage

Simultaneous Equations

Create a Tableau to represent this set of equations

equations

import { Tableau } from './main'

const tableau = Tableau.from([
  [[ 2 ,  1 , -1 ], [ 8 ]],
  [[-3 , -1 ,  2 ], [-11]],
  [[-2 ,  1 ,  2 ], [-3 ]],
])

Then to solve the equations

tableau.solve() // Returns [[2, 3, -1]]

After solving, to get just the first elements of all right-hand side of the tableau, you can use

tableau.getLHSFirsts() // Returns [2, 3, -1]

Matrix Inversion

Finding the inverse the above LHS

import { Tableau } from './main'

const tableau = Tableau.from([
  [[ 2 ,  1 , -1 ], [ 1 , 0 , 0 ]],
  [[-3 , -1 ,  2 ], [ 0 , 1 , 0 ]],
  [[-2 ,  1 ,  2 ], [ 0 , 0 , 1 ]],
])

tableau.solve() // Returns [ [ 4, 3, -1 ], [-2, -2, 1 ], [ 5, 4, -1 ] ]

Package Sidebar

Install

npm i gaussian-elimination-co

Weekly Downloads

1

Version

1.1.0

License

Boost

Unpacked Size

16.6 kB

Total Files

12

Last publish

Collaborators

  • calebowensperson