 pxduy=intval(zeros(2*N+1,4*N+1)); %(Phi)_x(\triangle u)_y
pydux=intval(zeros(2*N+1,4*N+1)); %(Phi)_y(\triangle u)_x
uxdpy=intval(zeros(2*N+1,4*N+1)); %(u)_x(\triangle Phi)_y
uydpx=intval(zeros(2*N+1,4*N+1)); %(u)_y(\triangle Phi)_x
uxduy=intval(zeros(2*N+1,4*N+1)); %(u)_x(\triangle u)_y
uydux=intval(zeros(2*N+1,4*N+1)); %(u)_y(\triangle u)_x
g1=0.5*ialpha*(-iPhi.*L1*(w(1:Ms).*L2.*(L1.^2*ialpha^2+L2.^2))'); %pxduy
 g2=0.5*ialpha*(-iPhi.*L2*(w(1:Ms).*L1.*(L1.^2*ialpha^2+L2.^2))'); %pydux
 g3=0.5*ialpha*(-w(1:Ms).*L1*(iPhi.*L2.*(L1.^2*ialpha^2+L2.^2))'); %uxdpy
  g4=0.5*ialpha*(-w(1:Ms).*L2*(iPhi.*L1.*(L1.^2*ialpha^2+L2.^2))'); %uydpx
  g5=0.5*ialpha*(-w(1:Ms).*L1*(w(1:Ms).*L2.*(L1.^2*ialpha^2+L2.^2))'); %uxduy
  g6=0.5*ialpha*(-w(1:Ms).*L2*(L1.*w(1:Ms).*(L1.^2*ialpha^2+L2.^2))'); %uydux
for i=1:Ms 
    i1=list2(i,1);
    i2=list2(i,2);
    ti=ss(i);
    for j=1:Ms
        j1=list2(j,1);
        j2=list2(j,2); 
        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;
        tj=-ss(j); 
        pxduy(m1,n1)= pxduy(m1,n1)-g1(i,j);
         pxduy(m1,n2)= pxduy(m1,n2)-g1(i,j)*tj;
       pxduy(m1,n3)= pxduy(m1,n3)-g1(i,j)*ti;
        pxduy(m1,n4)= pxduy(m1,n4)-g1(i,j)*ti*tj;
         
        pydux(m1,n1)= pydux(m1,n1)-g2(i,j); 
         pydux(m1,n2)=pydux(m1,n2)-g2(i,j)*(-1)*tj;
         pydux(m1,n3)=pydux(m1,n3)-g2(i,j)*ti*(-1);
         pydux(m1,n4)= pydux(m1,n4)-g2(i,j)*ti*tj;  
          
        uxdpy(m1,n1)= uxdpy(m1,n1)-g3(i,j);
         uxdpy(m1,n2)= uxdpy(m1,n2)-g3(i,j)*tj;
       uxdpy(m1,n3)= uxdpy(m1,n3)-g3(i,j)*ti;
        uxdpy(m1,n4)= uxdpy(m1,n4)-g3(i,j)*ti*tj;
         
        uydpx(m1,n1)= uydpx(m1,n1)-g4(i,j); 
         uydpx(m1,n2)=uydpx(m1,n2)-g4(i,j)*(-1)*tj;
         uydpx(m1,n3)=uydpx(m1,n3)-g4(i,j)*(-1)*ti;
         uydpx(m1,n4)= uydpx(m1,n4)-g4(i,j)*ti*tj; 
         
        uxduy(m1,n1)= uxduy(m1,n1)-g5(i,j);
         uxduy(m1,n2)= uxduy(m1,n2)-g5(i,j)*tj;
       uxduy(m1,n3)= uxduy(m1,n3)-g5(i,j)*ti;
        uxduy(m1,n4)= uxduy(m1,n4)-g5(i,j)*ti*tj;
      
        uydux(m1,n1)= uydux(m1,n1)-g6(i,j); 
         uydux(m1,n2)=uydux(m1,n2)-g6(i,j)*(-1)*tj;
         uydux(m1,n3)=uydux(m1,n3)-g6(i,j)*(-1)*ti;
         uydux(m1,n4)= uydux(m1,n4)-g6(i,j)*ti*tj;  
       if i1-j1~=0
           signij=sign(i1-j1);
           m2=abs(i1-j1)+1;
           s1=(i2-j2)*signij+2*N+1;
           s2=(i2+j2)*signij+2*N+1;
           s3=(-i2-j2)*signij+2*N+1;
           s4=(-i2+j2)*signij+2*N+1;
        pxduy(m2,s1)= pxduy(m2,s1)+g1(i,j);
        pxduy(m2,s2)= pxduy(m2,s2)+g1(i,j)*tj;
        pxduy(m2,s3)= pxduy(m2,s3)+g1(i,j)*ti;
        pxduy(m2,s4)= pxduy(m2,s4) +g1(i,j)*tj*ti;
        pydux(m2,s1)= pydux(m2,s1)+g2(i,j);
        pydux(m2,s2)= pydux(m2,s2)+g2(i,j)*(-1)*tj;
        pydux(m2,s3)= pydux(m2,s3)+g2(i,j)*(-1)*ti;
        pydux(m2,s4)= pydux(m2,s4)+g2(i,j) *ti*tj;
        uxdpy(m2,s1)= uxdpy(m2,s1)+g3(i,j);
        uxdpy(m2,s2)= uxdpy(m2,s2)+g3(i,j)*tj;
        uxdpy(m2,s3)= uxdpy(m2,s3)+g3(i,j)*ti;
        uxdpy(m2,s4)= uxdpy(m2,s4)+g3(i,j)*tj*ti;
        uydpx(m2,s1)= uydpx(m2,s1)+g4(i,j);
        uydpx(m2,s2)= uydpx(m2,s2)+g4(i,j)*(-1)*tj;
        uydpx(m2,s3)= uydpx(m2,s3)+g4(i,j)*(-1)*ti;
        uydpx(m2,s4)= uydpx(m2,s4) +g4(i,j) *ti*tj;
         uxduy(m2,s1)= uxduy(m2,s1)+g5(i,j);
        uxduy(m2,s2)= uxduy(m2,s2)+g5(i,j)*tj;
        uxduy(m2,s3)= uxduy(m2,s3)+g5(i,j)*ti;
        uxduy(m2,s4)= uxduy(m2,s4) +g5(i,j)*ti*tj;
        uydux(m2,s1)= uydux(m2,s1)+g6(i,j);
        uydux(m2,s2)= uydux(m2,s2)+g6(i,j)*(-1)*tj;
        uydux(m2,s3)= uydux(m2,s3)+g6(i,j)*(-1)*ti;
        uydux(m2,s4)= uydux(m2,s4) +g6(i,j) *tj*ti;
       else
           t1=abs(i2-j2)+2*N+1;
           t2=(i2+j2)+2*N+1;
           t3=abs(-i2-j2)+2*N+1;
           t4=abs(-i2+j2)+2*N+1;
        pxduy(1,t1)= pxduy(1,t1)+g1(i,j);
        pxduy(1,t2)= pxduy(1,t2)+g1(i,j)*tj;
        pxduy(1,t3)= pxduy(1,t3)+g1(i,j)*ti;
        pxduy(1,t4)= pxduy(1,t4)+g1(i,j)*ti*tj;
        pydux(1,t1)= pydux(1,t1)+g2(i,j);
        pydux(1,t2)= pydux(1,t2)+g2(i,j)*(-1)*tj;
        pydux(1,t3)= pydux(1,t3)+g2(i,j)*(-1)*ti;
        pydux(1,t4)= pydux(1,t4)+g2(i,j)*ti*tj;  
        uxdpy(1,t1)= uxdpy(1,t1)+g3(i,j);
        uxdpy(1,t2)= uxdpy(1,t2)+g3(i,j)*tj;
        uxdpy(1,t3)= uxdpy(1,t3)+g3(i,j)*ti;
        uxdpy(1,t4)= uxdpy(1,t4)+g3(i,j)*ti*tj;
        uydpx(1,t1)= uydpx(1,t1)+g4(i,j);
        uydpx(1,t2)= uydpx(1,t2)+g4(i,j)*(-1)*tj;
        uydpx(1,t3)= uydpx(1,t3)+g4(i,j)*(-1)*ti;
        uydpx(1,t4)= uydpx(1,t4)+g4(i,j)*ti*tj;   
         uxduy(1,t1)= uxduy(1,t1)+g5(i,j);
        uxduy(1,t2)= uxduy(1,t2)+g5(i,j)*tj;
        uxduy(1,t3)= uxduy(1,t3)+g5(i,j)*ti;
        uxduy(1,t4)= uxduy(1,t4)+g5(i,j)*ti*tj;
        uydux(1,t1)= uydux(1,t1)+g6(i,j);
        uydux(1,t2)= uydux(1,t2)+g6(i,j)*(-1)*tj;
        uydux(1,t3)= uydux(1,t3)+g6(i,j)*(-1)*ti;
        uydux(1,t4)= uydux(1,t4)+g6(i,j)*ti*tj;   
        end
    end
end

putheta=pxduy-pydux+uxdpy-uydpx; % (Phi)_x(\triangle u_N)_y-(Phi)_y(\triangle u_N)_x+(u_N)_x(\triangle Phi)_y
                                 % -(u_N)_y(\triangle Phi)_x
puthetaL2=intval(zeros(Ms,1));% ((Phi)_x(\triangle u_N)_y-(Phi)_y(\triangle u_N)_x+(u_N)_x(\triangle Phi)_y
                                 % -(u_N)_y(\triangle  Phi)_x,\Theta_1(i))_{L^2}
uutheta=uxduy-uydux; %(u_N)_x(\triangle u_N)_y-(u_N)_y(\triangle u_N)_x
uuthetaL2=intval(zeros(Ms,1)); %((u_N)_x(\triangle u_N)_y-(u_N)_y(\triangle u_N)_x,\Theta_1(i))_{L^2}
for i=1:3*N/2
    i1=list2(i,1);
    i2=list2(i,2);
    puthetaL2(i)=puthetaL2(i)+putheta(i1+1,i2+2*N+1)*2*PI^2/ialpha;
    uuthetaL2(i)=uuthetaL2(i)+uutheta(i1+1,i2+2*N+1)*2*PI^2/ialpha; 
end
for i=3*N/2+1:Ms
   i1=list2(i,1);
   i2=list2(i,2);
   puthetaL2(i)=puthetaL2(i)+putheta(i1+1,i2+2*N+1)*2*PI^2/ialpha;
   puthetaL2(i)=puthetaL2(i)+putheta(i1+1,-i2+2*N+1)*2*PI^2/ialpha*(-1)^(floor(i1/2)+i2+1);
   uuthetaL2(i)=uuthetaL2(i)+uutheta(i1+1,i2+2*N+1)*2*PI^2/ialpha;
   uuthetaL2(i)=uuthetaL2(i)+uutheta(i1+1,-i2+2*N+1)*2*PI^2/ialpha*(-1)^(floor(i1/2)+i2+1); 
end
vxdpy=intval(zeros(2*N+1,4*N+1)); %(v)_x(\triangle Phi)_y
vydpx=intval(zeros(2*N+1,4*N+1)); %(v)_y(\triangle Phi)_x
psxduy=intval(zeros(2*N+1,4*N+1)); %(Psi)_x(\triangle u)_y
psydux=intval(zeros(2*N+1,4*N+1)); %(Psi)_y(\triangle u)_x
uxdpsy=intval(zeros(2*N+1,4*N+1)); %(u)_x(\triangle Psi)_y
uydpsx=intval(zeros(2*N+1,4*N+1)); %(u)_y(\triangle Psi)_x
pxdvy=intval(zeros(2*N+1,4*N+1));  %(Phi)_x(\triangle v)_y
pydvx=intval(zeros(2*N+1,4*N+1));  %(Phi)_y(\triangle v)_x
uxdvy=intval(zeros(2*N+1,4*N+1));  %(u)_x(\triangle v)_y
uydvx=intval(zeros(2*N+1,4*N+1));  %(u)_y(\triangle v)_x
vxduy=intval(zeros(2*N+1,4*N+1));  %(v)_x(\triangle u)_y
vydux=intval(zeros(2*N+1,4*N+1));  %(v)_y(\triangle u)_x
g1=0.5*ialpha*(-w(1:Ms).*L1*(iPsi.*K2.*(K1.^2*ialpha^2+K2.^2))');
g2=0.5*ialpha*(-w(1:Ms).*L2*(iPsi.*K1.*(K1.^2*ialpha^2+K2.^2))');
g3=0.5*ialpha*(-iPhi.*L1*(w(Ms+1:Ms+Ma).*K2.*(K1.^2*ialpha^2+K2.^2))');
g4=0.5*ialpha*(-iPhi.*L2*(w(Ms+1:Ms+Ma).*K1.*(K1.^2*ialpha^2+K2.^2))');
g5=0.5*ialpha*(-iPhi.*L2.*(L1.^2*ialpha^2+L2.^2)*(w(Ms+1:Ms+Ma).*K1)');
g6=0.5*ialpha*(-iPhi.*L1.*(L1.^2*ialpha^2+L2.^2)*(w(Ms+1:Ms+Ma).*K2)');
g7=0.5*ialpha*(-w(1:Ms).*L2.*(L1.^2*ialpha^2+L2.^2)*(iPsi.*K1)');
g8=0.5*ialpha*(-L1.*w(1:Ms).*(L1.^2*ialpha^2+L2.^2)*(iPsi.*K2)');
g9=0.5*ialpha*(-w(1:Ms).*L1*(K2.*w(Ms+1:Ms+Ma).*(K1.^2*ialpha^2+K2.^2))');
g10=0.5*ialpha*(-w(1:Ms).*L2*(w(Ms+1:Ms+Ma).*K1.*(K1.^2*ialpha^2+K2.^2))');
 g11=0.5*ialpha*(-L2.*w(1:Ms).*(L1.^2*ialpha^2+L2.^2)*(w(Ms+1:Ms+Ma).*K1)');
  g12=0.5*ialpha*(-L1.*w(1:Ms).*(L1.^2*ialpha^2+L2.^2)*(w(Ms+1:Ms+Ma).*K2)');
for i=1:Ms
    i1=list2(i,1);
    i2=list2(i,2);
    ti=ss(i);
    for k=1:Ma
        k1=list3(k,1);
        k2=list3(k,2);
        
        m1=i1+k1+1;
        n1=i2+k2+2*N+1;
        n2=i2-k2+2*N+1;
        n3=-i2+k2+2*N+1;
        n4=-i2-k2+2*N+1;
         tk=-sa(k);
         uxdpsy(m1,n1)= uxdpsy(m1,n1)-g1(i,k);
         uxdpsy(m1,n2)=uxdpsy(m1,n2)-g1(i,k)*tk;
         uxdpsy(m1,n3)=uxdpsy(m1,n3)-g1(i,k)*ti; 
         uxdpsy(m1,n4)= uxdpsy(m1,n4)-g1(i,k)*ti*tk;         
          
         uydpsx(m1,n1)= uydpsx(m1,n1)-g2(i,k);
         uydpsx(m1,n2)=uydpsx(m1,n2)-g2(i,k)*(-1)*tk;      
        uydpsx(m1,n3)=uydpsx(m1,n3)-g2(i,k)*(-1)*ti;
          uydpsx(m1,n4)= uydpsx(m1,n4)-g2(i,k)*ti*tk; 
      
         pxdvy(m1,n1)= pxdvy(m1,n1)-g3(i,k);
         pxdvy(m1,n2)=pxdvy(m1,n2)-g3(i,k)*tk;
         pxdvy(m1,n3)=pxdvy(m1,n3)-g3(i,k)*ti; 
         pxdvy(m1,n4)= pxdvy(m1,n4)-g3(i,k)*ti*tk;         
          
               pydvx(m1,n1)= pydvx(m1,n1)-g4(i,k);
         pydvx(m1,n2)=pydvx(m1,n2)-g4(i,k)*(-1)*tk;      
        pydvx(m1,n3)=pydvx(m1,n3)-g4(i,k)*(-1)*ti;
          pydvx(m1,n4)= pydvx(m1,n4)-g4(i,k)*ti*tk; 
          
               vxdpy(m1,n1)= vxdpy(m1,n1)-g5(i,k);
         vxdpy(m1,n2)=vxdpy(m1,n2)-g5(i,k)*(-1)*tk;
         vxdpy(m1,n3)=vxdpy(m1,n3)-g5(i,k)*(-1)*ti;
          vxdpy(m1,n4)= vxdpy(m1,n4)-g5(i,k)*ti*tk; 
       
               vydpx(m1,n1)= vydpx(m1,n1)-g6(i,k);
          vydpx(m1,n2)=vydpx(m1,n2)-g6(i,k)*tk;
         vydpx(m1,n3)=vydpx(m1,n3)-g6(i,k)*ti;
            vydpx(m1,n4)= vydpx(m1,n4)-g6(i,k)*tk*ti; 
        
               psxduy(m1,n1)= psxduy(m1,n1)-g7(i,k);
         psxduy(m1,n2)=psxduy(m1,n2)-g7(i,k)*(-1)*tk;
         psxduy(m1,n3)=psxduy(m1,n3)-g7(i,k)*(-1)*ti;
          psxduy(m1,n4)= psxduy(m1,n4)-g7(i,k)*ti*tk; 
       
               psydux(m1,n1)= psydux(m1,n1)-g8(i,k);
          psydux(m1,n2)=psydux(m1,n2)-g8(i,k)*tk;
         psydux(m1,n3)=psydux(m1,n3)-g8(i,k)*ti;
            psydux(m1,n4)= psydux(m1,n4)-g8(i,k)*ti*tk;  
        
         uxdvy(m1,n1)= uxdvy(m1,n1)-g9(i,k);
         uxdvy(m1,n2)=uxdvy(m1,n2)-g9(i,k)*tk;
         uxdvy(m1,n3)=uxdvy(m1,n3)-g9(i,k)*ti; 
         uxdvy(m1,n4)= uxdvy(m1,n4)-g9(i,k)*ti*tk;         
          
               uydvx(m1,n1)= uydvx(m1,n1)-g10(i,k);
         uydvx(m1,n2)=uydvx(m1,n2)-g10(i,k)*(-1)*tk;      
        uydvx(m1,n3)=uydvx(m1,n3)-g10(i,k)*(-1)*ti;
          uydvx(m1,n4)= uydvx(m1,n4)-g10(i,k)*ti*tk; 
        
               vxduy(m1,n1)= vxduy(m1,n1)-g11(i,k);
         vxduy(m1,n2)=vxduy(m1,n2)-g11(i,k)*(-1)*tk;
         vxduy(m1,n3)=vxduy(m1,n3)-g11(i,k)*(-1)*ti;
          vxduy(m1,n4)= vxduy(m1,n4)-g11(i,k)*ti*tk; 
      
              vydux(m1,n1)= vydux(m1,n1)-g12(i,k);
          vydux(m1,n2)=vydux(m1,n2)-g12(i,k)*tk;
         vydux(m1,n3)=vydux(m1,n3)-g12(i,k)*ti;
            vydux(m1,n4)= vydux(m1,n4)-g12(i,k)*ti*tk; 
        if i1-k1~=0
            m2=abs(i1-k1)+1;
            s1=(i2-k2)*sign(i1-k1)+2*N+1;
            s2=(i2+k2)*sign(i1-k1)+2*N+1;
            s3=(-i2-k2)*sign(i1-k1)+2*N+1;
            s4=(-i2+k2)*sign(i1-k1)+2*N+1;
        uxdpsy(m2,s1)= uxdpsy(m2,s1)+g1(i,k);
        uxdpsy(m2,s2)= uxdpsy(m2,s2) +g1(i,k)*tk;
        uxdpsy(m2,s3)=uxdpsy(m2,s3) +g1(i,k)*ti;
       uxdpsy(m2,s4)=uxdpsy(m2,s4) +g1(i,k)*ti*tk;
        uydpsx(m2,s1)= uydpsx(m2,s1)+g2(i,k);
        uydpsx(m2,s2)= uydpsx(m2,s2) +g2(i,k)*(-1)*tk;
        uydpsx(m2,s3)=uydpsx(m2,s3)+g2(i,k)*(-1)*ti;
        uydpsx(m2,s4)=uydpsx(m2,s4) +g2(i,k)*ti*tk;
      pxdvy(m2,s1)= pxdvy(m2,s1)+g3(i,k);
        pxdvy(m2,s2)= pxdvy(m2,s2)+g3(i,k)*tk;
        pxdvy(m2,s3)=pxdvy(m2,s3) +g3(i,k)*ti;
       pxdvy(m2,s4)=pxdvy(m2,s4) +g3(i,k)*ti*tk;
        pydvx(m2,s1)= pydvx(m2,s1)+g4(i,k);
        pydvx(m2,s2)= pydvx(m2,s2)+g4(i,k)*(-1)*tk;
        pydvx(m2,s3)=pydvx(m2,s3) +g4(i,k)*(-1)*ti;
        pydvx(m2,s4)=pydvx(m2,s4) +g4(i,k)*ti*tk;
         vxdpy(m2,s1)= vxdpy(m2,s1)+g5(i,k);
        vxdpy(m2,s2)= vxdpy(m2,s2) +g5(i,k)*(-1)*tk;
        vxdpy(m2,s3)=vxdpy(m2,s3) +g5(i,k)*(-1)*ti;
        vxdpy(m2,s4)=vxdpy(m2,s4)  +g5(i,k)*ti*tk;
        vydpx(m2,s1)= vydpx(m2,s1)+g6(i,k);
        vydpx(m2,s2)= vydpx(m2,s2)+g6(i,k)*tk;
        vydpx(m2,s3)=vydpx(m2,s3) +g6(i,k)*ti;
         vydpx(m2,s4)=vydpx(m2,s4) +g6(i,k)*ti*tk;
          psxduy(m2,s1)= psxduy(m2,s1)+g7(i,k);
        psxduy(m2,s2)= psxduy(m2,s2)  +g7(i,k)*(-1)*tk;
        psxduy(m2,s3)=psxduy(m2,s3) +g7(i,k)*(-1)*ti;
        psxduy(m2,s4)=psxduy(m2,s4)  +g7(i,k)*ti*tk;
        psydux(m2,s1)= psydux(m2,s1)+g8(i,k);
        psydux(m2,s2)= psydux(m2,s2) +g8(i,k)*tk;
        psydux(m2,s3)=psydux(m2,s3) +g8(i,k)*ti;
         psydux(m2,s4)=psydux(m2,s4)+g8(i,k)*ti*tk;
          uxdvy(m2,s1)= uxdvy(m2,s1)+g9(i,k);
        uxdvy(m2,s2)= uxdvy(m2,s2)+g9(i,k)*tk;
        uxdvy(m2,s3)=uxdvy(m2,s3)+g9(i,k)*ti;
       uxdvy(m2,s4)=uxdvy(m2,s4)+g9(i,k)*ti*tk;
        uydvx(m2,s1)= uydvx(m2,s1)+g10(i,k);
        uydvx(m2,s2)= uydvx(m2,s2)+g10(i,k)*(-1)*tk;
        uydvx(m2,s3)=uydvx(m2,s3)+g10(i,k)*(-1)*ti;
        uydvx(m2,s4)=uydvx(m2,s4) +g10(i,k)*ti*tk;
          vxduy(m2,s1)= vxduy(m2,s1)+g11(i,k);
        vxduy(m2,s2)= vxduy(m2,s2)+g11(i,k)*(-1)*tk;
        vxduy(m2,s3)=vxduy(m2,s3)+g11(i,k)*(-1)*ti;
        vxduy(m2,s4)=vxduy(m2,s4)+g11(i,k)*ti*tk;
        vydux(m2,s1)= vydux(m2,s1)+g12(i,k);
        vydux(m2,s2)= vydux(m2,s2)+g12(i,k)*tk;
        vydux(m2,s3)=vydux(m2,s3)+g12(i,k)*ti;
         vydux(m2,s4)=vydux(m2,s4)+g12(i,k)*ti*tk;
        else
             t1=abs(i2-k2)+2*N+1;
             t2=abs(i2+k2)+2*N+1;
             t3=abs(-i2-k2)+2*N+1;
             t4=abs(-i2+k2)+2*N+1;
        uxdpsy(1,t1)= uxdpsy(1,t1)+g1(i,k);
        uxdpsy(1,t2)= uxdpsy(1,t2)+g1(i,k)*tk;
        uxdpsy(1,t3)=uxdpsy(1,t3) +g1(i,k)*ti;
       uxdpsy(1,t4)=uxdpsy(1,t4)+g1(i,k)*ti*tk;
        uydpsx(1,t1)= uydpsx(1,t1)+g2(i,k);
        uydpsx(1,t2)= uydpsx(1,t2)+g2(i,k)*(-1)*tk;
        uydpsx(1,t3)=uydpsx(1,t3)+g2(i,k)*(-1)*ti;
        uydpsx(1,t4)=uydpsx(1,t4)+g2(i,k)*tk*ti;
        pxdvy(1,t1)= pxdvy(1,t1)+g3(i,k);
        pxdvy(1,t2)= pxdvy(1,t2)+g3(i,k)*tk;
        pxdvy(1,t3)=pxdvy(1,t3)+g3(i,k)*ti;
       pxdvy(1,t4)=pxdvy(1,t4)+g3(i,k)*ti*tk;
        pydvx(1,t1)= pydvx(1,t1)+g4(i,k);
        pydvx(1,t2)= pydvx(1,t2)+g4(i,k)*(-1)*tk;
        pydvx(1,t3)=pydvx(1,t3)+g4(i,k)*(-1)*ti;
        pydvx(1,t4)=pydvx(1,t4)+g4(i,k)*ti*tk; 
        vxdpy(1,t1)= vxdpy(1,t1)+g5(i,k);
        vxdpy(1,t2)= vxdpy(1,t2)+g5(i,k)*(-1)*tk;
        vxdpy(1,t3)=vxdpy(1,t3)+g5(i,k)*(-1)*ti;
        vxdpy(1,t4)=vxdpy(1,t4)+g5(i,k)*ti*tk;
        vydpx(1,t1)= vydpx(1,t1)+g6(i,k);
        vydpx(1,t2)= vydpx(1,t2)+g6(i,k)*tk;
        vydpx(1,t3)=vydpx(1,t3)+g6(i,k)*ti;
         vydpx(1,t4)=vydpx(1,t4)+g6(i,k)*ti*tk;  
         psxduy(1,t1)= psxduy(1,t1)+g7(i,k);
        psxduy(1,t2)= psxduy(1,t2)+g7(i,k)*(-1)*tk;
        psxduy(1,t3)=psxduy(1,t3)+g7(i,k)*(-1)*ti;
        psxduy(1,t4)=psxduy(1,t4)+g7(i,k)*ti*tk;
        psydux(1,t1)= psydux(1,t1)+g8(i,k);
        psydux(1,t2)= psydux(1,t2)+g8(i,k)*tk;
        psydux(1,t3)=psydux(1,t3)+g8(i,k)*ti;
         psydux(1,t4)=psydux(1,t4)+g8(i,k)*ti*tk;  
          uxdvy(1,t1)= uxdvy(1,t1)+g9(i,k);
        uxdvy(1,t2)= uxdvy(1,t2)+g9(i,k)*tk;
        uxdvy(1,t3)=uxdvy(1,t3)+g9(i,k)*ti;
       uxdvy(1,t4)=uxdvy(1,t4)+g9(i,k)*tk*ti;
        uydvx(1,t1)= uydvx(1,t1)+g10(i,k);
        uydvx(1,t2)= uydvx(1,t2)+g10(i,k)*(-1)*tk;
        uydvx(1,t3)=uydvx(1,t3)+g10(i,k)*(-1)*ti;
        uydvx(1,t4)=uydvx(1,t4)+g10(i,k)*ti*tk;
         vxduy(1,t1)= vxduy(1,t1)+g11(i,k);
        vxduy(1,t2)= vxduy(1,t2)+g11(i,k)*(-1)*tk;
        vxduy(1,t3)=vxduy(1,t3)+g11(i,k)*(-1)*ti;
        vxduy(1,t4)=vxduy(1,t4)+g11(i,k)*ti*tk;
        vydux(1,t1)= vydux(1,t1)+g12(i,k);
        vydux(1,t2)= vydux(1,t2)+g12(i,k)*tk;
        vydux(1,t3)=vydux(1,t3)+g12(i,k)*ti;
         vydux(1,t4)=vydux(1,t4)+g12(i,k)*tk*ti;    
        end
    end
end
 psutheta=vxdpy-vydpx+psxduy-psydux+uxdpsy-uydpsx+pxdvy-pydvx; %J(v_N,\triangle\Phi_N)+J(\Psi_N,\triangle u_N)
                                                            %+J(u_N,\triangle \Psi_N)+J(\Phi_N,\triangle v_N)
uvtheta=uxdvy-uydvx+vxduy-vydux; %J(u_N,\triangle v_N)+J(v_N,\triangle u_N)                                                            
psuthetaL2=intval(zeros(Ma,1)); %(J(v_N,\triangle\Phi_N)+J(\Psi_N,\triangle u_N)
         %+J(u_N,\triangle \Psi_N)+J(\Phi_N,\triangle v_N),\Theta_2(i))_{L^2}
 uvthetaL2=intval(zeros(Ma,1));%(J(u_N,\triangle v_N)+J(v_N,\triangle u_N),\Theta_2(i))_{L^2}   
 for i=1:N^2/2
      i1=list3(i,1);
      i2=list3(i,2);
       psuthetaL2(i)=psuthetaL2(i)+psutheta(i1+1,i2+2*N+1)*2*PI^2/ialpha;
       uvthetaL2(i)=uvthetaL2(i)+uvtheta(i1+1,i2+2*N+1)*2*PI^2/ialpha;
       psuthetaL2(i)=psuthetaL2(i)+psutheta(i1+1,-i2+2*N+1)*2*PI^2/ialpha*(-1)^(floor(i1/2)+i2);
          
       uvthetaL2(i)=uvthetaL2(i)+uvtheta(i1+1,-i2+2*N+1)*2*PI^2/ialpha*(-1)^(floor(i1/2)+i2);
 end
  for i=N^2/2+1:Ma
      i1=list3(i,1);
      i2=list3(i,2);
       psuthetaL2(i)=psuthetaL2(i)+psutheta(i1+1,i2+2*N+1)^2*2*PI^2/ialpha;
       uvthetaL2(i)=uvthetaL2(i)+uvtheta(i1+1,i2+2*N+1)^2*2*PI^2/ialpha;
  end     
  
                         
p1=pxduy-pydux+uxdpy-uydpx+uxduy-uydux;
p2=pxduy-pydux+uxdpy-uydpx+2*(uxduy-uydux);
p3=pxduy-pydux+uxdpy-uydpx+uxduy-uydux+pxdpy-pydpx;
p4=psxduy-psydux+vxdpy-vydpx+vxduy-vydux+pxdvy-pydvx+uxdpsy-uydpsx+uxdvy-uydvx;
p5=psxduy-psydux+vxdpy-vydpx+2*(vxduy-vydux)+pxdvy-pydvx+uxdpsy-uydpsx+2*(uxdvy-uydvx);
p6=psxdpy-psydpx+psxduy-psydux+vxdpy-vydpx+vxduy-vydux+pxdpsy-pydpsx+pxdvy-pydvx ...
    +uxdpsy-uydpsx+uxdvy-uydvx;  
         puL2=sum(sum(p1(1:2*N+1,1:N).^2))*2*PI^2/ialpha;
%L2-norm of (I-P_N)J(\Phi_N,\triangle u_N)+J(u_N,\triangle \Phi_N)+J(u_N,\triangle u_N)
         puL2=puL2+sum(sum(p1(1:2*N+1,3*N+2:4*N+1).^2))*2*PI^2/ialpha;
         puL2=puL2+sum(sum(p1(N+2:2*N+1,N+1:3*N+1).^2))*2*PI^2/ialpha;
          pu2L2=sum(sum(p2(1:2*N+1,1:N).^2))*2*PI^2/ialpha;
%L2-norm of (I-P_N)J(\Phi_N,\triangle u_{2N})+J(u_{2N},\triangle \Phi_N)+J(u_{2N},\triangle u_{1N})
                    %+J(u_{1N},\triangle u_{2N})          
          pu2L2=pu2L2+sum(sum(p2(1:2*N+1,3*N+2:4*N+1).^2))*2*PI^2/ialpha; 
         pu2L2=pu2L2+sum(sum(p2(N+2:2*N+1,N+1:3*N+1).^2))*2*PI^2/ialpha;
          ppuL2=sum(sum(p3(1:2*N+1,1:N).^2))^2*2*PI^2/ialpha;
  %L2-norm of (I-P_N)J(\Phi_N,\triangle u_{1N})+J(u_{1N},\triangle \Phi_N)+J(u_{1N},\triangle u_{1N})
                    %+J(Phi_{N},\triangle \Phi_{N})        
          ppuL2=ppuL2+sum(sum(p3(1:2*N+1,3*N+2:4*N+1).^2))^2*2*PI^2/ialpha;
          ppuL2=ppuL2+sum(sum(p3(N+2:2*N+1,N+1:3*N+1).^2))^2*2*PI^2/ialpha;
         psuL2=sum(sum(p4(1:2*N+1,1:N).^2))*2*PI^2/ialpha;
  %L2-norm of (I-P_N)J(\Psi_N,\triangle u_N)+J(u_N,\triangle \Psi_N)+J(u_N,\triangle v_N)
                    %+J(\Phi_N,\triangle v_N)+J(v_N,\triangle \Phi_N)+J(v_N,\triangle u_N)        
         psuL2=psuL2+sum(sum(p4(1:2*N+1,3*N+2:4*N+1).^2))*2*PI^2/ialpha;
         psuL2=psuL2+sum(sum(p4(N+2:2*N+1,N+1:3*N+1).^2))*2*PI^2/ialpha;
         psu2L2=sum(sum(p5(1:2*N+1,1:N).^2))*2*PI^2/ialpha;
  %L2-norm of (I-P_N)J(\Psi_N,\triangle u_{2N})+J(v_{1N},\traingle u_{2N})
                      %+J(u_{2N},\triangle \Psi_N)+J(u_{2N},\triangle v_{1N})
                      %+J(v_{2N},\triangle \Phi_N)+J(v_{2N},\triangle u_{1N})
                      %+J(\PHi_N,\triangle v_{2N})+J(u_{1N},\trinagle v_{2N})       
         psu2L2=psu2L2+sum(sum(p5(1:2*N+1,3*N+2:4*N+1).^2))*2*PI^2/ialpha;
         psu2L2=psu2L2+sum(sum(p5(N+2:2*N+1,N+1:3*N+1).^2))*2*PI^2/ialpha;
         ppsuL2=sum(sum(p6(1:2*N+1,1:N).^2))*2*PI^2/ialpha;
   %L2-norm of (I-P_N)J(\Psi_N,\triangle u_{1N})+J(v_{1N},\traingle u_{1N})
                      %+J(u_{1N},\triangle \Psi_N)+J(u_{1N},\triangle v_{1N})
                      %+J(v_{1N},\triangle \Phi_N))+J(\Phi_N,\triangle v_{1N})
                      %+J(\Psi_N,\triangle \Phi_N)+J(\Phi_N,\triangle \Psi_N)      
         ppsuL2=ppsuL2+sum(sum(p6(1:2*N+1,3*N+2:4*N+1).^2))*2*PI^2/ialpha;
         ppsuL2=ppsuL2+sum(sum(p6(N+2:2*N+1,N+1:3*N+1).^2))*2*PI^2/ialpha; 
 
 
puL2=sqrt(puL2);
ppuL2=sqrt(ppuL2);
psuL2=sqrt(psuL2);
pu2L2=sqrt(pu2L2);
psu2L2=sqrt(psu2L2);
ppsuL2=sqrt(ppsuL2);
  DvxL2=intval('0'); %L2 norm of (\trinagle v)_x
DvyL2=intval('0'); %L2 norm of (\trinagle v)_y
vxL2=intval('0'); %L2 norm of v_x
vyL2=intval('0'); %L2 norm of v_y
 for i=1:N^2/2
      i1=list3(i,1);
      i2=list3(i,2);
       vxL2=vxL2+w(i+Ms)^2*4*PI^2*i1^2*ialpha;
      vyL2=vyL2+4*PI^2*i2^2/ialpha*w(i+Ms)^2;
      DvxL2=DvxL2+(i1^2*ialpha^2+i2^2)^2*w(i+Ms)^2*4*PI^2*i1^2*ialpha;
      DvyL2=DvyL2+(i1^2*ialpha^2+i2^2)^2*w(i+Ms)^2*4*PI^2*i2^2/ialpha;
  end
  for i=N^2/2+1:Ma
      i1=list3(i,1);
      i2=list3(i,2);
       vxL2=vxL2+w(i+Ms)^2*2*PI^2*i1^2*ialpha;
      vyL2=vyL2+2*PI^2*i2^2/alpha*w(i+Ms)^2;
      DvxL2=DvxL2+(i1^2*ialpha^2+i2^2)^2*w(i+Ms)^2*2*PI^2*i1^2*ialpha;
      DvyL2=DvyL2+(i1^2*ialpha^2+i2^2)^2*w(i+Ms)^2*2*PI^2*i2^2/ialpha;
  end
  vxL2=sqrt(vxL2);
  vyL2=sqrt(vyL2);
  DvxL2=sqrt(DvxL2);
  DvyL2=sqrt(DvyL2);
  ux=intval('0'); %  u_x
uy=intval('0'); %  u_y
 dux=intval('0'); %  (\trinagle u)_x
duy=intval('0'); %  (\triangle u)_y
for i=1:3/2*N
  i1=list2(i,1);
  i2=list2(i,2);
  ux=ux+i1*ialpha*(-sin(i1*ialpha*x+i2*y))*w(i);
  uy=uy+i2*(-sin(i1*ialpha*x+i2*y))*w(i);
   dux=dux+i1*ialpha*(-sin(i1*ialpha*x+i2*y))*w(i)*(i1^2*ialpha^2+i2^2);
  duy=duy+i2*(-sin(i1*ialpha*x+i2*y))*w(i)*(i1^2*ialpha^2+i2^2);
end
for i=1:3/2*N+1:Ms
    i1=list2(i,1);
    i2=list2(i,2);
    ux=ux-w(i)*(i1*ialpha*(sin(i1*ialpha*x+i2*y)+sin(i1*ialpha*x-i2*y)*(-1)^(floor(i1/2)+i2+1)));
    uy=uy-w(i)*(i2*(sin(i1*ialpha*x+i2*y)-sin(i1*ialpha*x-i2*y)*(-1)^(floor(i1/2)+i2+1)));
    dux=dux-w(i)*(i1*ialpha*(sin(i1*ialpha*x+i2*y)+sin(i1*ialpha*x-i2*y)*(-1)^(floor(i1/2)+i2+1)))*(i1^2*ialpha^2+i2^2);
    duy=duy-w(i)*(i2*(sin(i1*ialpha*x+i2*y)-sin(i1*ialpha*x-i2*y)*(-1)^(floor(i1/2)+i2+1)))*(i1^2*ialpha^2+i2^2);
end
uxinf=sup(abs(ux)); %Linf norm of u_x
uyinf=sup(abs(uy));  %Linf norm of u_y
duxinf=sup(abs(dux)); %Linf norm of \trinagle u_x
duyinf=sup(abs(duy));  %Linf norm of \trinagle u_y
vx=intval('0'); % v_x
vy=intval('0'); % v_y
dvx=intval('0'); % \triangle v_x
dvy=intval('0'); % \triangle v_y
for i=1:N^2/2
    i1=list3(i,1);
    i2=list3(i,2);
    vx=vx-w(i+Ms)*(i1*ialpha*(sin(i1*ialpha*x+i2*y)+sin(i1*ialpha*x-i2*y)*(-1)^(floor(i1/2)+i2)));
    vy=vy-w(i+Ms)*(i2*(sin(i1*alpha*x+i2*y)-sin(i1*alpha*x-i2*y)*(-1)^(floor(i1/2)+i2)));
    dvx=dvx-w(i+Ms)*(i1*ialpha*(sin(i1*ialpha*x+i2*y)+sin(i1*ialpha*x-i2*y)*(-1)^(floor(i1/2)+i2)))*(i1^2*ialpha^2+i2^2);
    dvy=dvy-w(i+Ms)*(i2*(sin(i1*alpha*x+i2*y)-sin(i1*alpha*x-i2*y)*(-1)^(floor(i1/2)+i2)))*(i1^2*ialpha^2+i2^2);
end
for i=N^2/2+1:Ma
    i1=list3(i,1);
    i2=list3(i,2);
    vx=vx-w(i+Ms)*i1*ialpha*sin(i1*ialpha*x+i2*y);
    vy=vy-w(i+Ms)*i2*sin(i1*ialpha*x+i2*y);
    dvx=dvx-w(i+Ms)*i1*ialpha*sin(i1*ialpha*x+i2*y)*(i1^2*ialpha^2+i2^2);
    dvy=dvy-w(i+Ms)*i2*sin(i1*ialpha*x+i2*y)*(i1^2*ialpha^2+i2^2);
end
vxinf=sup(abs(vx)); %Linf norm of v_x
vyinf=sup(abs(vy)); %Linf norm of v_y
dvxinf=sup(abs(dvx)); %Linf norm of \triangle v_x
dvyinf=sup(abs(dvy)); %Linf norm of \triangle v_y
duytheta1L2=intval(zeros(Ms,1));%L2-norm of (I-P_N)((triangle u)_y*Theta_1(j))
duxtheta1L2=intval(zeros(Ms,1));%L2-norm of (I-P_N)((triangle u)_x*Theta_1(j))
uxtheta1L2=intval(zeros(Ms,1));%L2-norm of (I-P_N)(( u)_x*Theta_1(j))
uytheta1L2=intval(zeros(Ms,1));%L2-norm of (I-P_N)(( u)_y*Theta_1(j))
duytheta2L2=intval(zeros(Ma,1));%L2-norm of (I-P_N)((triangle u)_y*Theta_2(j))
duxtheta2L2=intval(zeros(Ma,1));%L2-norm of (I-P_N)((triangle u)_x*Theta_2(j))
uxtheta2L2=intval(zeros(Ma,1));%L2-norm of (I-P_N)((  u)_x*Theta_2(j))
uytheta2L2=intval(zeros(Ma,1));%L2-norm of (I-P_N)((  u)_y*Theta_2(j))
dvytheta2L2=intval(zeros(Ma,1));%L2-norm of (I-P_N)((triangle v)_y*Theta_2(j))
dvxtheta2L2=intval(zeros(Ma,1));%L2-norm of (I-P_N)((triangle v)_x*Theta_2(j))
vxtheta2L2=intval(zeros(Ma,1));%L2-norm of (I-P_N)(( v)_x*Theta_2(j))
vytheta2L2=intval(zeros(Ma,1));%L2-norm of (I-P_N)((v)_y*Theta_2(j))
 for j=1:Ms   
j1=list2(j,1);
j2=list2(j,2);
tj=ss(j);
[duytheta1L2(j),duxtheta1L2(j),uxtheta1L2(j),uytheta1L2(j)]=PTheta1(Ms,N,iPhi,L1,L2,ialpha,j1,j2,ss,list2,tj,PI);
 end
for j=1:Ma  
    j1=list3(j,1);
    j2=list3(j,2);
    tj=sa(j); 
  [duytheta2L2(j),duxtheta2L2(j),uxtheta2L2(j),uytheta2L2(j)]=Ptheta2(Ms,N,iPhi,L1,L2,ialpha,j1,j2,ss,list2,tj,PI);
  [dvytheta2L2(j),dvxtheta2L2(j),vxtheta2L2(j),vytheta2L2(j)]=Pstheta2(Ma,N,iPsi,K1,K2,ialpha,j1,j2,sa,list3,tj,PI);
end 