Solution (source code)

= Solution

Differentiate the <Fourier series> term by term and collect <cosine> and <sine> terms. Substitution into the equation gives
$$
\boxed{\frac{a_0}{2}+\sum_{n=1}^{\infty}
[(a_n+\sqrt3\,n b_n)\cos(nx)+(b_n-\sqrt3\,n a_n)\sin(nx)]
=4\sin x.}
$$
For a <smooth> periodic solution, <differentiation> of the series is justified. Alternatively, multiply the <differential equation> by each trigonometric mode and integrate by parts; periodicity cancels the boundary terms and gives the same <coefficient> constraints without first differentiating an infinite sum.