Basis and Orthogonal Functions

This is a generalization of the Fourier series.  The orthogonality of the trignometric functions
(i.e., (∫_0^1) Sin[2 π n  x]  Sin[
            2 π m x] dx = ({{(1/2), if    n = m}, {0, if   n ≠ m}}))
was the key to the ``trick''  that permitted calculation of the Fourier coefficients.
This is a generalization of dot or scalar vector product, but for functions.  The norm that is defined above for the trignometric functions is fairly simple, it is the l2-norm:
f(x) • g(x) ≡  ∫ f(x) g(x) dx        (l2-norm)
However, there can be many other types of norms, for instance a Gaussian weighted l2-norm
f(x) • g(x) ≡  ∫ f(x) g(x) (e^(-x^2)) dx        (Gaussian weighted l2-norm)
and many many others.

Both the norm and the domain of integration must be defined.

To represent a function in terms of a sum of basis functions with coefficients, a orthogonality relation must be obtained for the basis functions.
We will do a few examples of orthogonality relations, the coefficients can be found as a straightforward extension of the Fourier method.

Establish by example the orthogonality relations for the Lengendre Polynomials

Table[
      Integrate[
        LegendreP[i, x] LegendreP[5, x], {x, -1, 1}], {i, -10, 
        10}]

Calculate the norm as a function of the order of the Legendre polynomial

Table[
      Integrate[LegendreP[i, x] LegendreP[i, x], {x, -1, 1}], {i, 0, 
        15}]

Make a guess at what the norm looks like

Table[(2/(2 i  +  1)),  {i, 0, 15}]

The orthogonality relation is plausibly: (∫_(-1)^1) LegendreP[i, x]  LegendreP[
            j, x] dx = ({{(2/(2  i  +  1)), if  |  
                  i |  = |j|}, {0, if  | i  | ≠|j|}})
In fact, this is correct

Representation of a function in terms of the Legendre basis

This demonstrates how to take a specific set (basis) of orthogonal functions and represent an arbitrary function in terms of an infinite sum of terms involving the basis functions, each with its own coefficient.  This is a direct analog to what we did with Fourier series.

A function to calculate the coefficients

LegendreCoefficient[f_,  i_]   :=  ((2 i  +  1)/2) 
        Integrate[f[x] LegendreP[i, x], {x, -1, 1}]

Use Legendre functions to represent the function (e^(-(x^2)))

This is an example function:

AFunc[x_]  := Exp[-x^2]

Calculate the first twenty coefficients

Lcofs  =  Table[LegendreCoefficient[AFunc, i], {i, 0, 20}]

Construct a vector of the eigenfunctions

Lfuncs  =  Table[LegendreP[i, x], {i, 0, 20}];

Visualize the approximation of the first twenty terms

Plot[{Lcofs . Lfuncs, Exp[-x^2]}, {x, -1, 1}, 
      PlotStyle -> {{Hue[0], Thickness[0.01]}, {Hue[0.66], 
            Thickness[0.005]}}]

Try another function

AFunc[x_]  := Sin[5  x] Sin[(5  +  (1/10)) x]

Coefficients out to 10 terms

Lcofs  =  Table[LegendreCoefficient[AFunc, i], {i, 0, 10}]

Lfuncs  =  Table[LegendreP[i, x], {i, 0, 10}];

Visualize the approximation

Plot[{Lcofs . Lfuncs, AFunc[x]}, {x, -1, 1}, 
      PlotStyle -> {{Hue[0], Thickness[0.01]}, {Hue[0.66], 
            Thickness[0.005]}}]