Package Exports
- quadratic-solver
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 (quadratic-solver) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Quadratic Equation Solver
This JavaScript library-slash-module brings the ability of finding roots of a quadratic equation by simply requiring it :)
Example Usage
Browser Import
<script src="https://unpkg.com/quadratic-solver"></script>
<script>
console.log(qs.GetVersion());
const rootsArr = qs.QuadSolver(2, 5, -3);
rootsArr.map(root => console.log(`Root: ${root}`));
</script>NodeJS Module
const { QuadSolver, GetVersion } = require("quadratic-solver");
console.log(GetVersion());
const rootsArr = QuadSolver(2, 5, -3);
rootsArr.map(root => console.log(`Root: ${root}`));Methods
QuadSolver(a, b, c)
Arguments
- a: coefficent of the squared term.
- b: coefficient of the linear term.
- c: constant with its sign.
Return Value
- when both roots are real:
Array[2]with the roots of the equation. - when only one root is real:
Array[2]wherein the first element is the real root and the other element is a warning. - when both roots are imaginary:
Array[2]in which both elements are warnings.
CompleteSquare(a, b, c)
Arguments
- a: coefficent of the squared term.
- b: coefficient of the linear term.
- c: constant with its sign.
Return Value
- when both roots are real:
Array[2]with the solutions for the equation. - when both roots are imaginary:
Array[2]with both elements are in which both elements areNaN.
QuadSolverCitardauq(a, b, c)
Arguments
Same as QuadSolver(a, b, c).
Return Value
Same as QuadSolver(a, b, c).
GetVersion()
Arguments
No arguments are required.
Return Value
String containing name and version of the package in quadratic-solver v0.x.x format.
ES6 Classes
Solver(a, b, c)
Properties
- a: coefficent of the squared term; default: 2.
- b: coefficient of the linear term; default: 5.
- c: constant with its sign; default: -3.
Methods
- versionMethod(): returns the package version.
Author
License
Source code distributed under the MIT License.