Programmes Matlab
Méthode de Kozlov-Maz’ya
%(* ::Package:: *) function [er2]= kozlovmazya(N,epsi,it,c1) N=0;epsi=10ˆ(-3);it=4;c1=0.6; x=linspace(0,1,N+1); h=1/(N+1); f1=sin(pi*x’); g=(1/piˆ(4))*(1-(1+piˆ(2))*exp(-piˆ(2)))*(sin(pi*x’)); gn=g+epsi*randn(size(g)); g=gn; A=(1/hˆ2)*(diag(2*ones((N-1),1))-diag(ones(N-2,1),1)-diag(ones(N-2,1),-1)); K=Aˆ(-2)*(eye(N-1)-((eye(N-1)+A)*expm(-(A)))); c=4*((N+1)*(sin(pi/(2*(N+1)))))ˆ2; gamma=c1*(cˆ2/(1 -(1+c)*exp(-c))); gamma, f(:,1)=zeros(N+1,1); for k=2:it F=(eye(N-1)-gamma*K)*f(2:N,k-1); f(:,k)=[0;F;0]+gamma*g; end er2=(norm(f1-f(:,it),2))/norm(f1,2); er2, plot(x,f1,’r’,x,f(:,it),’b*–’) grid legend(’sol. approch\[EAcute]e’, ’sol. exacte’)
Méthode de Troncature spectrale
function [er1, er2,fa1,fa2 ] = Methode_troncature(M,N,epsi,f1,f2,g1,g2) M=20; N=4; epsi=10ˆ-2;h=1/M; x=0:h:1; f1=(piˆ2)*sin(pi*x); f2=(piˆ2)*sin(2*pi*x); g1=(1/3)*(2-3.*exp(-2.*piˆ2)).*sin(pi.*x)+(1/12).*(-1+3.*exp(-8.*piˆ2)-2.*exp(-12.*piˆ2)).*sin(2.*pi*x);g2=(1/6)*(1-3*exp(-2*piˆ2)+2*exp(-3*piˆ2))*sin(pi*x)+(1/24)*(1+3*exp(-8*piˆ2)-4*exp(-12*piˆ2))*sin(2*pi*x); g1n=g1+epsi*randn(size(g1)); g2n=g2+epsi*randn(size(g2)); g1=g1n; g2=g2n; S2=0; for n=1:N a2n= (2*(nˆ2)*(piˆ2))/ (1-exp(-2*(nˆ2)*(piˆ2))); a3n=(3*(nˆ2)*(piˆ2))/(1-exp(-3*(nˆ2)*(piˆ2))); S1=g1.*sin(n*pi*x); S1=sum(S1); S2=S2+(2*a2n-a3n)*S1*sin(n*pi*x); end S4=0; for n=1:N a2n=(2*(nˆ2)*(piˆ2))/ (1-exp(-2*(nˆ2)*(piˆ2))); a3n=(3*(nˆ2)*(piˆ2))/(1-exp(-3*(nˆ2)*(piˆ2))); S3=g2.*sin(n*pi*x); S3=sum(S3); S4=S4+((-2)*a2n+(2)*a3n)*S3*sin(n*pi*x); end fa1=2*h*(S2+S4); er1=(norm(f1-fa1,2))/norm(f1,2); l2=0; for n=1:N; a2n= (2*(nˆ2)*(piˆ2))/ (1-exp(-2*(nˆ2)*(piˆ2))); a3n=(3*(nˆ2)*(piˆ2))/(1-exp(-3*(nˆ2)*(piˆ2))); l1=g1.*sin(n*pi*x); l1=sum(l1); l2=l2+(a2n-a3n)*l1*sin(n*pi*x); end l4=0; for n=1:N; a2n=(2*(nˆ2)*(piˆ2))/ (1-exp(-2*(nˆ2)*(piˆ2))); a3n=(3*(nˆ2)*(piˆ2))/(1-exp(-3*(nˆ2)*(piˆ2))); l3=g2.*sin(n*pi*x); l3=sum(l3); l4=l4+((-1)*a2n+(2)*a3n)*l3*sin(n*pi*x); end
Exemple2
function y=funct_cre1(t) if t>=0 && t<=1/4 y=0; else if t>=1/4 && t<=1/2 y=((4)*t-1); else if t>=1/2 && t<=3/4 y=(3-(4)*t); else y=0; end end end function y=funct_cre2(t) if t>=0 && t<=1/5 y=0; else if t>=1/5 && t<=2/5 y=5*t-1; else if t>=2/5 && t<=3/5 y=-5*t+3; else y=0; end end end