On wolfram alpha, I searched for the series expansion of the integral
$$\int \frac{\cos(2x) - \cos(x)}{x} \mathrm dx$$
(https://www.wolframalpha.com/input/?i=series+of+int+(cos(+2x)+-+cos(x))%2Fx+dx)
I am confused at the $\log(2)$ term in the series expansion at $x = 0$. I understand all the other terms come from integrating the expansion of $\frac{\cos(2x) - \cos(x)}{x}$. Where did $\log(2)$ come from? How was it evaluated? And how was the expansion at $ x = \infty$ evaluated?
Recall that
$$\cos(x)=\sum_{n=0}^\infty\frac{(-1)^n}{(2n)!}x^{2n}$$
Thus,
$$\cos(2x)=\sum_{n=0}^\infty\frac{(-1)^n4^n}{(2n)!}x^{2n}$$
And subtracting these two:
$$\cos(2x)-\cos(x)=\sum_{n=0}^\infty\frac{(-1)^n(4^n-1)}{(2n)!}x^{2n}$$
Then divide by $x$:
$$\frac{\cos(2x)-\cos(x)}x=\sum_{n=0}^\infty\frac{(-1)^n(4^n-1)}{(2n)!}x^{2n-1}$$
Integrate term by term:
$$\int\frac{\cos(2x)-\cos(x)}x\ dx=\sum_{n=0}^\infty\frac{(-1)^n(4^n-1)}{(2n)!(2n)}x^{2n}$$
But wait! Constant of integration!
$$\int\frac{\cos(2x)-\cos(x)}x\ dx=\color{red}{c}+\sum_{n=0}^\infty\frac{(-1)^n(4^n-1)}{(2n)!(2n)}x^{2n}$$
That's where the $\log(2)$ came from, though I'm not sure why WolframAlpha chose $\log(2)$ in particular... actually, here's where it came from:
$$\int\frac{\cos(2x)-\cos(x)}x\ dx=c+\int_x^\infty\frac{\cos(2t)-\cos(t)}t\ dt=c+\operatorname{Ci}(2x)-\operatorname{Ci}(x)$$
where $\operatorname{Ci}$ is the cosine integral. And by setting $x=c=0$, we get
$$\int_0^\infty\frac{\cos(2t)-\cos(t)}t\ dt=\log(2)$$
which is where the $\log(2)$ came from.
The expansion at infinity may likewise be done by setting $x=1/t$.
$$\operatorname{Ci}\left(\frac2t\right)-\operatorname{Ci}\left(\frac1t\right)$$
And Taylor expanding at $t=0$ (much harder to do, also not sure how Wolfram did this step exactly)