# Sec. 6 in G.F. Simmons' INTRO TO TOPOLOGY & MODERN ANALYSIS: A formula for the general terms of these two sequences please?

The set $$\mathbb{Q}^+$$ of all the positive rational numbers is given by $$\mathbf{Q}^+ = \left\{ \ \frac{p}{q} \ \colon \ p \in \mathbf{N}, q \in \mathbf{N} \ \right\}.$$ This set is countably infinite; so we can list its elements as a sequence (or an infinite sequence). One such sequence is as follows: $$1, \ \frac{1}{2}, \ \frac{2}{1} = 2, \ \frac{1}{3}, \ \frac{3}{1} = 3, \ \frac{1}{4}, \ \frac{2}{3}, \ \frac{3}{2}, \ \frac{4}{1} = 4, \ \frac{1}{5}, \ \frac{5}{1} = 5, \ \frac{1}{6}, \ \frac{2}{5}, \ \frac{3}{4}, \ \frac{4}{3}, \ \frac{5}{2}, \ \frac{6}{1} = 6, \ \frac{1}{7}, \ \frac{3}{5}, \ \frac{5}{3}, \ \frac{7}{1} = 7, \ \frac{1}{8}, \ \frac{2}{7}, \ \frac{4}{5}, \ \frac{5}{4}, \ \frac{7}{2}, \ \frac{8}{1} = 8, \ \ldots.$$ Here we have ordered the positive rationals by the size of the sum of the numerator and denominator, making sure to avoid repetition. Is this sequence correct as far as I've given it?

Now my question is, can we find a formula for the general term of this sequence? If so, then how to? I'd appreciate if the entire process is explained in detail.

Similarly, the set $$\mathbf{Q}$$ of all rational numbers is given by $$\mathbf{Q} = \left\{ \ \frac{p}{q} \ \colon \ p \in \mathbf{Z}, q \in \mathbf{Z}, q \neq 0 \ \right\}.$$ And, since $$\mathbf{Q}$$ is also countably infinite, we can list its elements as an infinite sequence. One such sequence is as follows: $$0, 1, -1, \frac{1}{2}, -\frac{1}{2}, 2, -2, \frac{1}{3}, -\frac{1}{3}, 3, -3, \frac{1}{4}, -\frac{1}{4}, \frac{2}{3}, -\frac{2}{3}, \frac{3}{2}, -\frac{3}{2}, 4, -4, \frac{1}{5}, -\frac{1}{5}, 5, -5, \frac{1}{6}, -\frac{1}{6}, \frac{2}{5}, -\frac{2}{5}, \frac{3}{4}, -\frac{3}{4}, \frac{4}{3}, -\frac{4}{3}, \frac{5}{2}, -\frac{5}{2}, 6, -6, \frac{1}{7}, -\frac{1}{7}, \frac{3}{5}, -\frac{3}{5}, \frac{5}{3}, -\frac{5}{3}, 7, -7, \frac{1}{8}, -\frac{1}{8}, \frac{2}{7}, -\frac{2}{7}, \frac{4}{5}, -\frac{4}{5}, \frac{5}{4}, -\frac{5}{4}, \frac{7}{2}, -\frac{7}{2}, 8, -8, \ldots.$$ This sequence is based on the scheme of the earlier sequence, except that (1) we begin with $$0$$ and (2) we follow each positive rational number as we come to it by its negative.

My second question is, how to find out a formula for the general term of this particular sequence of the rational numbers? I'd again really appreciate if the whole process is explained in detail.

Last but not the least, any references for reading up on this?

Such formulae necessarily involve the Euler's totient function, because the number of positive fractions $$p/q$$ (in their lower terms, of course) such that $$p+q=n$$ is precisely $$\varphi(n)$$. Then, for the first sequence, the $$k$$-th term can be obtained this way:
Let $$n=\max\{t\in\Bbb N:\sum_{j=1}^t\varphi(j)\le k\}$$. In other words, sum $$\varphi(1)+\varphi(2)+\cdots$$ until you exceed $$k$$. Then, the terms of the fraction sum $$n$$. Now, let $$r=k-\sum_{j=1}^{n-1}\varphi(j)$$ Then, the numerator of the fraction is the $$r$$-th number coprime with $$n$$.
Example: To find the $$100$$-th term first we see that $$\sum_{j=1}^{19}\varphi(j)=98$$ and $$\sum_{j=1}^{20}\varphi(j)=106$$, so the sum of the terms of the fraction is $$19$$. Since $$100-98=2$$ the numerator if the fraction is the second number coprime with $$19$$, namely $$2$$, so the $$100$$th term is $$2/17$$.
The formula (or, rather, the algorithm) for the second sequence is very similar. You have to count the first term, $$0$$, and sum $$2\varphi(j)$$ instead of $$\varphi(j)$$.