Example (Fourier series of t(1-t))

Consider the 1-periodic function $f:\R\to\R$ defined by $$ \begin{align*} f(\theta) = \theta(1-\theta), \quad \theta\in[0,1). \end{align*} $$

First we compute $$ \begin{align*} \hat f_0 &= \int_{0}^{1} \theta(1-\theta) \d \theta \\ &= \frac{1}{2} - \frac{1}{3} = \frac{1}{6}. \end{align*} $$ Then for $n\neq 0$, $$ \begin{align*} \hat f_n &= \int_{0}^{1} \theta(1-\theta) e^{-2\pi i n \theta} \d \theta \\ &= -\frac{1}{2\pi in}\Big(\underbrace{\left[\theta(1-\theta) e^{-2\pi in\theta}\right]_{\theta=0}^1}_{0 \text{ by continuity}} - \int_{0}^{1} (1-2\theta) e^{-2\pi i n\theta} \d \theta\Big) \\ &= -\frac{1}{4(n\pi)^2} \Big([(1-2\theta) e^{-2\pi i n\theta}]_{\theta = 0}^1 + 2\int_{0}^{1} e^{-2\pi i n\theta} \d \theta\Big) \\ &= -\frac{1}{2(n\pi)^2} \end{align*} $$ so $$ \begin{align*} f(\theta) \sim \frac{1}{6} - \frac{1}{2} \sum_{n\neq 0} \frac{1}{(n\pi)^2} e^{2\pi i n\theta}. \end{align*} $$

Or we can find the real Fourier series: since $f$ is even, $b_n = 0$. And for $n\geq 1$, $$ \begin{align*} a_n &= 2\int_{0}^{1} \theta(1-\theta) \cos (2\pi n\theta) \d \theta \\ &= \frac{1}{n \pi} \left([\theta(1-\theta)\sin(2\pi n \theta)]_{\theta = 0}^1 - \int_{0}^{1} (1-2\theta) \sin(2\pi n \theta) \d \theta\right) \\ &= -\frac{1}{2(n\pi)^2} \left([-(1-2\theta)\cos(2\pi n \theta)]_{\theta = 0}^1 - \int_{0}^{1} 2\cos(2\pi n\theta)\d \theta\right) \\ &= -\frac{1}{(n\pi)^2} \end{align*} $$ so $$ \begin{align*} f(\theta) \sim \frac{1}{6} - \sum_{n=1}^\infty \frac{1}{(n\pi)^2} \cos(2\pi n \theta). \end{align*} $$