Hi PF!(adsbygoogle = window.adsbygoogle || []).push({});

I recently wrote a program in MATLAB to orthonormalize continuous functions on a given interval ##x\in[a,b]##. Lets call the initial linearly independent functions I seek to orthonormalize ##L_i## and let's call these functions ##\psi_i## after I orthonormalize them.

After running my script, I perform an integration check, where I create an ##N\times N## matrix ##A:A_{ij} = \int_a^b \psi_i\psi_j\,dx##, ##N## being the number of ##L_i##'s I use. Theoretically ##A## should be the identity matrix.

When I let ##N=5##, my maximum error outside the diagonals for a particular sequence of functions (too difficult to explain which functions) is very small ##O(10^{-5})##. However, when I let ##N=20##, the maximum error off the diagonals is ##O(1)##.

My question is, do any of you know a set of functions that, once orthonormalized, give another analytic set of functions? I thought about taking ##L_i = x^i:x\in[-1,1]## to generate the Legendre polynomials, but these polynomials are not orthonormal on ##x\in[-1,1]##. I used ##\sin(nx)## and ##\cos(nx)## and they work, but not all sequences of functions seem to (like the first function I eluded to in the previous paragraph).

Does anyone know either what the Legendre polynomials are orthonormal over OR a set of linearly independent functions that have a known analytic corresponding orthonormal set of functions?

I'm trying to check my code and this would be very helpful. For your info, here's the script I wrote

Code (Text):

N = 20;% number of functions

dx = 0.001;

x = -pi:dx:pi;

Li = zeros(N,size(x,2));

for n = 1:size(Li,1)

Li(n,:) = cos(n*x)./sqrt(pi);% linearly independent functions to orthonormalize

end

psi = zeros(size(Li));

ortho = zeros(size(psi));

% gram-schmidt

for ii = 1:size(psi,1)

for s = 1:ii-1

ortho(ii,:) = ortho(ii,:)+psi(s,:)*trapz(psi(s,:).*Li(ii,:))*dx;

end% for s

psi(ii,:) = (Li(ii,:)-ortho(ii,:))./sqrt(trapz((Li(ii,:)-ortho(ii,:)).^2)*dx);% Gram-Schmidt on Li to construct psi

end% for ii

% check orthogonality

for kk = 1:size(Li,1)

for jj = 1:size(Li,1)

orBC(jj,kk) = trapz(psi(kk,:).*psi(jj,:))*dx;% orthogonality check on psi (should be Identity matrix)

end% for jj

end% for kk

for kk = 1:size(Li,1)

for jj = 1:size(Li,1)

orBCexact(jj,kk) = trapz(Li(kk,:).*Li(jj,:))*dx;% orthogonality check on Li (should be Identity matrix)

end% for jj

end% for kk

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# A Checking Gram-Schmidt

Have something to add?

Draft saved
Draft deleted

Loading...

Similar Threads - Checking Gram Schmidt | Date |
---|---|

I Limits to directly check second order differentiability | Feb 28, 2017 |

I Limits to directly check second order differentiability | Feb 28, 2017 |

I I found a *useful* method to calculate log(a+b), check it out | Feb 28, 2016 |

Triple integrals solution check | May 11, 2015 |

Schmidt decomposition theorem proof | Jan 12, 2010 |

**Physics Forums - The Fusion of Science and Community**