Is $22/7$ the closest to $\pi$, among fractions of denominator at most $50$?
I am currently studying continued fractions, while I know that for all denominators at most $Q_n$, $\frac{P_n}{Q_n}$ is the closed approximation. But what about the denominators between $Q_n$ and $Q_{n+1}$?
First we check with a simple script, is it even true. Now
Recall how we make a continous fraction: subtract the integer part, flip the fraction (or take $1/x$ for irrational $x$), repeat. By performing these steps on the supposed to be not true $\left|\pi-\frac{p}{q}\right|<\frac{22}{7}-\pi$ we may yield a contradiction.
There is no better approximation with $0<q\le 50$. Suppose there is, $\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}\approx{7.9268}>7\Rightarrow$$ $$\frac {p-3q}{22q-7p}>7$$ $$\left(\frac{p}{q} - \frac{157}{50}\right) \left(\frac{p}{q} - \frac{22}{7}\right)<0$$ $$\frac{157}{50}<\frac{p}{q}<\frac{22}{7}$$ But $\frac{157}{50},\,\frac{22}{7}$ are neighbours in the Farey sequence of order $50$ ($157\cdot 7-50\cdot 22=-1$) which implies no such $\frac{p}{q}$ with $q\le 50$ exists, QED.
Btw, the lowest denominator $\frac{p}{q}$ such that $\frac{157}{50}<\frac{p}{q}<\frac{22}{7}$ is the mediant of $\frac{157}{50}$ and $\frac{22}{7}$: $\ \frac{157+22}{50+7}= \frac{179}{57}$.