Why do non-constant periodic functions have no limit at infinity?

Why do periodic functions (like $\cos$ or $\sin$ or $\tan$) have no limit at infinity?

I can guess that it is because their values don't converge but repeat over and over, but I would like to know what is the formal analytical (that is with $\epsilon$'s and $\delta$'s) proof of the statement.


The reasoning is quite simple: take any periodic function $f$ such that $\forall x\ \ \ f(x+T)=f(x)$ and such that $f$ takes at least two different values (i.e. $f$ is not constant). Two two such values $a$ and $b$.

Now suppose that $f$ has a limit $l$ for $x\to\infty$. Take $\varepsilon = |a-b|/4$, then there exists $R$ such that $$\forall x>R \quad |f(x)-l|<\varepsilon=|a-b|/4.$$

But there exists $y_a$ such that $f(y_a)=a$ and $y_b$ such that $f(y_b)=b$, together with condition $y_a>R$ and $y_b>R$ (that's because $f$ is periodic). Put these values into the formula above and obtain a contradiction.

Edit

Why such $y_a$ and $y_b$ exist? We chose $a$ and $b$ to be the values of $f$, hence there exist $x_a\in \Bbb R$ such that $f(x_a)=a$. Now by periodicity you obtain that $$\forall n\in \Bbb Z\quad f(x_a+nT) = f(x_a)=a,$$ therefore if we chose $\Bbb N\ni m>\frac{R-x_a}{T}$, we obtain that $y_a=x_a+mT>R$ and $f(y_a)=a$. Similarly we can show the existence of $y_b$.


Any periodic function $f:\mathbb R\rightarrow \mathbb R$ that assumes more than one value can have no limit at $\pm \infty$.

Indeed, suppose the limit at $+\infty$ is the real number $L$ (the proof is similar for $-\infty$, so I omit it here). This means that we may make $|f(x)-L|$ as small as desired by taking $x$ sufficiently large.

Now this is already problematic. Since $f$ assumes two distinct values $a$ and $b$, and $f$ is periodic, there are arbitrarily large values of $x$ for which $f(x)=a$, and there are arbitrarily large values of $x$ for which $f(x)=b$, yet $f(x)$ must be bounded away from at least one of $a$ or $b$ (both, in fact, if $L$ is not one of them) for sufficiently large $x$.

The essential idea is that as $x$ increases to $+\infty$, $f(x)$ must visit $a$ and $b$ over and over, but the existence of the limit requires that $f(x)$ must eventually stay close to $L$. The only way all of this can happen is if $a=b=L$ and $f$ is constant.