Solution (source code)

= Solution

The <Fourier coefficients> follow by multiplying the expansion by $1$, by the appropriate <cosine>, or by the appropriate <sine>, then using <orthogonality>. In the convention with constant term $a_0/2$,
$$
\boxed{\begin{aligned}
a_0&=\frac1L\int_{-L}^Lh(x)\,dx,\\
a_n&=\frac1L\int_{-L}^Lh(x)\cos\frac{n\pi x}{L}\,dx,\qquad n\geq1,\\
b_n&=\frac1L\int_{-L}^Lh(x)\sin\frac{n\pi x}{L}\,dx,\qquad n\geq1.
\end{aligned}}
$$
The factor $1/L$ comes from the squared <norms> of the nonconstant <sine> and <cosine> functions: the <integral> of each square over $[-L,L]$ is $L$. The constant <function> has squared <norm> $2L$.