# Running a search algorithm

I want to write a program to check whether a given rational function $f(x,y)$ in two variables $x,y$(=$\dfrac{\text{polynomial in } x,y}{\text{polynomial in }x,y}$) is of the form $\sum_{i_k,j_k,l_k,m_k}\dfrac{1+x^{i_k}+y^{j_k}}{1+x^{l_k}+y^{m_k}}$ where $i_k,j_k,l_k,m_k$ runs from $0$ to $5$(say), and $k=$number of summands is $16$(say).

Is there a way to run a for loop that checks this? The main problem for me is that there are too many variables involved.

Could you please provide a concrete example of the fractions you want to deal with, so that we get an idea of their structure, their degree, etc ?