# Generalized Fourier series

A generalized Fourier series is the expansion of a square integrable function into a sum of square integrable orthogonal basis functions. The standard Fourier series uses an orthonormal basis of trigonometric functions, and the series expansion is applied to periodic functions. In contrast, a generalized Fourier series uses any set of orthogonal basis functions and can apply to any square integrable function.

## Definition

Consider a set $\Phi =\{\phi _{n}:[a,b]\to \mathbb {C} \}_{n=0}^{\infty }$ of square-integrable complex valued functions defined on the closed interval $[a,b]$ that are pairwise orthogonal under the weighted inner product:
$\langle f,g\rangle _{w}=\int _{a}^{b}f(x){\overline {g(x)}}w(x)dx,$
where $w(x)$ is a weight function and ${\overline {g}}$ is the complex conjugate of $g$. Then, the generalized Fourier series of a function $f$ is: $f(x)=\sum _{n=0}^{\infty }c_{n}\phi _{n}(x),$where the coefficients are given by: $c_{n}={\langle f,\phi _{n}\rangle _{w} \over \|\phi _{n}\|_{w}^{2}}.$

## Sturm-Liouville Problems

Given the space $L^{2}(a,b)$ of square integrable functions defined on a given interval, one can find orthogonal bases by considering a class of boundary value problems on the interval $[a,b]$ called regular Sturm-Liouville problems. These are defined as follows, $(rf')'+pf+\lambda wf=0$ $B_{1}(f)=B_{2}(f)=0$ where $r,r'$ and $p$ are real and continuous on $[a,b]$ and $r>0$ on $[a,b]$, $B_{1}$ and $B_{2}$ are self-adjoint boundary conditions, and $w$ is a positive continuous functions on $[a,b]$.
Given a regular Sturm-Liouville problem as defined above, the set $\{\phi _{n}\}_{1}^{\infty }$ of eigenfunctions corresponding to the distinct eigenvalue solutions to the problem form an orthogonal basis for $L^{2}(a,b)$ with respect to the weighted inner product $\langle \cdot ,\cdot \rangle _{w}$. We also have that for a function $f\in L^{2}(a,b)$ that satisfies the boundary conditions of this Sturm-Liouville problem, the series $\sum _{n=1}^{\infty }\langle f,\phi _{n}\rangle \phi _{n}$ converges uniformly to $f$.

## Examples
### Fourier–Legendre series

A function $f(x)$ defined on the entire number line is called periodic with period $T$ if a number $T>0$ exists such that, for any real number $x$, the equality $f(x+T)=f(x)$ holds.
If a function is periodic with period $T$, then it is also periodic with periods $2T$, $3T$, and so on. Usually, the period of a function is understood as the smallest such number $T$. However, for some functions, arbitrarily small values of $T$ exist.
The sequence of functions $1,\cos(x),\sin(x),\cos(2x),\sin(2x),...,\cos(nx),\sin(nx),...$ is known as the trigonometric system. Any linear combination of functions of a trigonometric system, including an infinite combination (that is, a converging infinite series), is a periodic function with a period of 2π.
On any segment of length 2π (such as the segments [−π,π] and [0,2π]) the trigonometric system is an orthogonal system. This means that for any two functions of the trigonometric system, the integral of their product over a segment of length 2π is equal to zero. This integral can be treated as a scalar product in the space of functions that are integrable on a given segment of length 2π.
Let the function $f(x)$ be defined on the segment [−π, π]. Given appropriate smoothness and differentiability conditions, $f(x)$ may be represented on this segment as a linear combination of functions of the trigonometric system, also referred to as the expansion of the function $f(x)$ into a trigonometric Fourier series.
The Legendre polynomials $P_{n}(x)$ are solutions to the Sturm–Liouville eigenvalue problem
    $\left((1-x^{2})P_{n}'(x)\right)'+n(n+1)P_{n}(x)=0.$
As a consequence of Sturm-Liouville theory, these polynomials are orthogonal eigenfunctions with respect to the inner product with unit weight. This can be written as a generalized Fourier series (known in this case as a Fourier–Legendre series) involving the Legendre polynomials, so that
    $f(x)\sim \sum _{n=0}^{\infty }c_{n}P_{n}(x),$
    $c_{n}={\langle f,P_{n}\rangle _{w} \over \|P_{n}\|_{w}^{2}}$
As an example, the Fourier–Legendre series may be calculated for $f(x)=\cos x$ over $[-1,1]$. Then
    ${\begin{aligned}c_{0}&={\int _{-1}^{1}\cos {x}\,dx \over \int _{-1}^{1}(1)^{2}\,dx}=\sin {1}\\c_{1}&={\int _{-1}^{1}x\cos {x}\,dx \over \int _{-1}^{1}x^{2}\,dx}={0 \over 2/3}=0\\c_{2}&={\int _{-1}^{1}{3x^{2}-1 \over 2}\cos {x}\,dx \over \int _{-1}^{1}{9x^{4}-6x^{2}+1 \over 4}\,dx}={6\cos {1}-4\sin {1} \over 2/5}\end{aligned}}$
and a truncated series involving only these terms would be
    ${\begin{aligned}c_{2}P_{2}(x)+c_{1}P_{1}(x)+c_{0}P_{0}(x)&={5 \over 2}(6\cos {1}-4\sin {1})\left({3x^{2}-1 \over 2}\right)+\sin 1\\&=\left({45 \over 2}\cos {1}-15\sin {1}\right)x^{2}+6\sin {1}-{15 \over 2}\cos {1}\end{aligned}}$
which differs from $\cos x$ by approximately 0.003. In computational applications it may be advantageous to use such Fourier–Legendre series rather than Fourier series since the basis functions for the series expansion are all polynomials and hence the integrals and thus the coefficients may be easier to calculate.

## Coefficient theorems

Some theorems on the series' coefficients $c_{n}$ include:

### Bessel's inequality

Bessel's inequality is a statement about the coefficients of an element $x$ in a Hilbert space with respect to an orthonormal sequence. The inequality was derived by F.W. Bessel in 1828:
    $\sum _{n=0}^{\infty }|c_{n}|^{2}\leq \int _{a}^{b}|f(x)|^{2}w(x)\,dx.$

### Parseval's theorem

Parseval's theorem usually refers to the result that the Fourier transform is unitary; loosely, that the sum (or integral) of the square of a function is equal to the sum (or integral) of the square of its transform.
If Φ is a complete basis, then:
    $\sum _{n=0}^{\infty }|c_{n}|^{2}=\int _{a}^{b}|f(x)|^{2}w(x)\,dx.$