Package Exports
- @theiliad/interpolatejs
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@theiliad/interpolatejs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
interpolateJS
Lagrange interpolation to the rescue!
Intro
InterpolateJS constructs a linear interpolation function p(x) for your provided set of x and y-values, using the Lagrange basis polynomials.
Using .evaluate() you can then provide an x-value to the function, and get an interpolated y-value.
Getting started
Installation:
npm i --save @theiliad/interpolatejsUsage
import/require:
import { interpolation, fraction } from "@theiliad/interpolatejs/index";
const xValues = [fraction(1, 3), fraction(1, 4), 1];
const yValues = [2, -1, 7];
const pOfx = interpolation(xValues, yValues);
console.log("p(1/3) =", pOfx.evaluate(fraction(1, 3)));
// ==> p(1/3) = 2In-browser CDN Usage:
<script src="https://unpkg.com/@theiliad/interpolatejs"></script>
<script>
const { interpolation, fraction } = interpolateJS;
const xValues = [fraction(1, 3), fraction(1, 4), 1];
const yValues = [2, -1, 7];
const pOfx = interpolation(xValues, yValues);
console.log(
"p(1/3) =",
pOfx.evaluate(
fraction(1, 3)
)
);
</script>