1.0.0 • Published 2 years ago

linear-quadratic-cubic-eq-solver v1.0.0

Weekly downloads
6
License
MIT
Repository
-
Last release
2 years ago

linear-quadratic-cubic-eq-solver

npm GitHub issues

functions

This package exposes three different functions:

solveLinearEquation(a, b)

Which is able to solve equations in the form of:

0=ax+b

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:

0=ax^2+bx+c

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) when a == 0

solveCubicEquation(a, b, c, d)

Which is able to solve equations in the form of:

0=ax^3+bx^2+cx+d

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) when a == 0
  • or [0] and the return possibilities of solveQuadraticEquation(a, b, c) when d == 0

Solve an eqaution

To solve an equation like:

4=2*x^2-32*x+2.1

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 ]
1.0.0

2 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

6 years ago

0.0.1

6 years ago