phi[1][x_,y_]:=If[x+y<1,1-x-y,0]

phi[2][x_,y_]:=If[x+y<1,x,1-y]

phi[3][x_,y_]:=If[x+y<1,y,1-x]

phi[4][x_,y_]:=If[x+y<1,0,x+y-1]

Table[Plot3D[phi[i][x,y],{x,0,1},{y,0,1}],{i,1,4}]

(M0=Table[Integrate[Integrate[phi[i][x,y]phi[j][x,y],{y,0,1}],{x,0,1}],{i,1,4},{j,1,4}])//MatrixForm

(M=Table[If[i<5&&j<5,M0[[i,j]],0]+If[i>4&&j>4,M0[[i-4,j-4]],0],{i,1,8},{j,1,8}])//MatrixForm

(K=Table[Integrate[Integrate[D[phi[i][x,y],x]D[phi[j][x,y],x]+D[phi[i][x,y],y]D[phi[j][x,y],y],{y,0,1}],{x,0,1}],{i,1,4},{j,1,4}])//MatrixForm

(D0=Table[Integrate[Integrate[D[phi[i][x,y],x]phi[j][x,y],{y,0,1}],{x,0,1}],{i,1,4},{j,1,4}])//MatrixForm

(D1=Table[Integrate[Integrate[ D[phi[i][x,y],y]phi[j][x,y],{y,0,1}],{x,0,1}],{i,1,4},{j,1,4}])//MatrixForm

(DD=Table[If[j<5,D0[[i,j]],0]+If[j>4,D1[[i,j-4]],0],{i,1,4},{j,1,8}])//MatrixForm

DD.Inverse[M].Transpose[DD]

K

(****)

phi[1][x_,y_]:=If[x+y<1,1-x-y,0]

phi[2][x_,y_]:=If[x+y<1,x,1-y]

phi[3][x_,y_]:=If[x+y<1,y,1-x]

phi[4][x_,y_]:=If[x+y<1,0,x+y-1]

Table[Plot3D[phi[i][x,y],{x,0,1},{y,0,1}],{i,1,4}]

psi[1][x_,y_]:=If[x+y<1,1,0]

psi[2][x_,y_]:=If[x+y<1,0,1]

Table[Plot3D[psi[i][x,y],{x,0,1},{y,0,1}],{i,1,2}]

(M0=Table[Integrate[Integrate[psi[i][x,y]psi[j][x,y],{y,0,1}],{x,0,1}],{i,1,2},{j,1,2}])//MatrixForm

(M=Table[If[i<3&&j<3,M0[[i,j]],0]+If[i>2&&j>2,M0[[i-2,j-2]],0],{i,1,4},{j,1,4}])//MatrixForm

(K=Table[Integrate[Integrate[D[phi[i][x,y],x]D[phi[j][x,y],x]+D[phi[i][x,y],y]D[phi[j][x,y],y],{y,0,1}],{x,0,1}],{i,1,4},{j,1,4}])//MatrixForm

(D0=Table[Integrate[Integrate[D[phi[i][x,y],x]psi[j][x,y],{y,0,1}],{x,0,1}],{i,1,4},{j,1,2}])//MatrixForm

(D1=Table[Integrate[Integrate[ D[phi[i][x,y],y]psi[j][x,y],{y,0,1}],{x,0,1}],{i,1,4},{j,1,2}])//MatrixForm

(DD=Table[If[j<3,D0[[i,j]],0]+If[j>2,D1[[i,j-2]],0],{i,1,4},{j,1,4}])//MatrixForm

DD.Inverse[M].Transpose[DD]

K