Linear algebra in javascript
Every other week I find myself solving some kind of problem that involves matrix operations or other linear algebra concepts. I still have my old TI-89 from when I was a student. It’s a handy calculator, no doubt about that, older people will even call it a luxury. But quite frankly, I don’t know why we should use calculators considering the speed of an average personal computer. Or even a cellphone in case you’re thinking about throwing the portability argument.
Anyway, rants aside, I was bored so I put together a tiny javascript library with basic linear algebra functions.
Here’s the infamous system of linear equations solve example:
Let’s consider the following system of linear equations:
x + y + z = 1 x + 2y + 3z = 4 x + 4y + 8z = 8
from your first algebra class..
A.x = b x = Inv(A).b
So let’s just to that
A = [[1,1,1],[1,2,3],[1,4,8]]; b = [[1],[4],[8]]; Ai = inverseMatrix(a); x = matrixMultiply(Ai,b); //will return the solution [[28],[49],[22]] yay!!! |
More examples and download at github.
Mmm…. turns out my rant is all but original.
Related Posts:
Tags: algebra, javascript, mathematics, ualgebra.js
November 29th, 2012 at 07:18
Great a submit. Standard drawback is usually G. modify ones own spirit far too repeatedly.