Commit 80624d5f authored by E-Girl-Mira's avatar E-Girl-Mira
Browse files

added algo matlab

parent c3867519
A = [1 2 3 4 5 ; 5 1 2 3 4 ; 4 5 1 2 3 ; 3 4 5 1 2 ; 2 3 4 5 1]
Abis = [1 -1 -200 0 ; 0 1 100 -100 ; 0 1 101 -101 ; 0 0 0 100]
b = [1 ; 1 ; 3 ; 4 ; 2]
bbis = [1 ; 1 ; 2 ; 4]
x = [0 ; 0 ; 0 ; 0 ; 0]
xbis = [0 ; 0 ; 0 ; 0]
n = size(b);
delta = 10;
tol = 1e-10;
cont = 0;
while delta > tol & cont < 200
ref = x;
for i = 1:n(1)
tmp = 0;
if j != i
tmp = tmp + A(i,j)*x(j);
end
x(i) = (b(i) - tmp) / A(i,i) ;
end
delta = norm(ref - x);
cont = cont + 1;
end
fprintf('%f\n%f\n%f\n%f\n en %d boucles',x, cont);
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment