What is $\lim_{n \to \infty} \left(\tfrac12 + \tfrac12\cos(\pi \, n! \, x)\right)^n$? Evaluate this function
$$ f(x) = \lim_{n \to \infty} \left(\tfrac12 + \tfrac12\cos(\pi \, n! \, x)\right)^n $$
for every $x \in \mathbb{R}$.
It's not (present day) homework.  I'm too old for that.
 A: ${\bf Theorem:}\text{ For any $a \in [0,1]$ there exists $x$ such that $f(x) = a$.}$
Proof: As other users have shown, if $x \in \mathbb{Q}$, then $f(x) = 1$. Find $x$ such that the limit is $0$ is pretty straightforward (I expect this is the case for almost all $x$ but I'm not sure how that could be proven). Now suppose $0< a < 1$. Let $(x_n) \in \mathbb{Z}$ be a sequence such that $\lim\limits_{n\rightarrow\infty}\frac{x_n}{\sqrt{n}} = \frac{\sqrt{2}}{\pi}\sqrt{\log\frac{1}{\sqrt{a}}}$. Then, we claim
$$
f\left(2\sum_{k=0}^\infty \frac{x_k}{k!}\right) = a
$$
Observe that by the half angle formula,
$$
f(x) = \lim_{n\rightarrow\infty} \left(\cos(n!\pi x /2)\right)^{2n}
$$
We also note that as $t$ approaches $0$, we have asymptotically $\cos(n\pi + t)^2 \sim (1 - \frac12t^2)^2$. Now:
$$
f\left(2\sum_{k=0}^\infty \frac{x_k}{k!}\right) = \lim_{n\rightarrow\infty} \cos\left(n! \pi \sum_{k=0}^\infty \frac{x_k}{k!}\right)^{2n} = \lim_{n\rightarrow\infty} \cos\left(\pi \sum_{k=n+1}^\infty \frac{n! x_k}{k!}\right)^{2n}
$$
since the first $n$ terms of the series are integer multiples of $\pi$. Then, we have:
$$
f\left(2\sum_{k=0}^\infty \frac{x_k}{k!}\right) =\lim_{n\rightarrow\infty} \cos\left(\pi \sum_{k=n+1}^\infty \frac{n! x_k}{k!}\right)^{2n} =  \lim_{n\rightarrow\infty} \left(1 -  \left(\pi \sum_{k=n+1}^\infty \frac{n! x_k}{k!}\right)^2\right)^{2n} = \lim_{n\rightarrow\infty} \left(1 -  \frac{1}{2}\left(\frac{\pi x_{n+1}}{n+1}\right)^2\right)^{2n} = \lim_{n\rightarrow\infty} \left(1 -  \frac12\left(\frac{\pi \sqrt{n+1} \frac{\sqrt{2}}{\pi}\sqrt{\log\frac{1}{\sqrt{a}}}}{n+1}\right)^2\right)^{2n} = \lim_{n\rightarrow\infty} \left(1 -  \frac{\log{\frac1{\sqrt{a}}}}{n+1}\right)^{2n} = \left(\lim_{n\rightarrow\infty} \left(1 + \frac{\log{\sqrt{a}}}{n+1}\right)^{n}\right)^2 = \left(\exp(\log\sqrt{a})\right)^2 = a
$$
(We can ignore all other terms of the series because they go to $0$ significantly faster than the first.)
This shows that $x = 2\sum_{k=0}^\infty \frac{x_k}{k!}$ indeed satisfies $f(x) =a$.
A mildly interesting fact is that since this proof only depends on the asymptotic behavior of the sequence $x_n$, the set of points $x$ such that $f(x) = a$ will actually be dense in $\mathbb{R}$.
A: $f(x) = \lim_{n \to \infty} \left(\tfrac12 + \tfrac12\cos(\pi \, n! \, x)\right)^n
$
If $x$ is rational,
$n!x$ will be an even integer
for large enough $n$
so
$\cos(\pi \, n! \, x)
=1$
and the result is $1$.
If $x$ is not rational,
it depends on
how close
$n!x$ is to an even integer.
If it is often not close,
then the limit for
those such $n$
is zero.
My guess is that
the limit does not exist
for irrational $x$,
but I don't know how
to prove it.
It may be related to work
on equidistributed sequences.
