> I want to know general methods to avoid a small imaginary error.
I guess that you need somethingh similar to the "chop" operator in Mathematica.
You can try this.
(%i1) fpprintprec: 5$ /* just to avoid too much figures in output */
(%i2) s: float(rectform(solve(x^3-3*x^2-2*x+1,x)));
(%o2) : [x=.34338-2.2204*10^-16*%i,x=2.2204*10^-16*%i-.83424,x=1.1102*10^-16*%i+3.4909]
(%i3) zero: 1e-8 $ /* your arbitrary threshold */
(%i4) for i:1 thru length(s) do
(if imagpart(rhs(s[i])) <= 1e-8 then s[i]: x=realpart(rhs(s[i])) else false ) ;
(%i5) s;
(%o5) [x=.34338,x=-.83424,x=3.4909]
Best
________________________________________________________________
Jose Sanchez-Marin.
Universitat de Valencia.
Institut de Ciencia Molecular (ICMol).
Cat. Jose Beltran Martinez, 2 Phone: +34 96 354 4444
E-46980 Paterna FAX: +34 96 354 3576
Spain e-mail: Jose.Sanchez at uv.es
_________________________________________________________________