%L2-norm of (I-P_N)((triangle Phi)_y*Theta_2(j))
%L2-norm of (I-P_N)((triangle Phi)_x*Theta_2(j))
%L2-norm of (I-P_N)(( Phi)_y*Theta_2(j))
%L2-norm of (I-P_N)(( Phi)_x*Theta_2(j))
function [dpytheta2L2,dpxtheta2L2,pxtheta2L2,pytheta2L2]=Ptheta2(Ms,N,iPhi,L1,L2,ialpha,j1,j2,ss,list2,tj,PI);
 g1=-0.5*iPhi.*(L1.^2*ialpha^2+L2.^2).*L2;
g3=-0.5*iPhi.*L2;
 g2=-0.5*iPhi.*(L1.^2*ialpha^2+L2.^2).*L1*ialpha;
 g4=-0.5*iPhi.*L1*ialpha;

    dpytheta2=intval(zeros(2*N+1,4*N+1));%(triangle Phi)_y*Theta_2(j)
pytheta2=intval(zeros(2*N+1,4*N+1));%( Phi)_y*Theta_2(j)
dpxtheta2=intval(zeros(2*N+1,4*N+1));%(triangle Phi)_x*Theta_2(j)
pxtheta2=intval(zeros(2*N+1,4*N+1));%( Phi)_x*Theta_2(j)
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;
    
    dpytheta2(m1,n1)=dpytheta2(m1,n1)+g1(i);
    dpytheta2(m1,n2)=dpytheta2(m1,n2)+g1(i)*tj;
    dpytheta2(m1,n3)=dpytheta2(m1,n3)-g1(i)*ti;
    dpytheta2(m1,n4)=dpytheta2(m1,n4)-g1(i)*ti*tj;
 
    pytheta2(m1,n1)=pytheta2(m1,n1)+g3(i);
    pytheta2(m1,n2)=pytheta2(m1,n2)+g3(i)*tj;
    pytheta2(m1,n3)=pytheta2(m1,n3)-g3(i)*ti;
    pytheta2(m1,n4)=pytheta2(m1,n4)-g3(i)*ti*tj;
   
    dpxtheta2(m1,n1)=dpxtheta2(m1,n1)+g2(i);
    dpxtheta2(m1,n2)=dpxtheta2(m1,n2)+g2(i)*tj;
    dpxtheta2(m1,n3)=dpxtheta2(m1,n3)+g2(i)*ti;
    dpxtheta2(m1,n4)=dpxtheta2(m1,n4)+g2(i)*ti*tj;
    
    pxtheta2(m1,n1)=pxtheta2(m1,n1)+g4(i);
    pxtheta2(m1,n2)=pxtheta2(m1,n2)+g4(i)*tj;
    pxtheta2(m1,n3)=pxtheta2(m1,n3)+g4(i)*ti;
    pxtheta2(m1,n4)=pxtheta2(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;
           dpytheta2(m1,t1)=dpytheta2(m1,t1)+g1(i);
           dpytheta2(m1,t2)=dpytheta2(m1,t2)+g1(i)*tj;
           dpytheta2(m1,t3)=dpytheta2(m1,t3)-g1(i)*ti;
           dpytheta2(m1,t4)=dpytheta2(m1,t4)-g1(i)*ti*tj;
           pytheta2(m1,t1)=pytheta2(m1,t1)+g3(i);
           pytheta2(m1,t2)=pytheta2(m1,t2)+g3(i)*tj;
           pytheta2(m1,t3)=pytheta2(m1,t3)-g3(i)*ti;
           pytheta2(m1,t4)=pytheta2(m1,t4)-g3(i)*ti*tj;
           dpxtheta2(m1,t1)=dpxtheta2(m1,t1)+g2(i);
           dpxtheta2(m1,t2)=dpxtheta2(m1,t2)+g2(i)*tj;
           dpxtheta2(m1,t3)=dpxtheta2(m1,t3)+g2(i)*ti;
           dpxtheta2(m1,t4)=dpxtheta2(m1,t4)+g2(i)*ti*tj;
            pxtheta2(m1,t1)=pxtheta2(m1,t1)+g4(i);
           pxtheta2(m1,t2)=pxtheta2(m1,t2)+g4(i)*tj;
           pxtheta2(m1,t3)=pxtheta2(m1,t3)+g4(i)*ti;
           pxtheta2(m1,t4)=pxtheta2(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;
           dpytheta2(1,s1)=dpytheta2(1,s1)+g1(i);
           dpytheta2(1,s2)=dpytheta2(1,s2)+g1(i)*tj;
           dpytheta2(1,s3)=dpytheta2(1,s3)-g1(i)*ti;
           dpytheta2(1,s4)=dpytheta2(1,s4)-g1(i)*ti*tj;
           pytheta2(1,s1)=pytheta2(1,s1)+g3(i);
           pytheta2(1,s2)=pytheta2(1,s2)+g3(i)*tj;
           pytheta2(1,s3)=pytheta2(1,s3)-g3(i)*ti;
           pytheta2(1,s4)=pytheta2(1,s4)-g3(i)*ti*tj;
           dpxtheta2(1,s1)=dpxtheta2(1,s1)+g2(i);
           dpxtheta2(1,s2)=dpxtheta2(1,s2)+g2(i)*tj;
           dpxtheta2(1,s3)=dpxtheta2(1,s3)+g2(i)*ti;
           dpxtheta2(1,s4)=dpxtheta2(1,s4)+g2(i)*ti*tj;
           pxtheta2(1,s1)=pxtheta2(1,s1)+g4(i);
           pxtheta2(1,s2)=pxtheta2(1,s2)+g4(i)*tj;
           pxtheta2(1,s3)=pxtheta2(1,s3)+g4(i)*ti;
           pxtheta2(1,s4)=pxtheta2(1,s4)+g4(i)*ti*tj;
    end
end
        dpytheta2L2=sum(sum(dpytheta2(1:2*N+1,1:N).^2*2*PI^2/ialpha));
        dpytheta2L2=dpytheta2L2+sum(sum(dpytheta2(1:2*N+1,3*N+2:4*N+1).^2*2*PI^2/ialpha));
        dpytheta2L2=dpytheta2L2+sum(sum(dpytheta2(N+2:2*N+1,N+1:3*N+1).^2*2*PI^2/ialpha));
        dpytheta2L2=sqrt(abs(dpytheta2L2));
        dpxtheta2L2=sum(sum(dpxtheta2(1:2*N+1,1:N).^2*2*PI^2/ialpha));
        dpxtheta2L2=dpxtheta2L2+sum(sum(dpxtheta2(1:2*N+1,3*N+2:4*N+1).^2*2*PI^2/ialpha));
        dpxtheta2L2=dpxtheta2L2+sum(sum(dpxtheta2(N+2:2*N+1,N+1:3*N+1).^2*2*PI^2/ialpha));
        dpxtheta2L2=sqrt(abs(dpxtheta2L2));
        pytheta2L2=sum(sum(pytheta2(1:2*N+1,1:N).^2*2*PI^2/ialpha));
        pytheta2L2=pytheta2L2+sum(sum(pytheta2(1:2*N+1,3*N+2:4*N+1).^2*2*PI^2/ialpha));
        pytheta2L2=pytheta2L2+sum(sum(pytheta2(N+2:2*N+1,N+1:3*N+1).^2*2*PI^2/ialpha));
        pytheta2L2=sqrt(abs(pytheta2L2));
        pxtheta2L2=sum(sum(pxtheta2(1:2*N+1,1:N).^2*2*PI^2/ialpha));
        pxtheta2L2=pxtheta2L2+sum(sum(pxtheta2(1:2*N+1,3*N+2:4*N+1).^2*2*PI^2/ialpha));
        pxtheta2L2=pxtheta2L2+sum(sum(pxtheta2(N+2:2*N+1,N+1:3*N+1).^2*2*PI^2/ialpha));
        pxtheta2L2=sqrt(abs(pxtheta2L2)); 