Most equations need to be solved numerically since no close-form expression representing their solutions can be obtained.
For polynomial equations of order 1, 2, 3, 4 exact solutions can be obtained. I have created a series of solvers up to a cubic solver,
that can be used to obtain most exact solutions. Of course with floating point errors, not everything is going to come out looking clean.
To be able to handle complex numbers I made a simplified version of a complex number without all the mathematical operations.
If you call the cubicSolve
function with a = 0
then the solver falls back on the quadratic solver, the quadratic solver will fallback on the linear solver and linear solver will return an empty array(Thanks for catching that u\korbonix).
Example Usage