Skip to content

Instantly share code, notes, and snippets.

View Modjular's full-sized avatar
🛠️

Tony Reksoatmodjo Modjular

🛠️
View GitHub Profile
@Modjular
Modjular / lagrange.js
Last active August 18, 2018 01:48 — forked from maccesch/lagrange.js
Lagrange Polynomial Interpolation. Example (Updated 8/2018): http://jsfiddle.net/jgU3Y/107/
/**
* At least two points are needed to interpolate something.
* @class Lagrange polynomial interpolation.
* The computed interpolation polynomial will be reffered to as L(x).
* @example
* var l = new Lagrange(0, 0, 1, 1);
* var index = l.addPoint(0.5, 0.8);
* console.log(l.valueOf(0.1));
*
* l.changePoint(index, 0.5, 0.1);