upper limit of $\cos (x^2)-\cos (x+1)^2$ is $2$ How to prove that upper limit of $\cos (x^2)-\cos (x+1)^2$ is $2$. 
Can anyone show proof of this?
 A: This problem appeared in the recent past, and I answered it, but I can't find it now. It goes like this: Let $x_n = \sqrt {2\pi n}.$ Then
$$\cos x_n^2 - \cos (x_n+1)^2 =  1 - \cos (2\sqrt {2\pi n} + 1).$$
Now $\cos (2\sqrt {2\pi n} + 1)$ is dense in $[-1,1].$* It follows that the desired upper limit is $2.$
*Suppose $a_1 < a_ 2 <\cdots \to \infty$ and $a_{n+1}-a_n \to 0.$ Then $e^{ia_n}$ is dense in the unit circle. Proof: This is because this sequence of points orbits the unit circle infinitely many times (because $a_n \to \infty$), in steps of arc length $a_{n+1}-a_n \to 0.$ It follows that for any fixed arc $A$ of positive length,  $e^{ia_n}$ lands in $A$ infinitely many times: You can't step over $A$ if your steps have arc length less than the length of $A.$ This gives the desired density.
Now check that $a_n = 2\sqrt {2\pi n} + 1$ satisfies the above. This implies $\cos a_n$ is dense in $[-1,1].$

I found my previous answer to this question: How to compute $\limsup$ and $\liminf ,\;$ as $x\to+\infty,\;$ of $\;\sin(x^2+x+1/2)\sin(x+1/2)$?
A: Well, $\cos (\text{anything})$ is always between $1$ and $-1$.  So the largest value you could potentially get from an expression of the form
$$\cos(\text{something}) - \cos(\text{something else})$$
would be attained by making the first cosine $1$ and the second cosine $-1$, in which case the result would be $1 - (-1) = 2$.  So in any case, $2$ is an upper bound for the result.
So now the question is, can we actually attain that bound?  To do so we would need to have $x^2$ be an even multiple of $\pi$ (because those are the values that yield $\cos(x^2)=1$, and we would need $(x+1)^2$ be an odd multiple of $\pi$ (because those are the values that yield $\cos(x+1)^2 = -1$).
Unfortunately those two conditions cannot be simultaneously met.  If $x^2 = 2n \pi$ for some integer $n$, then $x = \sqrt{2n\pi}$, in which case $(x+1)^2 = (1 + \sqrt{2n\pi})^2=1 + 2n\pi + 2\sqrt{2n\pi}$, which is not an odd multiple of $\pi$.
This assumes that you are expressing your angles in radians.  If you are measuring angles in degrees, you need $x^2$ to be an even multiple of $180$, and $(x+1)^2$ to be an odd multiple of $180$.  I will leave it to you check whether that is possible, and if so, what the solution is.
A: Let's use the sum to product formula:
$$ \cos a + \cos b = \sin \tfrac{a+b}{2}\cos \tfrac{a-b}{2} $$
Hmm is that right?  I never remember the correct combinations of + and -  symbols. Let's see:
$$ \frac{1}{2} \left( e^{2\pi i \, \frac{a+b}{2}} - e^{-2\pi i \, \frac{a+b}{2}}\right) \times \frac{1}{2} \left( e^{2\pi i \, \frac{a-b}{2}} + e^{-2\pi i \, \frac{a-b}{2}}\right)$$
If I am lucky we re-group the terms and it comes out correct:
$$ \frac{1}{4} \left( e^{2\pi i \, a} + e^{-2\pi i \, a}\right) + 
   \frac{1}{4} \left( e^{2\pi i \, b} - e^{-2\pi i \, b}\right) 
$$
This is wrong... I have written $\frac{1}{2} \left(\cos a - \sin b \right)$, but you can imagine with the correct choice of signs we can get it to work. 
A quick look at SOS math gives:
$$ \boxed{ \cos a + \cos b = 2 \,\cos \frac{a+b}{2} \, \cos \frac{a-b}{2} } $$
even pros get it wrong :-)

Let's try to solve your problem now... Let $a = (x+1)^2$ and $b = x^2$.  Then:
$$ \cos (x+1)^2 - \cos x^2 = 2 \,\sin \left(x^2 + x + \frac{1}{2} \right) \, \sin \left( x + \frac{1}{2} \right) \leq 2$$
We know that $\boxed{\cos x \leq 1}$ always.  So our number is always less than $2$.  In fact, the $\limsup$ is $2$.  This boils down to solving for integers:
\begin{eqnarray*}
x + \frac{1}{2}&\approx& \frac{\pi}{2} + 2\pi n_1 \hspace{0.5in}\text{ with }n_1 \in \mathbb{Z}\\
x^2 + x + \frac{1}{2}&\approx& \frac{\pi}{2} + 2\pi n_2 \hspace{0.5in}\text{ with }n_2 \in \mathbb{Z}
\end{eqnarray*}
It may be surprising at first, how these questions about trigonometry turn into questions of diophantine approximation.  This system of equation is easy to solve let's substitute one equation into the other
$$ x^2 + \left(x + \frac{1}{2}\right)\approx 
x^2 + \left(\frac{\pi}{2} + 2\pi n_1 \right)\approx
\frac{\pi}{2} + 2\pi n_2  $$
This leads to $x \approx \sqrt{2\pi (n_2 - n_1)}= \sqrt{2\pi n_3}$ and yet $x \approx \left(\frac{\pi}{2} - \frac{1}{2} \right) + 2\pi n_1$ where we are looking mod $2\pi$.  
Remark I If I choose units correctly we can look mod $1$ and just igonore all the numbers before the decimal point looking only at the "cents"  $\pi = \color{red}{3}.14159 \mod 1 \equiv \color{green}{0}.14159$
Remark II Proving that $\sqrt{2\pi n}$ is equidistributed mod $1$ is clear since the numbers are getting closer and closer together
$$ \sqrt{n+1} - \sqrt{ n} \approx \frac{1}{\sqrt{n} + \sqrt{n+1}} \approx \frac{1}{2\sqrt{n}} $$
Using a computer we can plot this function and see that we have a chance at getting the numbers to be close:

Further analysis of the numbers appearing after the decimal point in $\sqrt{n}$ is extremely difficult.  Here, two Harvard professors duking it out over the gap distribution [1].
