Hi,

I have a problem to simplify automatically rational with an imaginary part. In my case I only manipulate polynomials with real coefficients but some imaginary part arise due to rounding errors. See this example :

-->X=poly(0,'x');

-->A=(X-1)^2;

-->B=(X-1)*(X-2);

-->R=A/B// = (X-1)/(X-2)
 R  =

  - 1 + x
    -----
  - 2 + x

-->A=clean(A+%eps*(1+%i))//  add a rounding error
 A  =

Partie réelle


              2
    1 - 2x + x
Partie imaginaire


    0

-->R=A/B// = no simplifications
 R  =

                2
    1 - 2x +  1x
   --------------
              2
    2 - 3x + x


I can't simplify R, even using simp(R), I've found some work around applying clean to numerator/denominator coefficients TWICE (I don't known why twice?!?!?) :

-->R=poly(clean(coeff(numer(R))),'x')/poly(clean(coeff(denom(R))),'x')
 R  =

             2
  - 2 + x + x
    ---------
             2
  - 6 + x + x

-->R=poly(clean(coeff(numer(R))),'x')/poly(clean(coeff(denom(R))),'x')
 R  =

    2 + x
    -----
    6 + x

but of course this doesn't work for polynomials with complex coefficients like :


-->(X+%i)/(X^2+1) // = 1/(X-%i)
 ans  =


   i +  1x
   --------
         2
    1 + x

I would like to find a solution for all polynomials with real/complex coefficients , any idea ?

Philippe

_______________________________________________
users mailing list
users@lists.scilab.org
http://lists.scilab.org/mailman/listinfo/users

Reply via email to