clear all ; The 3 solutions for x in the cubic equation: 0 = x^3 + a1 x^2 + a2 x + a3 q=(3a2-a1^2)/9 r=(9a1*a2-27a3-2a1^3)/54 s=(r+(q^3+r^2)^.5)^(1/3) t=(r-(q^3+r^2)^.5)^(1/3) real_root=s+t-a1/3 eliminate s t q r ; Next determine the other 2 roots from the real root: other_roots=(-a1-real_root+sign*(-3*real_root^2-2*a1*real_root+a1^2-4*a2)^.5)/2 eliminate real_root clear 2-5