I am trying to solve the following ordinary differential equation by assuming that the function $f(x)$ is in the form of a Fourier series, in the bounds $-L < x < L$.
$$ \frac{\mathrm{d}f}{\mathrm{d}x} = f(x) \qquad f(x) = \frac{A_0}{2} + \sum_{n=1}^\infty \left[A_n\cos\left(\frac{n\pi x}{L}\right) + B_n\sin\left(\frac{n\pi x}{L}\right)\right] $$
My solution involves first determining the derivative $\frac{\mathrm{d}f}{\mathrm{d}x}$ from the assumed Fourier series form of the solution and then substituting into the original equation.
$$ \frac{\pi}{L}\sum_{n=1}^\infty n\left[-A_n\sin\left(\frac{n\pi x}{L}\right) + B_n\cos\left(\frac{n\pi x}{L}\right)\right] = \frac{A_0}{2} + \sum_{n=1}^\infty \left[A_n\cos\left(\frac{n\pi x}{L}\right) + B_n\sin\left(\frac{n\pi x}{L}\right)\right] $$
From here I apply orthogonality with $\cos\left(\frac{n\pi x}{L}\right)$ and $\sin\left(\frac{n\pi x}{L}\right)$ with weight function $r(x) = 1$ between $-L < x < L$, the necessary integral solutions shown below.
$$ \int_{-L}^L\!\cos\left(\frac{n\pi x}{L}\right)\cos\left(\frac{m\pi x}{L}\right)\,\mathrm{d}x = \delta_{nm}L \qquad \int_{-L}^L\!\sin\left(\frac{n\pi x}{L}\right)\sin\left(\frac{m\pi x}{L}\right)\,\mathrm{d}x = \delta_{nm}L $$ $$ \int_{-L}^L\!\sin\left(\frac{n\pi x}{L}\right)\cos\left(\frac{m\pi x}{L}\right)\,\mathrm{d}x = 0 \qquad \int_{-L}^L\!\cos\left(\frac{n\pi x}{L}\right)\sin\left(\frac{m\pi x}{L}\right)\,\mathrm{d}x = 0 $$ $$ \int_{-L}^L\!\cos\left(\frac{n\pi x}{L}\right)\,\mathrm{d}x = 0 \qquad \int_{-L}^L\!\sin\left(\frac{n\pi x}{L}\right)\,\mathrm{d}x = 0 $$ Applying these orthogonality conditions to the original equation $$ \text{orthogonality with} \quad \cos\left(\frac{n\pi x}{L}\right), \quad \frac{\pi}{L}\sum_{n=1}^\infty n\left[0 + L\delta_{nm}B_n\right] = 0 + \sum_{n=1}^\infty\left[L\delta_{nm}A_n + 0\right] $$ $$ n\pi B_n = LA_n \qquad B_n = \frac{L}{n\pi}A_n $$ $$ \text{orthogonality with} \quad \sin\left(\frac{n\pi x}{L}\right), \quad \frac{\pi}{L}\sum_{n=1}^\infty n\left[-L\delta_{nm}A_n + 0\right] = 0 + \sum_{n=1}^\infty\left[0 + L\delta_{nm}B_n\right] $$ $$ -n\pi A_n = LB_n \qquad B_n = -\frac{n \pi}{L}A_n $$
These results are contradictory, or to be more specific orthogonality with the cosine seems to give an incorrect result, since derivation of the Fourier series coefficients for the solution to this differential equation, $f(x) = Ae^x$, shows that $B_n = -\frac{n \pi}{L}A_n$. Have I made a mistake in my working or am I not understanding something about orthogonality?
I may have made some mistakes in typing this up, I have double checked everything but I cannot be sure. I have however done this derivation through many times with pen and paper and always come to these contradictory results.