What's the Fourier Series for ln(x)?

I'm trying to see what the Fourier Series for ln(x) on $[0,\pi]$.

I plugged all of the formulas in for the coefficients into Wolfram Alpha and got this: $$\ln(x)=\frac{\pi \ln(\pi)}{\pi}-\frac{2}{\pi}\sum_{n=1}^{\infty}\frac{\sin(nx)(\gamma - \operatorname{Ci(n\pi)}+\ln(n) +\cos(n\pi)\ln(n))}{n}+\frac{2}{\pi}\sum_{n=1}^\infty\frac{\cos(nx)( \ln(n)\sin(n\pi)-\operatorname{Si(n\pi)))}}{n}$$

Is this correct? I find it odd that the Euler-Mascheroni constant appeared which leads me to believe it's incorrect. If it's incorrect, would someone give a hint for a set up that could help? Thanks!

• It's sort of natural for $\gamma$ to appear here, since there is (after all) a logarithm. For comparison and motivation, note that $$\int_0^{\infty} e^{-x} \ln x \, dx = -\gamma$$ and recall that $\cos$ and $\sin$ are the real and imaginary parts of $e^z$. – user296602 Mar 2 '18 at 21:24
• Oh, that makes sense @user296602 – Tom Himler Mar 2 '18 at 22:26

The series is correct. The coefficient of $\cos(nx)$ comes from $\int \cos(nx) \log(x)\,dx$, which, when integrated by parts, becomes $$\int \frac{\sin(nx)}{x}\,dx$$ up to a constant. This is where the sine integral $\operatorname{Si}(n\pi)$ comes from in the formula for the cosine coefficient.
The sine coefficients are a bit more complicated, because $\cos(nx)/x$ is not integrable on $[0, \pi]$. One has to offset the value at $0$ to get a convergent integral: $$\int \frac{1-\cos(nx)}{x}\,dx$$
But the cosine integral is still defined via $\cos(x)/x$ and not $(1-\cos(x))/x$. Specifically, $${\displaystyle \operatorname {Ci} (x)=-\int _{x}^{\infty }{\frac {\cos t}{t}}\,dt=\gamma +\ln x+\int _{0}^{x}{\frac {\cos t-1}{t}}\,dt }$$
Hence the presence of $\gamma$ and $\log$. One may say $\gamma$ is not really present in this Fourier series, it appears only to cancel out the $\gamma$ that's hidden inside of $\operatorname{Ci}(n\pi)$. If we defined the integral cosine by integrating $(1-\cos x)/x$, there would be no $\gamma$ there.