I am stuck on the derivation of the series expansion of the cosine integral during my attempt to derive the Kummer series representation from scratch.
The cosine integral is defined as $$ \rm Ci \left(x\right) = \int^x_\infty\frac{\cos t}{t}dt $$
On Wolfam Alpha, it is written without proof that
$$ \rm Ci\left( x\right) = \gamma + \ln x - \int^x_0\frac{1-\cos t}{t}dt = \gamma + \ln x - \sum^\infty_{n=1}\frac{(-1)^{n+1}x^{2n}}{(2n)(2n)!} $$
And I want to know how to derive this.
Details
The Kummer series is the Fourier expansion of $\ln{\Gamma\left(x\right)}$, which is totally monstrous as we might expect: $$ \ln{\Gamma \left(x\right)} = \left(1-x\right)\ln{\left(2\pi\right)} + \gamma\left(\frac{1}{2}-x\right) -\frac{1}{2}\ln{\left( 2\sin{\pi x} \right)} + \frac{1}{\pi}\sum^\infty_{n=1} \frac{\ln{n}}{n}\sin{\left(2\pi x\right)} $$
However, the derivation (much to my surprise) follows straight from the definition of the Fourier expansion, though I cannot find a complete derivation that does not take various series expansions for granted. Consider $x\in\left[0,1\right]$, with half period $P=1$, we can derive the coefficients as follows: $$ a_n = 2\int^1_0\ln\Gamma\left(x\right) \cos\left(2\pi nx\right) dx $$ $$ b_n = 2\int^1_0\ln\Gamma\left(x\right) \sin\left(2\pi nx\right) dx $$
My problem arises during the part where I derive $b_n$. I use the Weierstrass product definition of $\Gamma\left( x\right)$ (as detailed here), take $\ln$ on both sides, and get:
$$ \ln\Gamma\left(x\right)\sin\left(2\pi nx\right) = -\left(\gamma x + \ln x\right)\sin\left(2\pi nx\right)+ \sum^\infty_{k=1}\left[\frac{x}{k}-\ln\left(1+\frac{x}{k}\right)\right]\sin\left(2\pi nx\right) $$
Integrating the first part on $\left[0,1\right]$, I end up with
$$ \mathcal{I} = \frac{\gamma - \rm Ci\left(2\pi n\right)}{2\pi n} - \lim_{x\to 0} \left[ \frac{\ln x- \rm Ci\left(2\pi nx\right)}{2\pi n}\right] $$
With the intent of getting
$$ \mathcal{I} = \frac{2\gamma + \ln{\left( 2\pi n\right)} - \rm Ci\left(2\pi n\right)}{2\pi n} $$
I've seen this post, and is able to derive $$ \int^x_0\frac{1-\cos t}{t}dt = \sum^\infty_{n=1}\frac{(-1)^{n+1}x^{2n}}{(2n)(2n)!} $$ But I am still not sure how to proceed from there.