Problem 352
Easy Remainders and Fourier Series

Expand f(x)=x² in a sine series on (0,pi)

Expand $f(x)=x^2$ in a sine series on $(0,\pi)$.

Explanation of Method

Two integrations by parts on $\int_0^\pi x^2\sin(nx)\,dx$ produce a coefficient with two distinct pieces: one proportional to $\pi^2/n$ (from the leading boundary term, present for every $n$) and one proportional to $1/n^3$ that survives only for odd $n$ (since it involves $(-1)^n-1$).

  1. Integrate $x^2\sin(nx)$ by parts twice.
  2. Evaluate at the endpoints and simplify.
  3. Split the result into its all-$n$ and odd-only pieces.

Step 1 · Computing $b_n$

Using $\int x^2\sin(nx)\,dx=-\dfrac{x^2\cos(nx)}n+\dfrac{2x\sin(nx)}{n^2}+\dfrac{2\cos(nx)}{n^3}$, evaluated on $[0,\pi]$ (with $\sin(n\pi)=0$, $\cos(n\pi)=(-1)^n$): $$ \int_0^\pi x^2\sin(nx)\,dx = \frac{\pi^2(-1)^{n+1}}n + \frac{2[(-1)^n-1]}{n^3}. $$ Multiplying by $2/\pi$: $$ b_n = \frac{2\pi(-1)^{n+1}}n + \frac{4[(-1)^n-1]}{\pi n^3}. $$

Step 2 · Splitting by parity

For even $n$: $(-1)^n-1=0$, so $b_n=\dfrac{-2\pi}n$. For odd $n$: $(-1)^n-1=-2$, so $b_n=\dfrac{2\pi}n-\dfrac8{\pi n^3}$. (Verified numerically: partial sums to $2000$ terms match $x^2$ to 3+ decimal places at several test points.)

Step 3 · Fourier series

$$ \boxed{x^2 = 2\pi\sum_{n=1}^\infty\frac{(-1)^{n+1}}n\sin(nx) - \frac8\pi\sum_{k=1}^\infty\frac{\sin((2k-1)x)}{(2k-1)^3}} $$


Summary Table

PropertyValue
Coefficient (even $n$)$b_n=-2\pi/n$
Coefficient (odd $n$)$b_n=2\pi/n-8/(\pi n^3)$

Additional Notes

Result

$$ x^2 = 2\pi\sum_{n=1}^\infty\frac{(-1)^{n+1}}n\sin(nx) - \frac8\pi\sum_{k=1}^\infty\frac{\sin((2k-1)x)}{(2k-1)^3}, \qquad x\in(0,\pi). $$