matlab file for the diagonalization: matre2m.m
The file as listing: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% eng=2.8;V1=-2; fac=0.4; nnn=input('dimension of the matrix: ') ; nhal=floor((nnn-1)/2); diga=[ones(1,nhal);fac*ones(1,nhal)]; digg=reshape(diga,1, 2*nhal); if (nnn-1)==(2*nhal+1) digg=[ digg 1]; end H0=eng*eye(nnn); H1=diag(digg); H1=[zeros(nnn-1,1) H1];H1=[H1;zeros(1,nnn)];H1=H1+H1'; H1=H0+H1*V1; H1(1,1)=2;H1(nnn,nnn)=2; [a_vec e_val] = eig(H1); [vals inds]=sort(diag(e_val)); figure(1) plot(vals,'*') figure(2) sqvals=sqrt(vals); sqvals=abs(sqvals); plot((sqvals),'*') ind1=1; while (ind1>0) ind1=input('which eigenvector to plot : (negative stop) '); if ind1>0 vec=a_vec(:,inds(ind1)); figure(3) plot(vec,'o');set(gca,'ylim',[-3/sqrt(nnn) 3/sqrt(nnn) ]); end end %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%