Hi Denis,I'm attaching a test program I wrote that compares the old and new algorithms.
Obviously the old one missed a bunch of solutions because it classified all solutions as 1 or 3, but the new one also sometimes misses a solution. You might want to turn this into an automated test for the bug (and maybe use it as a stress test with a random number generator).
I think one problem might be that you use "is close to zero" to check if you should use special processing. I think any tests which say "do it this way and get fewer roots" should be conservative and if we are on the borderline and we can do the code that generates more solutions then we should generate more and them maybe refine the roots and eliminate duplicates. That way we can be (more) sure not to leave any roots unsolved.
The test as it is has a test case (I just chose random numbers to check and got lucky - d'oh!) that generates 1 solution from the new code even though the equation had 2 distinct solutions that weren't even near each other...
...jim
CubicSolver.java
Description: java/