Anul 3 Semestrul 2
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
n=7;
|
||||
|
||||
A=5*eye(n) -diag(ones(1,n-1),1)- diag(ones(1,n-1),-1);
|
||||
|
||||
b = [4,3* ones(1,n-2),4]';
|
||||
|
||||
|
||||
x0 = zeros(size(b));
|
||||
|
||||
[x, nit] = jacobi(A,b, x0,10^(-5), 1000);
|
||||
|
||||
[x, nit] = gaussseidel(A,b, x0,10^(-5), 1000);
|
||||
|
||||
A = [10 7 8 7; 7 5 6 5; 8 6 10 9; 7 5 9 10];
|
||||
b=[32;23;33;31];
|
||||
|
||||
x = A^-1*b
|
||||
trueB = b;
|
||||
trueX = x;
|
||||
trueA = A;
|
||||
|
||||
A = [10 7 8 7; 7 5 6 5; 8 6 10 9; 7 5 9 10];
|
||||
|
||||
|
||||
|
||||
b=[32.1;22.9;33.1;30.9];
|
||||
|
||||
x = A^-1*b
|
||||
norm(trueX-x,inf)/norm(trueX,inf)
|
||||
norm(trueB-b,inf)/norm(trueB,inf)
|
||||
cond(A)
|
||||
|
||||
A = [10 7 8.1 7.2; 7.8 5.04 6 5; 8 5.98 9.89 9; 6.99 4.99 9 9.98];
|
||||
b=[32;23;33;31];
|
||||
x = A^-1*b
|
||||
|
||||
cond(A)
|
||||
|
||||
norm(trueX-x,inf)/norm(trueX,inf)
|
||||
norm(trueA-A,inf)/norm(trueA,inf)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user