@nexys/math-ts
Version:
[](https://www.npmjs.com/package/@nexys/math-ts) [](https://travis-ci.com/github/Nexysweb/math-ts) [ • 392 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.linear = (x, m, b) => exports.polynomial(x, [b, m]);
exports.quadratic = (x, a, b, c) => exports.polynomial(x, [c, b, a]);
exports.polynomial = (x, a) => {
if (a.length === 0) {
return 0;
}
return a.map((v, i) => {
return v * (Math.pow(x, i));
}).reduce((a, b) => a + b);
};