What is the motivation behind the steps in this 'simple' proof that $\pi$ is irrational? In $1947$, Ivan Niven published A Simple Proof that $\pi$ is irrational, which only requires knowledge of elementary calculus to understand. Since then, many variations of this proof have been published, one of which I will briefly outline here:

*

*Assume, for the sake of contradiction, that $\pi$ can be expressed in the form $a/b$, where $a$ and $b$ are integers.

*Let $f$ be the polynomial function defined by
$$
f(x)=\frac{x^n(a-bx)^n}{n!} \, ,
$$
where $n$ is a positive integer.

*Consider the integral $I=\int_{0}^{\pi} f(x)\sin x \, dx$. Since $f$ and $\sin$ are positive on the interval $(0,\pi)$, we have $0<I$. Moreover, if $n$ is large enough, then $I<1$. This is because
$$
f(x)\sin x =\frac{x^n(a-bx)^n}{n!}\sin x<\frac{x^n\pi^n}{n!}
$$
and $$\int_{0}^{\pi}\frac{x^n\pi^n}{n!} \, dx <1$$ for sufficiently large $n$.

*On the other hand, integration by parts tells us that
\begin{align}
\int f(x) \sin x \, dx = &-f(x)\cos x +f'(x)\sin x + f''(x) \cos x - f'''(x)\sin x \\ &-f''''(x)\cos x +\ldots\pm f^{(2n)}(x)\cos x
\end{align}
Every function $f^{(k)}$ (with $0 \leq k\leq 2n$) takes integer values when $x=0$ and $x=\pi$. The same is true for $\sin$ and $\cos$. Hence, $I$ must be an integer. But earlier we showed that if $n$ is sufficiently large, $0<I<1$, thereby reaching a contradiction. $\blacksquare$
Although the steps in the proof are not too difficult to follow, it still leaves me scratching my head thinking why on earth someone would try to prove $\pi$ is irrational by defining a bizzarre-looking function and then proceeding to integrate it. The proof seems entirely unmotivated. Is there any insight into how someone could have thought of such a proof? Is there something about the function $f$ and the trigonometric functions that provide us with information about the irrationality of $\pi$?
 A: We can reason as follows.
If we want to force a contradiction from $\pi=a/b$, we need to exploit the one thing we know about $\pi$: that certain functions have a period proportional to $\pi$, and nice values at certain rational multiples of it. Let's try working with the sine function for example, which is $0$ at multiples of $\pi$, even though its period is $2\pi$.
Its half-period from $0$ to $\pi$ tells the whole story, thanks to $\sin x$ being odd. And on this half-period, $\sin x$ looks a bit like a parabola, so one obvious approximation of it is a multiple of$$x(\pi-x)=x(a/b-x)=x(a-bx)/b.$$Of course, $x(a-bx)$ is upper-bounded by e.g. completing the square.
Now it's only natural to see which functions of the form $f(x(a-bx))\sin x$ we can integrate from $0$ to $\pi$, presumably using integration by parts if $f$ is a polynomial. If the integrand is non-negative in our choice of integration range, the integral is at least $0$. And if $f(y)$ is proportional to some power of $y$, we even get an upper bound on the integral.
You can almost tell without calculation that $\int_0^\pi x^n(a-bx)^n\sin xdx$ will be an integer. A special integer? I hope so. Integers are funny things, you see. Two different real numbers' difference can be arbitrarily small, but when integers differ, they differ by at least $1$. So $\int_0^\pi x^n(a-bx)^n\sin xdx\ge1$, which is a much more interesting lower bound. If we could just show the LHS gets arbitrarily small with large $n$, we'd be done. The rest is just trying IBP to see what happens.
But now, a bit of bad news: our upper bound on $x^n(a-bx)^n$ is $(\pi/2)^{2n}$, which grows exponentially. Now, luckily $\sin x$ is bound, but that's not much consolation. It's looking less likely the integral will shrink enough as $n$ grows to finish the argument.
Then again, polynomials getting differentiated many times for repeated IBP introduces potentially rather large combinatorial factors. If we want to get rid of all the polynomial factors so we know how to finish the integration with e.g. $\int\sin xdx=-\cos x+C$, we might even get superexponential factors, like $n!$. That's cool, because if some positive integer $k(n)$ divides $\int_0^\pi x^n(a-bx)^n\sin xdx$, that integral will have lower bound $k(n)$. So if $k$ grows superexponentially, our original strategy is basically saved.
And then Niven or Bourbaki (not a real person, by the way) or anyone tries it out, and polishes the finding into a proof, rather than the above thinking-out-loud.
