There was a mistake in the formulas, the correct ones (i think) are theses
In any case, I think that the usual formulas for the coefficients of Fourier
are trivial to program in Maxima.
b(n):= 1/L * integrate(f(x)*cos(n*w*x),x,-L,L);
a(n):= 1/L * integrate(f(x)*sin(n*w*x),x,-L,L);
f(x)= a0/2 + sum a(n)*sin(n*w*x) + sum b(n)*cos(n*w*x) with w=%pi/(2*L)