Rewriting a rational expression as a quotient and a remainder