%L2-norm of (I-P_N)((\delta Phi)_y*Theta_1(j))
%L2-norm of (I-P_N)((\delta Phi)_x*Theta_1(j))
%L2-norm of (I-P_N)(( Phi)_y*Theta_1(j))
%L2-norm of (I-P_N)(( Phi)_x*Theta_1(j))
function [dpytheta1L2,dpxtheta1L2,pxtheta1L2,pytheta1L2]=PTheta1(Ms,N,iPhi,L1,L2,ialpha,j1,j2,ss,list2,tj,PI);
g1=-0.5*iPhi.*(L1.^2*ialpha^2+L2.^2).*L2;
g2=-0.5*iPhi.*(L1.^2*ialpha^2+L2.^2).*L1*ialpha;
g3=-0.5*iPhi.*L2;
g4=-0.5*iPhi.*L1*ialpha;

dpytheta1=intval(zeros(2*N+1,4*N+1));   
pytheta1=intval(zeros(2*N+1,4*N+1));
dpxtheta1=intval(zeros(2*N+1,4*N+1));
pxtheta1=intval(zeros(2*N+1,4*N+1));
for i=1:Ms
    i1=list2(i,1);
    i2=list2(i,2);
    ti=ss(i);
    m1=i1+j1+1;
    n1=i2+j2+2*N+1;
    n2=i2-j2+2*N+1;
    n3=-i2+j2+2*N+1;
    n4=-i2-j2+2*N+1; 
    dpytheta1(m1,n1)=dpytheta1(m1,n1)+g1(i);
    dpytheta1(m1,n2)=dpytheta1(m1,n2)+g1(i)*tj;
    dpytheta1(m1,n3)=dpytheta1(m1,n3)-g1(i)*ti;
    dpytheta1(m1,n4)=dpytheta1(m1,n4)-g1(i)*ti*tj;
  
    pytheta1(m1,n1)=pytheta1(m1,n1)+g3(i);
    pytheta1(m1,n2)=pytheta1(m1,n2)+g3(i)*tj;
    pytheta1(m1,n3)=pytheta1(m1,n3)-g3(i)*ti;
    pytheta1(m1,n4)=pytheta1(m1,n4)-g3(i)*ti*tj;
 
    dpxtheta1(m1,n1)=dpxtheta1(m1,n1)+g2(i);
    dpxtheta1(m1,n2)=dpxtheta1(m1,n2)+g2(i)*tj;
    dpxtheta1(m1,n3)=dpxtheta1(m1,n3)+g2(i)*ti;
    dpxtheta1(m1,n4)=dpxtheta1(m1,n4)+g2(i)*ti*tj;
    
    pxtheta1(m1,n1)=pxtheta1(m1,n1)+g4(i);
    pxtheta1(m1,n2)=pxtheta1(m1,n2)+g4(i)*tj;
    pxtheta1(m1,n3)=pxtheta1(m1,n3)+g4(i)*ti;
    pxtheta1(m1,n4)=pxtheta1(m1,n4)+g4(i)*ti*tj;
    if i1-j1~=0
           signij=sign(i1-j1);
           m1=abs(i1-j1)+1;
           t1=(i2-j2)*signij+2*N+1;
           t2=(i2+j2)*signij+2*N+1;
           t3=(-i2-j2)*signij+2*N+1;
           t4=(-i2+j2)*signij+2*N+1;
           dpytheta1(m1,t1)=dpytheta1(m1,t1)+g1(i);
           dpytheta1(m1,t2)=dpytheta1(m1,t2)+g1(i)*tj;
           dpytheta1(m1,t3)=dpytheta1(m1,t3)-g1(i)*ti;
           dpytheta1(m1,t4)=dpytheta1(m1,t4)-g1(i)*ti*tj;
           pytheta1(m1,t1)=pytheta1(m1,t1)+g3(i);
           pytheta1(m1,t2)=pytheta1(m1,t2)+g3(i)*tj;
           pytheta1(m1,t3)=pytheta1(m1,t3)-g3(i)*ti;
           pytheta1(m1,t4)=pytheta1(m1,t4)-g3(i)*ti*tj;
           dpxtheta1(m1,t1)=dpxtheta1(m1,t1)+g2(i);
           dpxtheta1(m1,t2)=dpxtheta1(m1,t2)+g2(i)*tj;
           dpxtheta1(m1,t3)=dpxtheta1(m1,t3)+g2(i)*ti;
           dpxtheta1(m1,t4)=dpxtheta1(m1,t4)+g2(i)*ti*tj;
            pxtheta1(m1,t1)=pxtheta1(m1,t1)+g4(i);
           pxtheta1(m1,t2)=pxtheta1(m1,t2)+g4(i)*tj;
           pxtheta1(m1,t3)=pxtheta1(m1,t3)+g4(i)*ti;
           pxtheta1(m1,t4)=pxtheta1(m1,t4)+g4(i)*ti*tj;
           else
           s1=abs(i2-j2)+2*N+1;
           s2=(i2+j2)+2*N+1;
           s3=abs(-i2-j2)+2*N+1;
           s4=abs(-i2+j2)+2*N+1;
           dpytheta1(1,s1)=dpytheta1(1,s1)+g1(i);
           dpytheta1(1,s2)=dpytheta1(1,s2)+g1(i)*tj;
           dpytheta1(1,s3)=dpytheta1(1,s3)-g1(i)*ti;
           dpytheta1(1,s4)=dpytheta1(1,s4)-g1(i)*ti*tj;
           pytheta1(1,s1)=pytheta1(1,s1)+g3(i);
           pytheta1(1,s2)=pytheta1(1,s2)+g3(i)*tj;
           pytheta1(1,s3)=pytheta1(1,s3)-g3(i)*ti;
           pytheta1(1,s4)=pytheta1(1,s4)-g3(i)*ti*tj;
           dpxtheta1(1,s1)=dpxtheta1(1,s1)+g2(i);
           dpxtheta1(1,s2)=dpxtheta1(1,s2)+g2(i)*tj;
           dpxtheta1(1,s3)=dpxtheta1(1,s3)+g2(i)*ti;
           dpxtheta1(1,s4)=dpxtheta1(1,s4)+g2(i)*ti*tj;
           pxtheta1(1,s1)=pxtheta1(1,s1)+g4(i);
           pxtheta1(1,s2)=pxtheta1(1,s2)+g4(i)*tj;
           pxtheta1(1,s3)=pxtheta1(1,s3)+g4(i)*ti;
           pxtheta1(1,s4)=pxtheta1(1,s4)+g4(i)*ti*tj;
    end
end

      dpytheta1L2=sum(sum(dpytheta1(1:2*N+1,1:N).^2*2*PI^2/ialpha));
      dpytheta1L2=dpytheta1L2+sum(sum(dpytheta1(1:2*N+1,3*N+2:4*N+1).^2*2*PI^2/ialpha));
      dpytheta1L2=dpytheta1L2+sum(sum(dpytheta1(N+2:2*N+1,N+1:3*N+1).^2*2*PI^2/ialpha));
      dpytheta1L2=sqrt(abs(dpytheta1L2));
        dpxtheta1L2=sum(sum(dpxtheta1(1:2*N+1,1:N).^2*2*PI^2/ialpha));
        dpxtheta1L2=dpxtheta1L2+sum(sum(dpxtheta1(1:2*N+1,3*N+2:4*N+1).^2*2*PI^2/ialpha));
        dpxtheta1L2=dpxtheta1L2+sum(sum(dpxtheta1(N+2:2*N+1,N+1:3*N+1).^2*2*PI^2/ialpha));
        dpxtheta1L2=sqrt(abs(dpxtheta1L2));
        pytheta1L2=sum(sum(pytheta1(1:2*N+1,1:N).^2*2*PI^2/ialpha));
        pytheta1L2=pytheta1L2+sum(sum(pytheta1(1:2*N+1,3*N+2:4*N+1).^2*2*PI^2/ialpha));
        pytheta1L2=pytheta1L2+sum(sum(pytheta1(N+2:2*N+1,N+1:3*N+1).^2*2*PI^2/ialpha));
        pytheta1L2=sqrt(abs(pytheta1L2));
        pxtheta1L2=sum(sum(pxtheta1(1:2*N+1,1:N).^2*2*PI^2/ialpha));
        pxtheta1L2=pxtheta1L2+sum(sum(pxtheta1(1:2*N+1,3*N+2:4*N+1).^2*2*PI^2/ialpha));
        pxtheta1L2=pxtheta1L2+sum(sum(pxtheta1(N+2:2*N+1,N+1:3*N+1).^2*2*PI^2/ialpha));
        pxtheta1L2=sqrt(abs(pxtheta1L2));