This is from my attempt to show $\frac{22}{7}$ is the best approximation of $\pi$ with denominator not more than $50$.
My attempt as follows:
Suppose there is a better rational approximation, $\frac pq$: $\left|\pi-\frac pq\right|<\frac{22}{7}-\pi$
$$\pi-\frac{22}{7}<\pi-\frac pq<\frac{22}{7}-\pi$$
$$-\frac{22}{7}<-\frac pq<\frac{22}{7}-2\pi$$
$$\frac{22}{7}>\frac pq>-\frac{22}{7}+2\pi$$
$$\frac{22}{7}-3>\frac {p-3q}q>-\frac{22}{7}-3+2\pi$$
$$\frac{1}{7}>\frac {p-3q}q>\frac{14\pi-43}{7}$$
$$7<\frac q{p-3q}<\frac{7}{14\pi-43}$$
$$0<\frac {22q-7p}{p-3q}<\frac{308-98\pi}{14\pi-43}$$
$$\frac {p-3q}{22q-7p}>\frac{14\pi-43}{308-98\pi}>7$$
Then, in order not to re-arrange terms by hand, I fed the latter inequality to wolframalpha, obtaining
$$(50 p - 157 q) (7 p - 22 q)<0$$
$$\frac{157}{50}<\frac{p}{q}<\frac{22}{7}\tag{1}$$
and along with this one more thing, with Reduce[(p - 3 q)/(-7 p + 22 q) > 7, {p, q}, Integers]:
$$p = 157 n_1 + 22 n_2 + 179,\, q = 50 n_1 + 7 n_2 + 57,\, n_1, n_2 \in \mathbb{Z}_{+}\tag{2}$$
which solves the original problem (as $q\ge 57$).
However, I do not know any explanation on how is it derived, I'm feeling that I'm missing something well-known. The first idea I can think of is like we solve $$0<\frac{p}{q}-\frac{157}{50}<\frac{22}{7}-\frac{157}{50}$$ $$0<\frac{50p-157q}{50q}<\frac{1}{350}$$ $$0<7(50p-157q)<q$$ ... we solve Diophantine equation $7(50p-157q)=k$ for every $0<k<q$, but it doesn't seem to produce such a neat result. So the question is: how does (1)$\Rightarrow$(2)? References where I can read a more general case may be even better (if available for free).
Thanks.
It is true that, for any positive integers $u,v$ $$ \frac{157}{50} < \frac{157u + 22v}{50u + 7v} < \frac{22}{7} $$ However, take $u,v$ fairly large, you can alter the numerator a little bit (say by $\pm 1$) and still have that inequality