# Expanding rational functions with minimal denominator

I'm working with rational functions and I want to be able to put them in a specific form and then get a list of terms in which the numerators are monomials. Take for example

r[x_, y_, z_, v_] := x/(1 + y)^2 + y/v + z


What I would like is some function rationalMonomialList which gives me back

rationalMonomialList[r[x,y,z,v]]  (* output= {y/v, x/(1 + y)^2, z} *)


for r this is easy enough by taking

rationalMonomialList[rat_]:=
Module[{rat0=Expand[rat]},Table[rat0[[i]],{i,1,Length[rat0]}]]


which is the answer I want. This lets me write rf as $$r(x,y,z,v)=p(x,y,z,v)+q(x,y,z,v)+s(x,y,z,f)$$

where $p$ is a polynomial, $q$ is a laurent polynomial, and $s$ is a rational function. However, there are plenty of equivalent forms for rational functions, and this obviously won't work for most of them. As a counter example, The definition above gives the following:

rationalMonomialList[Apart[r[x,y,z,v]]]
(* out= {x/(1 + y)^2, y/(v (1 + y)^2), (2 y^2)/(v (1 + y)^2), y^3/(v (1 + y)^2), z} *)


Which is not of the form given above. What's a good way to do this?

I can't exactly guarantee that this works for arbitrary rational functions, but if you replace ExpandAll with FullSimplify it works on the cases you have provided at least.

Also, if you have more than one term after FullSimplify then the Head of the whole expression will be Plus, and the arguments will be the terms. So I find it easier to turn it into a list using the following:

rationalMonomialList[expr_] :=
With[{simp=FullSimplify[expr]}, If[Head[simp] === Plus, List @@ simp, {simp} ]

• I am always wary about using FullSimplify. I'm encountering these functions in a setting where I'm looking for exact solutions to some polynomial equations and there are cases where FullSimplify does not give me back something exactly equivalent to what I put in. Commented Mar 9, 2016 at 21:56

Since you commented that you do not trust FullSimplify perhaps you can use more transparent tools such as Cancel and Collect to effect your manipulations. I am not claiming this is robust but for your consideration:

reduce = Fold[Cancel @* Collect, #, Variables @ #] &;


Now:

Apart[r[x, y, z, v]]
reduce[%]
List @@ %

(v x + y + 2 y^2 + y^3)/(v (1 + y)^2) + z

y/v + x/(1 + y)^2 + z

{y/v, x/(1 + y)^2, z}