"Solomon" <
alao...@gmail.com> wrote in message <mpelhk$b8v$
1...@newscl01ah.mathworks.com>...
>
> Here is the code
>
> steps=1000;
> kx = linspace(-2*pi/3,2*pi/3,steps);
> ky =linspace(-pi/sqrt(3),pi/sqrt(3),steps);
> ev1=zeros(length(kx));
> for l= 1:length(kx)
> for j= 1:length(ky)
> k3= kx(l); k1= -(kx(l) + sqrt(3)*ky(j))/2; % wave vectors
> k2= (-kx(l) + sqrt(3)*ky(j))/2;
> ga=(1/12)*(exp(1i*k1)+exp(1i*k2)+exp(1i*k3));
> gas=(1/12)*(exp(-1i*k1)+exp(-1i*k2)+exp(-1i*k3));
> m1=[0, ga, gas; gas, 0, ga; ga, gas, 0]; m2= eye(3) +m1;
> xx=[0,1; 1,0]; id2= eye(2); id3= eye(3);
> zz=[1,0; 0,-1]; id6= kron(zz,id3);
> H1= kron(m2, id2)-3*kron(m1, xx); H= id6*H1;
> [V,eg]=eig(H);
> egd=sort(real(diag(eg)));
> ev1(l,j)= egd(4)+egd(5)+egd(6);
> end
> end
> ev = 1-(1/(4*pi^2))*trapz(ky,trapz(kx,ev1,2))
The code you give with ev1(l,j) has kx varying along the first dimension of ev1, not its second, so you are incorrect when you say "The second dimension has kx varying." This means that trapz(kx,ev1,2) is incorrect by a scale factor of 2*sqrt(3). Moreover if the number of steps in kx and ky were different you would get an error message for the trapz call because the number of elements in kx would not be equal to the number of columns in ev1. However, with the number of steps the same, the outer trapz would have the opposite scale factor error which compensates for the inner scale factor error, giving you essentially the same answer as if you had written trapz(kx,trapz(ky,ev1,2)), so this error does not account for the numerical discrepancy between what you expect and what you get.
This apparently narrows the problem down to my fourth point, namely the way the elements of ev1 are computed, and I can't help you with this at present since I don't know the theory behind these computations. If you would give a reference to some accessible internet article that carries out this computation in non-matlab form, perhaps it would be possible for me or someone else to detect where your matlab code may go wrong.