JSPM

linear-quadratic-cubic-eq-solver

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 18
  • Score
    100M100P100Q55356F
  • License MIT

solves linear, quadratic and cubic equations

Package Exports

  • linear-quadratic-cubic-eq-solver
  • linear-quadratic-cubic-eq-solver/lib/index.js

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 (linear-quadratic-cubic-eq-solver) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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 ]