Got solveCubic() working, but it has some things which can be improved on