Computing an infinite limit involving a double integral 
$$\lim_{T\to \infty}\frac{\int_0^T\cos^2(s) \exp(-s)\int_0^s \cos(\cos a)\exp(a)\,\mathrm{d}a\,\mathrm{d}s}{T}$$

I tried computing this limit in maple but got the answer: 'undefined'.
How to compute this limit, I accept special functions.
 A: Here is some partial solution:
We want to check if the numerator goes to infinity first, so we can apply l'Hospital. We have $-1\le\cos a\le1$, and $-\pi/2<-1<1<\pi/2$. We also know that the cosine function is positive in the above interval. You can therefore show that $$\cos(1)\le \cos(\cos s)\le 1$$
The value for $\cos(1)$ is about $0.54$. Then we have $$\int_0^s\cos(1)e^a da\le \int_0^s\cos(\cos a)e^a da\le\int_0^se^a da$$or $$\cos(1)(e^s-1)\le\int_0^s\cos(\cos a)e^a da\le e^s-1$$ 
The integral $\int_0^T\cos^se^{-s}ds$ is finite, so in the limit when $T\rightarrow\infty$ the ratio of a constant divided by $T$ goes to zero. What we have is that $$\lim_{T\rightarrow \infty}\cos(1)\frac{\int_0^T\cos^2(s )ds}{T}\le \lim_{T\rightarrow \infty}\frac{\int_0^T\cos^2(s)e^{-s}\int_0^s\cos(\cos a)e^a da ds}{T}\le\lim_{T\rightarrow\infty}\frac{\int_0^T\cos^2(s )ds}{T}$$
You can compute now the integral, to get that $$\int_0^T\cos^2(s )ds=\frac{T}{2}+\frac{\sin 2T}{4}$$
You can therefore apply l'Hospitals rule.You have $\frac{d}{dx}\int_0^xf(t)dt=f(x)$, so:
$$\lim_{T\rightarrow \infty}\frac{\int_0^T\cos^2(s)e^{-s}\int_0^s\cos(\cos a)e^a da ds}{T}=\lim_{T\rightarrow \infty}\cos^2(T)e^{-T}\int_0^T\cos(\cos a)e^a da$$
You can rewrite the last limit as
$$\lim_{T\rightarrow \infty}\frac{\int_0^T\cos(\cos a)e^a da}{\frac{e^{T}}{\cos^2(T)}}$$
If you apply l'Hospital again, I get that the limit does not exist.
A: The limit exists and is finite with the value
$$\lim_{T\to\infty} J(T)/T = \frac{1}{2\pi} \int_0^\pi\cos(\cos(x))dx = 0.38259884...$$
Here,
$$J(T):=\int_0^T \, ds \cos^2(s)e^{-s}\int_0^s \, dx \cos(\cos(x))e^x. $$
The proof consists of an integration by parts to get a 'nice' expression, then bounding all the terms except for one remaining, and dealing with it specially.
The integration by parts shows that
$$ J(T) = \Big( \int_0^T  \, dx \cos(\cos(x))e^x \Big)\Big(\frac{-1}{10}e^{-T}
\big(5+\cos(2T)-2\sin(2T)\big) \Big)+$$
$$+\frac{1}{10}\int_0^T e^{-s}\big(5+\cos(2s)-2\sin(2s)\big)\cos(\cos(s))e^s ds .$$
Let's deal with the first line of the previous question; call it $J_1.$ The second line is $J_2.$
$$J_1 =  \int_0^T  \, dx f(x,T)e^{x-T} \, , \,  f(x,T)=\frac{-1}{10}\cos(\cos(x))\big(5+\cos(2T)-2\sin(2T)\big).$$ It's easy to see that $|f(x,T)|<1$ and thus $|J_1|<1-e^{-T}.$  In dividing by $T$ and taking the limit, it is obvious that $|J_1|/T \to 0.$  Note that in $J_2$ I've written it as would come out of an integration by parts but the important thing is that the exponential growth and decay within the integrand cancel.  Furthermore define
$$J_2^a:= \int_0^T dx\cos(\cos(x)) \, , \,  J_2^b:= \int_0^T dx \, \cos(2x)\cos(\cos(x))$$
$$J_2^c:= \int_0^T dx \, \sin(2x)\cos(\cos(x))
= 2 \int_0^T dx \,\cos(x) \sin(x)\cos(\cos(x)).$$
$J_2^c$ is easily explicitly integrated and can be bounded by a constant.  Thus $J_2^c/T \to 0$ as $T \to \infty.$  For $J_2^b,$
$$\frac{J_2^b}{T} = \int_0^1 dx \, \cos(2x\,T)\cos(\cos(x \,T)) \to 0$$
by the Riemann-Lebesgue lemma. For $J_2^a$ notice that the integrand is periodic of period $\pi.$  Assume $T=n\,\pi + b$ with $0<b<\pi.$  All continuous $T$ is covered because of the extra $b,$ even as we let $n \to \infty$ through discrete values.
$$\frac{J_2^b}{T}=\frac{1}{n\pi+b} \Big( \int_0^\pi(*) +\int_\pi^{2\pi}(*) 
+ ...\int_{(n-1)\pi}^{n\pi}(*) +  \int_{n\pi}^{n\pi+b}(*) \Big)$$
where the (*) stands for the integrand which is not shown for it obscures the argument I'm making.  There are $n$ identical integrals by periodicty so
$$\frac{J_2^b}{T}=\frac{1}{n\pi+b}\Big( n\, \int_0^\pi dx\cos(\cos(x)) + C\Big).$$
The iterated cosine can be bounded by 1 so $|C|<\pi,$ no matter what the value of $b$ is.  On letting $n \to \infty$ and picking up the factor of 1/2 from the definition of $J_2,$ we get the first formula for this answer. As a numerical check I let T=1000 and used lots of precision to get a brute force evaluation of the J(1000)/1000 = 0.371.
