# Compute the fourier coefficients, and series for $\log(\sin(x))$

I posted a similar question with a bad response, so I am retrying with hopes of better knowledge. The fourier series is in the form:

$$f(x) = \frac{a_0}{2} + \sum_{n=1}^{\infty} a_n\cos(nx) + \sum_{n=1}^{\infty} b_n\sin(nx)$$

Where:

$$a_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x)\cos(nx) dx$$ $$b_n = \frac{1}{\pi} \int_{-\pi}^{\pi} f(x)\sin(nx) dx$$

The problem is computing the coefficients. The goal of trying to derive the series is to solve:

$$\int_{0}^{\pi} \log(\sin(x)) dx$$

$\displaystyle a_n = \frac{1}{\pi} \int_{-\pi}^{\pi} \log(\sin(x))\cos(nx) dx$

Which is very difficult to compute.

What can be done?

The series representation is:

$$\log(\sin(x)) = -\log(2) - \sum_{n=1}^{\infty} \frac{\cos(2kx)}{k}$$

• Notice that $a_n$ is not so difficult to compute, if one performs a round of integration by parts, bringing the logarithm into a cotangent and the cosine into a sine. – Jack D'Aurizio Dec 16 '14 at 12:45
• The only slightly tricky part is to compute $a_0$, but there is a nice proof through Riemann sums. I will be glad to show it, as soon as I have enough time (quite busy at the moment). – Jack D'Aurizio Dec 16 '14 at 12:47
• @JackD'Aurizio, thank you for commenting. So this wont require finding the antiderivative of $\log(\sin(x))$? That is good. Again thank you Jack! – Amad27 Dec 16 '14 at 12:48
• @JackD'Aurizio, no problem, whenever you have time. I would like to see it. Thanks once again, I will be working on this, and post an update later. Glad to hear from you! =) – Amad27 Dec 16 '14 at 12:48
• exactly, integrating by parts we can just replace $\log\sin x$ with $\cot x$. After that, we just need Briggs' formulas to compute $a_k$ for $k\geq 1$. – Jack D'Aurizio Dec 16 '14 at 12:49

Ok, here I am. The goal is to compute the Fourier series of $g(x)=\log\sin x$ over $[0,\pi]$, or the Fourier series of $h(x)=\log\sin\frac{x}{2}$ over $[0,2\pi]$, or the Fourier series of $f(x)=\log\cos\frac{x}{2}$ over $[-\pi,\pi]$. Since $f(x)$ is an even function, we have to compute: $$a_n = \frac{1}{\pi}\int_{-\pi}^{+\pi}\cos(nx)\log\cos\frac{x}{2}\,dx = \frac{2}{\pi}\int_{0}^{\pi}\cos(nx)\log\cos\frac{x}{2}\,dx$$ for any $n\geq 1$ to be able to state: $$f(x) = \frac{1}{2\pi}\int_{-\pi}^{\pi}f(x)\,dx + \sum_{n\geq 1}a_n\cos(nx)=\frac{a_0}{2}+\sum_{n\geq 1}a_n\cos(nx).$$ for any $x\in(-\pi,\pi)$. Integration by parts gives: $$a_n = \frac{2}{\pi}\left(\frac{1}{n}\left.\sin(nx)\log\cos\frac{x}{2}\right|_{0}^{\pi}+\frac{1}{2n}\int_{0}^{\pi}\sin(nx)\tan\frac{x}{2}\,dx\right)$$ or just: $$a_n = \frac{1}{\pi n}\int_{0}^{\pi}\frac{\sin(nx)\sin(x/2)}{\cos(x/2)}\,dx = \frac{2}{\pi n}\int_{0}^{\pi/2}\frac{\sin(2nx)\sin x}{\cos x}\,dx.$$ Since $\cos((2n+1)x)=2\cos x\cos(2nx)-\cos((2n-1)x)$, we have: $$a_n = \frac{1}{\pi n}\int_{0}^{\pi/2}\sum_{k=1}^{n}\cos((2k-1)x)\,dx =\frac{(-1)^{n+1}}{n}.$$ This gives: $$\log\cos\frac{x}{2}=\frac{a_0}{2}+\sum_{n\geq 1}\frac{(-1)^{n+1}}{n}\cos(nx)$$ for any $x\in(-\pi,\pi)$. In order to find $a_0$, we can simply match $f(0)=0$ with the series on the right hand side. Since: $$\sum_{n\geq 1}\frac{(-1)^{n+1}}{n}=\int_{0}^{1}\frac{dx}{1+x}=\log 2,$$ we have: $$\log\cos\frac{x}{2}=-\log 2+\sum_{n\geq 1}\frac{(-1)^{n+1}}{n}\cos(nx)\qquad\forall x\in(-\pi,\pi),\tag{1}$$ and by translating the variable: $$\log\sin\frac{x}{2}=-\log 2-\sum_{n\geq 1}\frac{1}{n}\cos(nx)\qquad\forall x\in(0,2\pi),\tag{2}$$ $$\log\sin x = -\log 2-\sum_{n\geq 1}\frac{1}{n}\cos(2nx)\qquad\forall x\in(0,\pi),\tag{3}$$ as wanted.

A little addendum, since I think it is worth mentioning the following technique. Starting with a celebrated identity: $$\prod_{k=1}^{n-1}\sin\frac{\pi k}{n}=\frac{2n}{2^n}$$ and noticing that $\log\sin x$ is a Riemann integrable function over $(0,\pi)$, we have: $$\int_{0}^{\pi}\log\sin x\,dx = \lim_{n\to +\infty}\frac{\pi}{n}\sum_{k=1}^{n-1}\log\sin\frac{\pi k}{n}=\lim_{n\to +\infty}\frac{\pi}{n}\log\frac{2n}{2^n}=\color{red}{-\pi\log 2}.$$

• Thank you Jack! This is absolutely fantastic. I am currently away from home, I have a few questions, which if you dont mind I will ask when I get back home. Thank you once again Jack, and I apologize for what I did previously. you are an amazing person! – Amad27 Dec 16 '14 at 17:41
• Hey, I lost it here $\cos((2n+1)x)=2\cos x\cos(2nx)-\cos((2n-1)x)$ would you care to explain how this is true? And how do you see that the integral is that series? – Pedro Fernandes Sep 8 at 21:10

Use equation $\text{(1d)}$ below and the fact that $$\int_0^\pi\cos(2kx)\,\mathrm{d}x=0$$ to get $$\int_0^\pi\log(\sin(x))\,\mathrm{d}x=-\pi\log(2)$$

\begin{align} \log(\sin(x)) &=\log\left(\frac{e^{ix}-e^{-ix}}{2i}\right)\tag{1a}\\ &=+ix-\log(2)-i\pi/2+\log(1-e^{-2ix})\tag{1b}\\ &=-ix-\log(2)+i\pi/2+\log(1-e^{+2ix})\tag{1c}\\ &=-\log(2)-\sum_{k=1}^\infty\frac{\cos(2kx)}{k}\tag{1d} \end{align} Explanation:
$\text{(1a)}$: $\sin(x)=\frac{e^{ix}-e^{-ix}}{2i}$
$\text{(1b)}$: bring $e^{+ix}$ and $+\frac1{2i}$ out of the log
$\text{(1c)}$: bring $e^{-ix}$ and $-\frac1{2i}$ out of the log
$\text{(1d)}$: use $\log(1-x)=-\sum\limits_{k=1}^\infty\frac{x^k}k$ while averaging $\text{(1b)}$ and $\text{(1c)}$

\begin{align} \log(\cos(x)) &=\log\left(\frac{e^{ix}+e^{-ix}}2\right)\tag{2a}\\ &=+ix-\log(2)+\log(1+e^{-2ix})\tag{2b}\\ &=-ix-\log(2)+\log(1+e^{+2ix})\tag{2c}\\ &=-\log(2)+\sum_{k=1}^\infty(-1)^{k-1}\frac{\cos(2kx)}{k}\tag{2d} \end{align} Explanation:
$\text{(2a)}$: $\cos(x)=\frac{e^{ix}+e^{-ix}}2$
$\text{(2b)}$: bring $e^{+ix}$ and $\frac12$ out of the log
$\text{(2c)}$: bring $e^{-ix}$ and $\frac12$ out of the log
$\text{(2d)}$: use $\log(1+x)=\sum\limits_{k=1}^\infty(-1)^{k-1}\frac{x^k}k$ while averaging $\text{(2b)}$ and $\text{(2c)}$

• I just ran across this answer in which I prove equation $\text{(1d)}$ in a different way. – robjohn Dec 19 '14 at 10:19
• Hi Rob. Happy Holidays. Whenever I see one write $\log (z_1z_2)=\log(z_1)+\log(z_2)$ without specifying the branches that are assumed, I begin to wonder if the analysis is sound. Of course, here one only needs to ensure that the branches of $\log(1-e^{\pm i2x})$ are chosen to make the right-hand sides purely real. What did you have in mind? – Mark Viola Dec 1 '18 at 3:07
• @MarkViola: I assumed the branch cut along the negative real axis and standard log along the positive real axis. For small $x$, things are within a narrow cone about the real axis and so there should be little problem using $\log(xy)=\log(x)+\log(y)$. – robjohn Dec 1 '18 at 6:40


We'll take the imaginary part in both members: \begin{align}&\sum_{k\ = 1}^{n}\sin\pars{2ky} =\half\,\cot\pars{y} - {\cos\pars{\bracks{2n + 1}y} \over 2\sin\pars{y}} \end{align}

With $\ds{0 < x \leq {\pi \over 2}}$, integrate in both members over $\ds{\pars{x,{\pi \over 2}}}$: \begin{align}&\sum_{k\ = 1}^{n} {-\cos\pars{2k\bracks{\pi/2}} + \cos\pars{2kx} \over 2k} =\left.\half\,\ln\pars{\sin\pars{y}}\right\vert_{x}^{\pi/2} -\half\int_{x}^{\pi/2}{\cos\pars{\bracks{2n + 1}y} \over \sin\pars{y}}\,\dd y \end{align}

Then, \begin{align}-\ \overbrace{\sum_{k\ = 1}^{n}{\pars{-1}^{k}\over k}} ^{\dsc{-\ln\pars{2}}} +\sum_{k\ = 1}^{n}{\cos\pars{2kx} \over k} =-\ln\pars{\sin\pars{x}} -\int_{x}^{\pi/2}{\cos\pars{\bracks{2n + 1}y} \over \sin\pars{y}}\,\dd y \end{align}

We'll take the limit $\ds{n \to\ \infty}$: \begin{align}\ln\pars{\sin\pars{x}}&= -\ln\pars{2} - \sum_{k\ = 1}^{\infty}{\cos\pars{2kx} \over k}\ -\ \underbrace{\lim_{n\ \to\ \infty} \int_{x}^{\pi/2}{\cos\pars{\bracks{2n + 1}y} \over \sin\pars{y}}\,\dd y}_{\ds{=}\ \dsc{0}} \end{align}

$$\color{#66f}{\large\ln\pars{\sin\pars{x}}}= \color{#66f}{\large-\ln\pars{2} - \sum_{k\ = 1}^{\infty}{\cos\pars{2kx} \over k}} \,,\qquad x \in \left(\, 0,{\pi \over 2}\,\right]\tag{1}$$ Indeed $\ds{\large\it\mbox{it's still valid}}$ in $\pars{0,\pi}$ $\ds{\pars{~\color{#00f}{\sf\mbox{see below}}~}}$

When $\ds{x \in \pars{{\pi \over 2},\pi}}$: \begin{align} \ln\pars{\sin\pars{x}}&=\ln\pars{\sin\pars{\pi - x}} =-\ln\pars{2} - \sum_{k\ = 1}^{\infty}{\cos\pars{2k\bracks{\pi - x}} \over k} \\[5mm]&=-\ln\pars{2} - \sum_{k\ = 1}^{\infty}{\cos\pars{2kx} \over k} \end{align} such that $\pars{1}$ is valid in $\pars{0,\pi}$.