clear all
close all

LN=[10:20:130];
method=2;
u=@(x,y) cos(pi*(x-y));
f=@(x,y) 2*pi^2*cos(pi*(x - y));
gD=@(x,y) u(x,y);

NormH1=@(M,K,U) sqrt(dot(M*U,U)+dot(K*U,U));
NormL2=@(M,U) sqrt(dot(M*U,U));

k=1;
for N=LN
  [Th,U,M,K]=ep07.solveP1(f,gD,N,'method',method);
  H(k)=Th.get_h();
  Uex=siMesh.eval(Th,u);
  EL2(k)=NormL2(M,U-Uex)/NormL2(M,Uex); % erreur relative L2
  EH1(k)=NormH1(M,K,U-Uex)/NormH1(M,K,Uex); % erreur relative H1
  k=k+1;
end

figure(1)
loglog(H,EL2,'r',H,EH1,'b',H,H,'kd-',H,H.^2,'ks-')
xlabel('h')
legend('Erreur L2','Erreur H1','O(h)','O(h^2)')
% figure a ameliorer
