0% found this document useful (0 votes)
33 views5 pages

1) 4x-4y+2z 1 2x+8y-2z 2 3x - 2y+3z 1: Daniel Encinas Lerma 390 Metodos Numericos - Matlab

The document describes solving systems of linear equations using Gaussian elimination and the Jacobi iterative method in MATLAB. It provides examples of solving 3x3 and 4x4 systems and calculating the convergence rate for the Jacobi method. Solutions are presented for each example problem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views5 pages

1) 4x-4y+2z 1 2x+8y-2z 2 3x - 2y+3z 1: Daniel Encinas Lerma 390 Metodos Numericos - Matlab

The document describes solving systems of linear equations using Gaussian elimination and the Jacobi iterative method in MATLAB. It provides examples of solving 3x3 and 4x4 systems and calculating the convergence rate for the Jacobi method. Solutions are presented for each example problem.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

DANIEL ENCINAS LERMA 390

METODOS NUMERICOS matlab

1)
4x-4y+2z = 1
2x+8y-2z = 2
3x -2y+3z = 1
A= [4, -4, 2 ; 2, 8 , -2 ; 3, -2, 3];
B= [1; 2; 1];
N = rank(A);
for K = 1:N
B(K,1) = B(K,1)/A(K,K);
A(K,:) = A(K,:)/A(K,K);
end
D = eye(N);
L = zeros(N);
U = zeros(N);
A = A-D;
for K = 1:N-1
L(K:N,K) = A(K:N,K);
U(K,K:N) = A(K,K:N);
end
F = -inv(D+L)*U;
Rs = max(abs(eig(F)));
p = 6;
Ni = (p*log(10))/(-log(Rs));
Nm = fix(Ni)+1;
X = zeros(N,Nm);
X(:,1) = ones;
for K = 2:Nm
X(:,K) = F*X(:,K-1) + inv(D+L)*B;
end
X

x=0.3882
y=0.1667
z=0.556

DANIEL ENCINAS LERMA 390

METODOS NUMERICOS matlab

2)
6x-2y+3z+5w = 6
5x+10y-6z+w = 8
3x+y+8z+3w = 3
x+y+z-8w = 1

A= [6, -2, 3, 5 ; 5, 10, -6, 1 ; 3, 1, 8, 3 ; 1, 1, 1,-8 ];


B= [6; 8; 3; 1 ];
N = rank(A);
for K = 1:N
B(K,1) = B(K,1)/A(K,K);
A(K,:) = A(K,:)/A(K,K);
end
D = eye(N);
L = zeros(N);
U = zeros(N);
A = A-D;
for K = 1:N-1
L(K:N,K) = A(K:N,K);
U(K,K:N) = A(K,K:N);
end
F = -inv(D+L)*U;
Rs = max(abs(eig(F)));
p = 6;
Ni = (p*log(10))/(-log(Rs));
Nm = fix(Ni)+1;
X = zeros(N,Nm);
X(:,1) = ones;
for K = 2:Nm
X(:,K) = F*X(:,K-1) + inv(D+L)*B;
end
X

x=1.0727
y=0.2338
z=-0.0442
w=0.0328

DANIEL ENCINAS LERMA 390

METODOS NUMERICOS matlab

matriz inversa
1)
5x+7y = 50
9x+14y = 97

A= [5 7;9 14];
B= [50;97];
i = inv(A);
N = rank(A);
for K = 1:N
B(K,1) = B(K,1)/A(K,K);
A(K,:) = A(K,:)/A(K,K);
end
D = eye(N);
L = zeros(N);
U = zeros(N);
A = A-D;
for K = 1:N-1
L(K:N,K) = A(K:N,K);
U(K,K:N) = A(K,K:N);
end
F = -inv(D+L)*U;
Rs = max(abs(eig(F)));
p = 6;
Ni = (p*log(10))/(-log(Rs));
Nm = fix(Ni)+1;
X = zeros(N,Nm);
X(:,1) = ones;
for K = 2:Nm
X(:,K) = F*X(:,K-1) + inv(D+L)*B;
end
X

x=3 y=5

DANIEL ENCINAS LERMA 390

METODOS NUMERICOS matlab

1)
3x-4y = -6
2x+4y = 16

A= [3, -4; 2, 4];


B= [-6 ; 16];
i = inv(A);
N = rank(A);
for K = 1:N
B(K,1) = B(K,1)/A(K,K);
A(K,:) = A(K,:)/A(K,K);
end
D = eye(N);
L = zeros(N);
U = zeros(N);
A = A-D;
for K = 1:N-1
L(K:N,K) = A(K:N,K);
U(K,K:N) = A(K,K:N);
end
F = -inv(D+L)*U;
Rs = max(abs(eig(F)));
p = 6;
Ni = (p*log(10))/(-log(Rs));
Nm = fix(Ni)+1;
X = zeros(N,Nm);
X(:,1) = ones;
for K = 2:Nm
X(:,K) = F*X(:,K-1) + inv(D+L)*B;
end
X

x=2 y=3

DANIEL ENCINAS LERMA 390

METODOS NUMERICOS matlab

2)
2x-y+3 = -3
x+y+z = 2
3x+2y-z = 8
A= [2, -1, 3; 1, 1, 1; 3, 2, -1];
B= [-3; 2; 8];
i = inv(A);
N = rank(A);
for K = 1:N
B(K,1) = B(K,1)/A(K,K);
A(K,:) = A(K,:)/A(K,K);
end
D = eye(N);
L = zeros(N);
U = zeros(N);
A = A-D;
for K = 1:N-1
L(K:N,K) = A(K:N,K);
U(K,K:N) = A(K,K:N);
end
F = -inv(D+L)*U;
Rs = max(abs(eig(F)));
p = 6;
Ni = (p*log(10))/(-log(Rs));
Nm = fix(Ni)+1;
X = zeros(N,Nm);
X(:,1) = ones;
for K = 2:Nm
X(:,K) = F*X(:,K-1) + inv(D+L)*B;
end
X

x=1 y=2 z=-1

You might also like