5.115 How to find all poles and their order of a rational function?

Gives a rational function in \(x\), such as

\[ \frac {1}{10 \left (x -4\right ) \left (x -5\right )^{3}} \]
How to find all its poles which are \(x=4\) and \(x=5\) and the order of each pole which will be \(1\) and \(3\) in this example?

Using  sqrfree as follows

restart; 
get_poles_and_order:=proc(r_in,x::symbol)::list; 
  local r:=r_in,N::posint; 
  local the_poles::list; 
  local item; 
 
  r:=normal(r); 
  if not type(r,'ratpoly'(anything,x)) then 
     error("Not be a polynomial or a rational function in ",x) 
  fi; 
 
  the_poles := sqrfree(denom(r),x); 
  the_poles := the_poles[2,..]; #we do not need the overall factor 
  for N,item in the_poles do 
      the_poles[N]:=[solve(item[1]=0,x),item[2]]; 
  od; 
  return the_poles; 
 
end proc:
 

The above proc get_poles_and_order returns back a list of lists. Each sublist has its first entry the pole and the second entry the order.

Here are some examples

r:=1/(10*(x-4)*(x-5)^3); 
get_poles_and_order(r,x) 
 
     #[[4, 1], [5, 3]]
 

The above says there is a pole at \(x=4\) of order 1 and pole at \(x=5\) of order 3.