[Scilab-users] lack of simplification for rational

Tim Wescott tim at wescottdesign.com
Wed Nov 23 20:08:55 CET 2016


I think this is a case of "you can't get there from here", certainly if
you're using Scilab, and absolutely if you're getting your polynomials
by measuring the coefficients, or by, at some point, going from symbolic
representations to some sort of floating-point representation.

The underlying problem is that reducing the fractions the way that you
want to requires finding the roots of the polynomials involved, but the
task of finding the roots of a polynomial gets more and more numerically
unstable as the polynomial order goes up.

You might be able to do this reliably if you use a symbolic solver as,
for instance, Maxima, and if the order of your polynomials doesn't
exceed whatever that solver is capable of.  I'm not sure what Maxima can
do, but fifth-order is the maximum for which an algorithm exists to
factor any polynomial symbolically, and my understanding is that the
algorithm is horrid.  I would be pleasantly surprised if Maxima could
reliable do it with 3rd-order polynomials, and astonished if it could do
fourth- and fifth-order ones.

You may be reduced to doing this job by hand: factor the numerator and
denominator polynomials into their roots, then look for the roots that
come close to matching, then use that and knowledge of whatever it is
that you're modeling to decide which ones "really" cancel.

Just as a note: I'm not sure what physical processes you're trying to
represent with ratios of polynomials, but if you're working with
transfer functions of linear systems, having identical roots in
numerator and denominator can either arise from a mathematical artifact
in your computations, or it can be indicative of a pole-zero
cancellation in your physical system.  The former doesn't matter (other
than as an irritant), but a pole-zero cancellation can cause problems if
the pole in question is unstable or if it decays more slowly than it
receives excitation in the real world.  I don't know if similar cautions
apply in other realms with canceling roots in the numerator and
denominator -- but given my experience with control systems, I'd at
least check the physics behind any such cancellations.

On Wed, 2016-11-23 at 19:37 +0100, philippe wrote:
> 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 at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users

-- 

Tim Wescott
www.wescottdesign.com
Control & Communications systems, circuit & software design.
Phone: 503.631.7815
Cell:  503.349.8432





More information about the users mailing list