Socket
Socket
Sign inDemoInstall

cubic-roots

Package Overview
Dependencies
2
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

cubic-roots


Version published
Weekly downloads
379
increased by221.19%
Maintainers
1
Install size
2.51 MB
Created
Weekly downloads
 

Readme

Source

cubic-roots

Implementation of Kahan's cubic root finder.

Motivation

According to Kahan, standard cubic root finders based on classical methods are prone to numerical inaccuracies. This is an implementation of a numerically stable method illustrated in Kahan's notes titled "To Solve a Real Cubic Equation".

The notes can be found here: http://people.eecs.berkeley.edu/~wkahan/Math128/Cubic.pdf.

Usage

The quadratic equation solved is Ax2 + Bx + C = 0. The cubic equation solved is Ax3 + Bx2 + Cx + D = 0.

  • getQuadraticRoots(A, B, C)
    • returns 4 real numbers: A1, B1, A2, B2
    • this corresponds to the (possibly) complex roots A1 + B1 * i and A2 + B2 * i.
  • getCubicRoots(A, B, C, D)
    • returns 5 real numbers: A0, A1, B1, A2, B2
    • this corresponds to the 1 real and 2 (possibly) complex roots A0, A1 + B1 * i, and A2 + B2 * i.

Author

Algorithm and pseudocode by William Kahan. Implementation in Javascript by Tim Bright

License

(c) Tim Bright, 2017. MIT License.

Keywords

FAQs

Last updated on 12 Sep 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc