1.0.0 • Published 2 years ago

@alesmenzel/cubic-equation v1.0.0

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

🥉 Cubic equation

Javascript implementation calculating roots of cubic equation. Based on Alexander Shtuchkin's implementation.

Installation

npm install @alesmenzel/cubic-equation

Usage

import { calculateCubicRoots } from "@alesmenzel/cubic-equation"

// ax^3 + bx^2 + cx + d = 0
const a = 1
const b = 2
const c = 3
const d = 4
calculateCubicRoots(a, b, c, d)
calculateCubicRoots(a, b, c, d, {
  isZero(value) {
    return value === 0 // or use the default that treats numbers < 1e10 as zeros
  }
})