CubicEquationSolver icon indicating copy to clipboard operation
CubicEquationSolver copied to clipboard

Python Script to find the roots of a Cubic Equation

Cubic Equation Solver

Useful Information about the script :

  • Used as a subsitute of np.roots() function which utilizes Eigen Value Matrix Method for finding roots of the polynomial.

  • ~6x faster than np.roots but exclusive to cubic polynomials.

  • Manages the issue of inherent in the power basis representation of the polynomial in floating point numbers.

  • Time Complexity of snippet is O(1).

Algorithm Link

Sample Code

import CubicEquationSolver
CubicEquationSolver.solve(1, 0, 1, 0)
Output: [ 0.+0.j  0.+1.j -0.-1.j]