Méthode de relaxation

C.Delaere

la matrice du problème

h=15;
Clear[f];
f[i_,j_]:=100/; ((i==1)&&(j<=h))
f[i_,j_]:=0/;((i>1)||(j>h))
probleme = Table[f[i,j],{i,1,h},{j,1,2*h-1}];
MatrixForm[N[probleme]];
Plot3D[probleme[[Round[i]]][[Round[j]]],{i,1,h},{j,1,2*h-1}]

formules pour l'iteration

Clear[next];
next1[i_,j_]:=probleme[[i]][[j]] /;((i==1)||(j==1)||
                                   (j==(2*h-1))||(i==h))
next1[i_,j_]:=1/4*(probleme[[i+1]][[j]]+
                  probleme[[i]][[j+1]]+
                  probleme[[i-1]][[j]]+
                  probleme[[i]][[j-1]]) /;((i>1)&&(j>1)&&(j<(2*h-1))&&(i<h))

Clear[next2];
next2[i_,j_]:=next1[i,3] /;(j==1)
next2[i_,j_]:=next1[j-h+1,i+h-1] /;(j>=(h+i))
next2[i_,j_]:=next1[i,j] /; ((j>1)&&(i<(h+j)))

iteration

maxiter=100;
Clear[monitor];
monitor={};
Do[
probleme = Table[next2[i,j],{i,1,h},{j,1,2*h-1}];
monitor = Append[monitor,N[probleme[[3]][[7]]]]
,{k,0,maxiter}]
MatrixForm[N[probleme]];
Plot3D[probleme[[Round[i]]][[Round[j]]],{i,1,h},{j,1,2*h-1}]

affichage de la convergence pour un point

Plot[monitor[[Round[n]]],{n,1,maxiter}]