2
votes

Is there a way to check if a rational function is a polynomial in Matlab?


I have a big rational function, call it R, that I am trying to show is a polynomial. I've tried the simplify and simplifyFraction functions and the following (not very effective) procedure:

  1. Split it into denominator and numerator:

    [num,den] = numden(R);
    
  2. Calculate the roots of both polynomials:

    r_num = roots(sym2poly(num));
    r_den = roots(sym2poly(den));
    
  3. Check if all the elements of r_den belong to r_num:

Because of numerical imprecision I haven't been able to come up with a reliable way of doing this.

1
Have you tried to simple perform a division with remainder? If the remainder is zero, then the denomnator exactly divides into the numerator. - Lutz Lehmann

1 Answers

2
votes

This is a not-so-easy problem and finding greatest common divisor of polynomials is a very active area of research. There are tons of publications and you can find them online.

The main problem is that root finding is an ill-conditioned problem. And recently a few experts are trying to combine the numerical computations with symbolic representations. If you google for ERES method you will have an entry point together with thesis of Christou.

This problem is particularly important for signals and control people because of the transfer function representations and pole zero cancellations. Matlab goes out a long way to make sure that all is OK and a minimal neighborhood of each pole zero is accepted as a cancellation.

So as a quick remedy, convert your polynomial coefficients to 1D vectors, say a and b, and use minreal(tf(a,b)). Then you can extract num and den of that transfer representation.

Shameless plug: I am the author of a python3 library and I also implemented a system theoretical approach. Here and here is the full implementation details with citations about LCM and GCD operations.