% Eigenvalue problem u'' = \lambda u clear all; close all a=0; b=pi; n=100; N=n-1; h=(b-a)/n; x=h:h:b-h; % form the matrix A = diag(2*ones(1,N))+ diag(ones(1,N-1),1) + diag(ones(1,N-1),-1); A = A/(h*h); d = eig(A); figure(1); plot(d) [V,D]=eig(A);n1=fix(n/4);n2=fix(n/2); u1=V(:,1); u2=V(:,n1);u3=V(:,n2);u4=V(:,n-2); figure(2) subplot(221); plot(x,u1) subplot(222); plot(x,u2) subplot(223); plot(x,u3) subplot(224); plot(x,u4) % Note: the eigen-functions are normalized in 2-norm.