First of all if you compute the rational fraction numerator or denominator from their roots (and if they are complex conjugate) the result is a complex polynomial even if the imaginary part is not shown.

Second: the simplification of numerical rational fraction is a very difficult problem. As Tim said the roots computed by numerical algorithm cannot be use for that purpose.
Just try:
p=poly(ones(1,n),"x","c");
r=roots(p)
plot(real(r)-1,imag(r),"+")
You will see the roots on a circle which radius is of order %eps^(1/n) !
It is not a bug just a consequence of the numerical computations.

The simplication algorithm present in Scilab tryes to find reasonable simplification based on the bezout equation error. But it has only be written for the real case.

The bug fixes Samuel pointed to you allow simplification for complex polynomials having zero imaginary parts.
Serge
Le 23/11/2016 à 19:37, philippe a écrit :
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


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

Reply via email to