%L2-norm of (I-P_N)((triangle Psi)_y*Theta_2(j))
%L2-norm of (I-P_N)((triangle Psi)_x*Theta_2(j))
%L2-norm of (I-P_N)(( Psi)_y*Theta_2(j))
%L2-norm of (I-P_N)(( Psi)_x*Theta_2(j))
function [dpsytheta2L2,dpsxtheta2L2,psxtheta2L2,psytheta2L2]=Pstheta2(Ma,N,iPsi,K1,K2,ialpha,j1,j2,sa,list3,tj,PI);
g1=-0.5*iPsi.*(K1.^2*ialpha^2+K2.^2).*K2;
g2=-0.5*iPsi.*(K1.^2*ialpha^2+K2.^2).*K1*ialpha;
  g3=-0.5*iPsi.*K2;
  g4=-0.5*iPsi.*K1*ialpha;
  
dpsytheta2=intval(zeros(2*N+1,4*N+1));%(triangle Psi)_y*Theta_2(j)
psytheta2=intval(zeros(2*N+1,4*N+1));%( Psi)_y*Theta_2(j)
dpsxtheta2=intval(zeros(2*N+1,4*N+1));%(triangle Psi)_x*Theta_2(j)
psxtheta2=intval(zeros(2*N+1,4*N+1));%( Psi)_x*Theta_2(j)
for i=1:Ma
    i1=list3(i,1);
    i2=list3(i,2);
    ti=sa(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;
    
    dpsytheta2(m1,n1)=dpsytheta2(m1,n1)+g1(i);
    dpsytheta2(m1,n2)=dpsytheta2(m1,n2)+g1(i)*tj;
    dpsytheta2(m1,n3)=dpsytheta2(m1,n3)-g1(i)*ti;
    dpsytheta2(m1,n4)=dpsytheta2(m1,n4)-g1(i)*ti*tj;
  
    psytheta2(m1,n1)=psytheta2(m1,n1)+g3(i);
    psytheta2(m1,n2)=psytheta2(m1,n2)+g3(i)*tj;
    psytheta2(m1,n3)=psytheta2(m1,n3)-g3(i)*ti;
    psytheta2(m1,n4)=psytheta2(m1,n4)-g3(i)*ti*tj;
    
    dpsxtheta2(m1,n1)=dpsxtheta2(m1,n1)+g2(i);
    dpsxtheta2(m1,n2)=dpsxtheta2(m1,n2)+g2(i)*tj;
    dpsxtheta2(m1,n3)=dpsxtheta2(m1,n3)+g2(i)*ti;
    dpsxtheta2(m1,n4)=dpsxtheta2(m1,n4)+g2(i)*ti*tj;
    
    psxtheta2(m1,n1)=psxtheta2(m1,n1)+g4(i);
    psxtheta2(m1,n2)=psxtheta2(m1,n2)+g4(i)*tj;
    psxtheta2(m1,n3)=psxtheta2(m1,n3)+g4(i)*ti;
    psxtheta2(m1,n4)=psxtheta2(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;
           dpsytheta2(m1,t1)=dpsytheta2(m1,t1)+g1(i);
           dpsytheta2(m1,t2)=dpsytheta2(m1,t2)+g1(i)*tj;
           dpsytheta2(m1,t3)=dpsytheta2(m1,t3)-g1(i)*ti;
           dpsytheta2(m1,t4)=dpsytheta2(m1,t4)-g1(i)*ti*tj;
           psytheta2(m1,t1)=psytheta2(m1,t1)+g3(i);
           psytheta2(m1,t2)=psytheta2(m1,t2)+g3(i)*tj;
           psytheta2(m1,t3)=psytheta2(m1,t3)-g3(i)*ti;
           psytheta2(m1,t4)=psytheta2(m1,t4)-g3(i)*ti*tj;
           dpsxtheta2(m1,t1)=dpsxtheta2(m1,t1)+g2(i);
           dpsxtheta2(m1,t2)=dpsxtheta2(m1,t2)+g2(i)*tj;
           dpsxtheta2(m1,t3)=dpsxtheta2(m1,t3)+g2(i)*ti;
           dpsxtheta2(m1,t4)=dpsxtheta2(m1,t4)+g2(i)*ti*tj;
            psxtheta2(m1,t1)=psxtheta2(m1,t1)+g4(i);
           psxtheta2(m1,t2)=psxtheta2(m1,t2)+g4(i)*tj;
           psxtheta2(m1,t3)=psxtheta2(m1,t3)+g4(i)*ti;
           psxtheta2(m1,t4)=psxtheta2(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;
           dpsytheta2(1,s1)=dpsytheta2(1,s1)+g1(i);
           dpsytheta2(1,s2)=dpsytheta2(1,s2)+g1(i)*tj;
           dpsytheta2(1,s3)=dpsytheta2(1,s3)-g1(i)*ti;
           dpsytheta2(1,s4)=dpsytheta2(1,s4)-g1(i)*ti*tj;
           psytheta2(1,s1)=psytheta2(1,s1)+g3(i);
           psytheta2(1,s2)=psytheta2(1,s2)+g3(i)*tj;
           psytheta2(1,s3)=psytheta2(1,s3)-g3(i)*ti;
           psytheta2(1,s4)=psytheta2(1,s4)-g3(i)*ti*tj;
           dpsxtheta2(1,s1)=dpsxtheta2(1,s1)+g2(i);
           dpsxtheta2(1,s2)=dpsxtheta2(1,s2)+g2(i)*tj;
           dpsxtheta2(1,s3)=dpsxtheta2(1,s3)+g2(i)*ti;
           dpsxtheta2(1,s4)=dpsxtheta2(1,s4)+g2(i)*ti*tj;
           psxtheta2(1,s1)=psxtheta2(1,s1)+g4(i);
           psxtheta2(1,s2)=psxtheta2(1,s2)+g4(i)*tj;
           psxtheta2(1,s3)=psxtheta2(1,s3)+g4(i)*ti;
           psxtheta2(1,s4)=psxtheta2(1,s4)+g4(i)*ti*tj;
    end
end
 
      dpsytheta2L2=sum(sum(dpsytheta2(1:2*N+1,1:N).^2*2*PI^2/ialpha));
      dpsytheta2L2=dpsytheta2L2+sum(sum(dpsytheta2(1:2*N+1,3*N+2:4*N+1).^2*2*PI^2/ialpha));
      dpsytheta2L2=dpsytheta2L2+sum(sum(dpsytheta2(N+2:2*N+1,N+1:3*N+1).^2*2*PI^2/ialpha));
      dpsytheta2L2=sqrt(abs(dpsytheta2L2));
        dpsxtheta2L2=sum(sum(dpsxtheta2(1:2*N+1,1:N).^2*2*PI^2/ialpha));
        dpsxtheta2L2=dpsxtheta2L2+sum(sum(dpsxtheta2(1:2*N+1,3*N+2:4*N+1).^2*2*PI^2/ialpha));
        dpsxtheta2L2=dpsxtheta2L2+sum(sum(dpsxtheta2(N+2:2*N+1,N+1:3*N+1).^2*2*PI^2/ialpha));
        dpsxtheta2L2=sqrt(abs(dpsxtheta2L2));
        psytheta2L2=sum(sum(psytheta2(1:2*N+1,1:N).^2*2*PI^2/ialpha));
        psytheta2L2=psytheta2L2+sum(sum(psytheta2(1:2*N+1,3*N+2:4*N+1).^2*2*PI^2/ialpha));
        psytheta2L2=psytheta2L2+sum(sum(psytheta2(N+2:2*N+1,N+1:3*N+1).^2*2*PI^2/ialpha));
        psytheta2L2=sqrt(abs(psytheta2L2));
        psxtheta2L2=sum(sum(psxtheta2(1:2*N+1,1:N).^2*2*PI^2/ialpha));
        psxtheta2L2=psxtheta2L2+sum(sum(psxtheta2(1:2*N+1,3*N+2:4*N+1).^2*2*PI^2/ialpha));
        psxtheta2L2=psxtheta2L2+sum(sum(psxtheta2(N+2:2*N+1,N+1:3*N+1).^2*2*PI^2/ialpha));
        psxtheta2L2=sqrt(abs(psxtheta2L2));
   
 
