nodequadratic
v1.3.0
Published
Quadratic solver
Downloads
27
Maintainers
Readme
Node Quadratic
In algebra, a quadratic function, a quadratic polynomial, a polynomial of degree 2, or simply a quadratic, is a polynomial function in one or more variables in which the highest-degree term is of the second degree.
Installation
This is a Node.js module available through the npm registry.
Before installing nodequadratic
, download and install Node.js
Installation is accomplished using the npm install command:
$ npm i nodequadratic --save
Usage
Node Quadratic is a very simple package to use:
var nodequadratic = require("nodequadratic");
// var result = nodequadratic.solve(a, b, c);
var result = nodequadratic.solve(1, -12, -28);
console.log(result);
/* {
discriminant: 256,
solutions: {
plus: 14,
minus: -2
}
} */
console.log(`The roots are ${result.solutions.plus} and ${result.solutions.minus}`);
// The roots are 14 and -2
The plus and minus solutions are a result of subtracting or adding the discriminant from -b before dividing by 2a.
console.log(result.solutions.plus);
// 14