function retval = ratint(B, A, lo, hi)
  ## B = [1];
  ## (s + 1) * (s + 2)^3
  ## A = conv([1,1], convpow([1, 2], 3));
  ## A = [1, 0, 0]

  [R, P, K, E] = residue(B, A);
  empty_list_elements_ok = 1;
  y = [];
  for x = [lo, hi]
    val = 0; 
    if(length(E) > 0)
      E1 = ( E ~= 1);
      E2 = ( E == 1);
      if(any(E1))
	F1 = E(E1) - 1;
	P1 = P(E1);
	R1 = R(E1);
	val = val - sum( R1 ./ F1 ./ (x - P1) .^ F1);
      endif
      if(any(E2))
	##F2 = E(E2)
	P2 = P(E2);
	R2 = R(E2);
	val = val + sum(R2 .* log(x - P2));
      endif
    endif
    if(length(K) > 0)
      val = val + polyval(polyinteg(K), x);
    endif
    y = [y, val];
  endfor
  retval = y(2) - y(1);
endfunction