Orthonormal basis functions

We discussed a class of functions  {(Subscript[u, 1]), (Subscript[u, 2]), . . ., (Subscript[u, n])} that posses the property that
∫  dx   \(TraditionalForm\`\(u\_n\^*\)\) (Subscript[u, m]) = (Subscript[δ, nm]).   There exist many  such sets in mathematical physics,
below we give one example of such a  set.  We will look at a class of real  functions
that satisfy orthonormality in the domain  -1 < x < 1.

Mathematica contains built in functions that are important in mathematical physics. One them is called LegendreP, and  gives the famous Legendre Polynomials.

We define a function u[n,x] in terms of the built in functions

u[n_,x_]=Sqrt[(2 n+1)/2] LegendreP[n,x]

Lets plot such a function in the domain, first
I will try n=3. Try some other values for n.

Plot[u[3,x],{x,-1,1}]

Are these functions normalized?, Lets see for a particular n=5. Try some other
values.

n=5;
Integrate[u[n,x]u[n,x],{x,-1,1}]
Clear[n];

Finally, we need to check orthogonality. We define the integral

integral[n_,m_]:=Integrate[u[n,x]u[m,x],{x,-1,1}]

Note: We defined something new here. The colon after the definition for the function integral, is called a set delay. It tells Mathematica not to evaluate the r.h.s until the function is called.

integral[1,0]

integral[2,3]

integral[5,5]

So you see that the functions u[n,x] do seem to be orthonormal. Of course one can only prove this analytically for all n.

According to the discussion in our notes any function  psi(x)  could be expressed
as a sum of the basis functions , psi=∑ c[n] u[n,x], and the expansion coefficients
are given by ∫dx u[n,x] psi[x]=c[n], where the integral is over the domain -1<x<1

c[n_]:=Integrate[psi[x] u[n,x],{x,-1,1}]

Lets choose some function for psi

psi[x_]=Sqrt[x^2]

graph1=Plot[psi[x],{x,-1,1}]

Let's calculate a few coeffiecient

N[c[6]]

(Note: N[fun] means to evaluate to a real number)

It's easier to construct a whole table of c[n]. I will call this table cntable up to a max=12.

max=12;
cntable=Table[N[c[i]],{i,0,max}]

Note that the odd terms vanish, and the even terms seem to get smaller. Lets plot the truncated  sum psi=∑ c[n] u[n,x]

approximationforpsi[x_]:=Sum[cntable[[i]] u[i-1,x],{i,1,12}]

graph2=Plot[approximationforpsi[x],{x,-1,1}]

we compare this approximation to the real function

Show[{graph1,graph2}]

The approximation is Ok, except perhaps near x=0. Obviously if we chose max to be greater than 12 we would obtain a better approximation.

This subset from n=0,12 will not form a complete set over the interval. Let's construct  g[x,y]=∑ u[n,x]u[n,y]

g[x_,y_]:=Sum[u[n,x]u[n,y],{n,0,max}]

Plot3D[Evaluate[g[x,y]],{x,-1,1},{y,-1,1},PlotRange->{0,10},PlotPoints->40]

Note that g[x,y] has a strong peak structure  along the diagonal where x=y. This is reminiscent of the peak near x=0 for the δ[x] function. Because we are truncating at max=12 we certainly do not have a complete set, but as we increase max  g[x,y] should approach a delta function δ[x-y].

Try finding the expansion coefficients for other functions g[x]. What happens if g[x] is a polynomial function? Also try using different values for max