http://qs1969.pair.com?node_id=1189416


in reply to solve cubic equations

BTW, the some of the solutions returned by the second if branch may be the same. Mathematicians call these "multiple roots." If $u == 0, there is a triple root at $x = $s. If $t == 0, there is a single root at $x = $s - $u and a double root at x = $s + $u/2 (because cos(2/3*pi) == cos(-2/3*pi) == -1/2).