https://github.com/calebowens/gaussian-elimination
https://github.com/calebowens/gaussian-elimination
Last synced: over 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/calebowens/gaussian-elimination
- Owner: calebowens
- License: bsl-1.0
- Created: 2022-05-25T16:22:35.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-26T17:20:01.000Z (about 4 years ago)
- Last Synced: 2025-01-17T14:55:53.493Z (over 1 year ago)
- Language: TypeScript
- Size: 77.1 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Gaussian Elimination
This simple library facilitates the solving of simultaneous equations and finding the
inverse of matrices via Gaussian Elimination.
Docs: [View Docs](https://calebowens.github.io/Gaussian-Elimination/)
## Usage
### Simultaneous Equations
Create a Tableau to represent this set of equations

```ts
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
```ts
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
```ts
tableau.getLHSFirsts() // Returns [2, 3, -1]
```
### Matrix Inversion
Finding the inverse the above LHS
```ts
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 ] ]
```