linear-quadratic-cubic-eq-solver
functions
This package exposes three different functions:
solveLinearEquation(a, b)
Which is able to solve equations in the form of:
It returns
-
[]
when there is no solution -
[0]
when every x is an sulution -
[x:number]
with the solution
solveQuadraticEquation(a, b, c)
Which is able to solve equations in the form of:
It returns
-
[x_1:number, x_2:number]
or[x_1:Complex, x_2:Complex]
with the two solutions - or the return possibilities of
solveLinearEquation(a, b)
whena == 0
solveCubicEquation(a, b, c, d)
Which is able to solve equations in the form of:
It returns
-
[x_1:number|Complex, x_2:number|Complex, x_3:number|Complex]
with the two solutions - or the return possibilities of
solveQuadraticEquation(a, b, c)
whena == 0
- or
[0]
and the return possibilities ofsolveQuadraticEquation(a, b, c)
whend == 0
Solve an eqaution
To solve an equation like:
You can use this package like this:
const solver = require('linear-quadratic-cubic-eq-solver');
const solutions = solver.solveQuadraticEquation(2, -32, 2.1 - 4);
console.log('solutions', solutions);
// which returns: solutions [ 16.059156283383516, -0.05915628338351553 ]