linear-quadratic-cubic-eq-solver
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

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=2x^2-32x+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 ]

Package Sidebar

Install

npm i linear-quadratic-cubic-eq-solver

Weekly Downloads

4

Version

1.0.0

License

MIT

Unpacked Size

10.3 kB

Total Files

6

Last publish

Collaborators

  • feirell