Solving 3rd order equation by solve.



Hi,
and yet another variant of Pepe's and Rupert's solutions:

(%i1) chop (x, eps) := if is (imagpart (x) < eps) then realpart (x) else x$

(%i2) chop_solve ([args]) := map (lambda ([eq], lhs (eq) = chop (rhs (eq), 1e-8)), float (rectform (apply (solve, args))))$

(%i3) chop_solve(x^3-3*x^2-2*x+1, x);

(%o3) [x = .3433795689528897, x = - .8342431843139217,  x = 3.490863615361032]


Regards,
Jaime