# Does there exist a generating function for the rational numbers?

Since the rationals are countable, you can list them in a sequence $$(a_n)_{n\geq 0}$$ such that each rational appears at least once in the sequence. Is there such a listing $$(a_n)_{n \geq 0}$$ for which $$\sum_{k = 0}^{\infty} a_kx^k =a_0 + a_1x + a_2x^2 + ...$$ has a closed form?

• As a word of caution: if the answer turns out to be "no", a proof probably wouldn't be a good fit on this site. – Arthur Mar 7 '19 at 14:18
• What do you mean by "nice"? – MathematicsStudent1122 Mar 7 '19 at 14:26
• I don't have anything specific in mind; I guess that closed form is enough, so I'll delete the "nice". – Tanny Sieben Mar 7 '19 at 14:43

Along the track of the Farey sequence, we could build a 2 variables generating function for all the rationals in $$[0,1]$$ as $$f(x,y) = \sum\limits_{1\, \le \,n} {\sum\limits_{1 \le m \le n} {\left[ {\gcd (n,m) = 1} \right]{m \over n}x^{\,n} y^{\,m} } }$$ where $$[P]$$ denotes the Iverson bracket.
We can also construct the o.g.f. above following instead the steps of the Stern-Brocot tree \eqalign{ & f_0 (x,y) = 0x + xy \cr & f_1 (x,y) = 0x + {1 \over 2}x^{\,2} y + xy \cr & f_2 (x,y) = 0x + {1 \over 3}x^{\,3} y + {1 \over 2}x^{\,2} y + {2 \over 3}x^{\,3} y^{\,2} + xy \cr & \quad \vdots \cr}