MATLAB: How to calculate the min and max degree/order of a rational polynomial

Symbolic Math Toolbox

I have a algebraic function of 't':
syms t;
p=5/t^2 - 9/t - 9*t + 5*t^2 - 1/t^4 - t^3 + 19;
How do I find the min and max order of 't'?
For example, min = -4, max = 3.

Best Answer

Currently, there is no built-in function to calculate the min and max order of a rational polynomial.
There are two workarounds. If I have the following rational polynomials for example:
p{1} = t^5 + 2*t^4 + 3*t^3 + 4*t^2 + 5*t + 6 + 7/t + 8/t^2 + 9/t^3;
p{2} = t^5 + 2*t^4 + 3*t^3 + 4*t^2;
The workarounds are:
[num,den]=numden(p{i});
orderNum = polynomialDegree(num);
orderDen = polynomialDegree(den);
% workaround 1
if orderNum~=0 && orderDen~=0
minOrder = -orderDen;
maxOrder = orderNum - orderDen;
elseif orderDen==0
maxOrder = orderNum;
indexNonZeroCoeff = find(fliplr(coeffs(p{i},'all'))>0);
minOrder = indexNonZeroCoeff(1)-1;
end
% workaround 2
[n, d] = numden(p{i});
maxo = polynomialDegree(n)-polynomialDegree(d);
[d, n] = numden(subs(p{i}, t, 1/t));
mino = polynomialDegree(n) - polynomialDegree(d);
Please see the attached file 'exampleFindOrder.m' for the full example code.
For more detailed information about the 'polynomialDegree' function: