L Squared Error for a Fourier Sine Series

How close is my Fourier Sine series to a function f(x)?

Answer: \( L_2(N) = -\frac{1}{2} a_n^2 + \int_\Omega f^2(x) dx \)

This question came up recently while discussing PDE (partial differential equations) solution techniques. The final result is quite interesting.

Our sine series approximates the function f(x) over the domain \(\Omega\) as $$f(x) \approx \sum {{a_n}\sin (n \pi x)}$$ You can determine the coefficients with the formula. $$ a_n = 2\int_\Omega f(x) \sin(n \pi x) dx$$
One good measure of the error between the sine series and the function is the \(L_2\), pronounced “el squared”, error. $$ L_2 =\int_{\Omega} \left( u(x) – f(x) \right)^2 dx $$
Substitute for the sine series to obtain. $$ L_2 = \int_{\Omega} \left({{a_n}sin (n \pi x)}- f(x) \right)^2 dx $$
Expand the terms to obtain $$ L_2 = \int_{\Omega} a_n^2 \sin^2(n \pi x) dx  -2\int_{\Omega} a_n f(x) \sin(n \pi x) dx + \int_{\Omega} f^2(x) dx $$

Now, these integrals are particularly interesting. The first integral is a constant \(0.5 a_n^2\). The second contains the definition of \(a_n\). The third only contains the function \(f^2(x)\). This simplifies to $$L_2(N) = -\frac{1}{2} a_n^2 +\int_\Omega f^2(x) dx$$

Interestingly, if we let the error become zero, the following is an identity $$ a_n^2 = 2 \int_\Omega f^2(x) dx$$ Knowledge of this identity will allow you to quickly compute integrals of squared trig functions.

Neat! Do you have any interesting Fourier results? Let me know in the comments.