$\newcommand{\bbx}[1]{\,\bbox[8px,border:1px groove navy]{{#1}}\,}
\newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
\newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
\newcommand{\dd}{\mathrm{d}}
\newcommand{\ds}[1]{\displaystyle{#1}}
\newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
\newcommand{\ic}{\mathrm{i}}
\newcommand{\mc}[1]{\mathcal{#1}}
\newcommand{\mrm}[1]{\mathrm{#1}}
\newcommand{\pars}[1]{\left(\,{#1}\,\right)}
\newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
\newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
\newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
\newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
&\int_{0}^{\infty}{x\cos\pars{x} - \sin\pars{x} \over x^{3}}\,
\cos\pars{x \over 2}\,\dd x \\[5mm] = &
\int_{0}^{\infty}{x\bracks{1 - 2\sin^{2}\pars{x/2}} - \sin\pars{x} \over x^{3}}\,\cos\pars{x \over 2}\,\dd x
\\[5mm] & =
{1 \over 2}\int_{0}^{\infty}{2x\cos\pars{x/2} - 2x\sin\pars{x}\sin\pars{x/2} -
2\sin\pars{x}\cos\pars{x/2} \over x^{3}}\,\,\,\dd x
\\[5mm] & =
{1 \over 2}\int_{0}^{\infty}{x\cos\pars{x/2} + x\cos\pars{3x/2} -
\sin\pars{3x/2} - \sin\pars{x/2} \over x^{3}}\,\,\,\dd x
\\[1cm] & =
-\,{1 \over 2}\int_{0}^{\infty}{1 - \cos\pars{x/2} \over x^{2}}\,\dd x -
{1 \over 2}\int_{0}^{\infty}{1 - \cos\pars{3x/2} \over x^{2}}\,\dd x
\\[5mm] & -
{1 \over 4}\int_{x\ =\ 0}^{x\ \to\ \infty}\bracks{2x - \sin\pars{3x/2} - \sin\pars{x/2}}\,\dd\pars{1 \over x^{2}}
\end{align}
Integrating by parts the last integral:
\begin{align}
&\int_{0}^{\infty}{x\cos\pars{x} - \sin\pars{x} \over x^{3}}\,
\cos\pars{x \over 2}\,\dd x =
\\[5mm] & =
-\,{1 \over 2}\int_{0}^{\infty}{1 - \cos\pars{x/2} \over x^{2}}\,\dd x -
{1 \over 2}\int_{0}^{\infty}{1 - \cos\pars{3x/2} \over x^{2}}\,\dd x
\\[5mm] & +
{1 \over 4}\int_{x = 0}^{\infty}{2 - 3\cos\pars{3x/2}/2 - \cos\pars{x/2}/2 \over x^{2}}\,\dd x
\\[1cm] & =
-\,{1 \over 2}\int_{0}^{\infty}{1 - \cos\pars{x/2} \over x^{2}}\,\dd x -
{1 \over 2}\int_{0}^{\infty}{1 - \cos\pars{3x/2} \over x^{2}}\,\dd x
\\[5mm] & +
{3 \over 8}\int_{0}^{\infty}{1 - \cos\pars{3x/2} \over x^{2}}\,\dd x +
{1 \over 8}\int_{0}^{\infty}{1 - \cos\pars{x/2} \over x^{2}}\,\dd x
\\[1cm] & =
-\,{3 \over 8}\int_{0}^{\infty}{1 - \cos\pars{x/2} \over x^{2}}\,\dd x
-\,{1 \over 8}\int_{0}^{\infty}{1 - \cos\pars{3x/2} \over x^{2}}\,\dd x
\\[5mm] & =
-\,{3 \over 16}\int_{0}^{\infty}{1 - \cos\pars{x} \over x^{2}}\,\dd x
-\,{3 \over 16}\int_{0}^{\infty}{1 - \cos\pars{x} \over x^{2}}\,\dd x =
-\,{3 \over 8}\
\int_{0}^{\infty}{1 - \cos\pars{x} \over x^{2}}\,\dd x
\\[5mm] & =
-\,{3 \over 4}\int_{0}^{\infty}{\sin^{2}\pars{x/2} \over x^{2}}\,\dd x =
-\,{3 \over 8}\
\underbrace{\int_{0}^{\infty}{\sin^{2}\pars{x} \over x^{2}}\,\dd x}
_{\ds{=\ {\pi \over 2}}}\ = \
\bbox[#ffe,10px,border:1px dotted navy]{\ds{-\,{3 \over 16}\,\pi}}
\end{align}
>By integrating by parts:
$\ds{\int_{0}^{\infty}{\sin^{2}\pars{x} \over x^{2}}\,\dd x =
\int_{0}^{\infty}{\sin\pars{x} \over x}\,\dd x = {1 \over 2}\,\pi}$.
Note that the mesh spacing is not uniform. The length of the $i$'th subinterval is $x_i-x_{i-1}=2^{i/n}-2^{(i-1)/n}$.
Then, we can write
$$\begin{align}
L(f,P_n)&=\sum_{i=1}^n \frac{1}{x_{i-1}}(x_i-x_{i-1})\\\\
&=\sum_{i=1}^n \left(\frac{1}{2^{(i-1)/n}}\right)\left(2^{i/n}-2^{(i-1)/n}\right)\\\\
&=\sum_{i=1}^n\left(2^{1/n}-1\right)\\\\
&=n\left(2^{1/n}-1\right)\\\\
&=n\left(e^{\frac1n\log(2)}-1\right)\\\\
&=\log(2)+O\left(\frac1n\right)\tag 1
\end{align}$$
and
$$\begin{align}
U(f,P_n)&=\sum_{i=1}^n \frac{1}{x_{i}}(x_i-x_{i-1})\\\\
&=\sum_{i=1}^n \left(\frac{1}{2^{i/n}}\right)\left(2^{i/n}-2^{(i-1)/n}\right)\\\\
&=\sum_{i=1}^n\left(2^{1/n}-1\right)\\\\
&=n\left(1-2^{-1/n}\right)\\\\
&=n\left(1-e^{-\frac1n\log(2)}\right)\\\\
&=\log(2)+O\left(\frac1n\right)\tag 2
\end{align}$$
Taking the limit as $n\to \infty$ of $(1)$ and $(2)$, we find
$$\bbox[5px,border:2px solid #C0A000]{\lim_{n\to \infty}L(f,P_n)=\lim_{n\to \infty}U(f,P_n)=\log(2)}$$
as was to be shown!
Best Answer
I don't think you need to specialize to $a=k \pi$. Rather, there is a simple, analytical expression for the sum of the cosine series.
Write
$$\sum_{k=1}^n \cos{\left(\frac{k a}{n}\right)} = \Re{\left[\sum_{k=1}^n e^{i k a/n}\right ]} $$
The sum on the right is a simple geometrical series:
$$\sum_{k=1}^n e^{i k a/n} = \frac{e^{i a}-1}{1-e^{-i a/n}} = e^{i a (1+(1/n))/2} \frac{\sin{(a/2)}}{\sin{(a/(2n))}}$$
Taking the real part of the sum, I get
$$\frac{a}{n} \sum_{k=1}^n \cos{\left(\frac{k a}{n}\right)} = \frac{a\sin{(a/2)}}{n \sin{(a/(2 n))}} \cos{\left[\frac{a}{2}\left ( 1+\frac{1}{n}\right)\right]}$$
To evaluate the integral, take the limit as $n \to \infty$ and note that, in this limit, $n \sin{(a/(2 n))} \approx a/2$. Then
$$\int_0^a dx \, \cos{x} = a \frac{\sin{(a/2)}}{a/2} \cos{(a/2)} = \sin{a}$$