You are on page 1of 10

METODO NUMERICO 1 IMF

UNIVERSIDAD NACIONAL MAYOR DE SAN MARCOS


(Universidad del Perú, DECANA DE AMÉRICA)

ESCUELA DE INGENIERIA MECANICA DE FLUIDOS

FACULTAD DE CIENCIAS FISICAS

INGENIERO: WILLIAM WILFREDO CHAUCA NOLASCO

CURSO: METODOS NUMERICOS I

ALUMNO: GALLARDO INCA ARACELI LUCERO

TEMA: Sistemas de expresiones algebraicas

2019

pág. 1
METODO NUMERICO 1 IMF

Sistemas de expresiones algebraicas


Existen dos formas para encontrar la S.E.L

 Eliminacionde gauss
simple
 Gaus jordan
 Descomposicion lu
 Do olitle
 Cholesky
a) METODOS DIRECTOS

Gauss soidel
b) METODOS DIRECTOS jacobi

a) METODO DIRECTO –ELIMINACION GAUSS


𝑎1 𝑥 + 𝑏1 𝑦 + 𝑐1 𝑧 = 𝑑1
𝑎2 𝑥 + 𝑏2 𝑦 + 𝑐2 𝑧 = 𝑑2
𝑎3 𝑥 + 𝑏3 𝑦 + 𝑐3 𝑧 = 𝑑3

𝑎1 𝑏1 𝑐1 𝑑1
[𝑎2 𝑏2 𝑐2 𝑑2]
𝑎3 𝑏3 𝑐3 𝑑3
Diagonal principal
NOTA:
Gauss jordan busca que la matriz de coeficiente sea una matriz
identidad

1 0 0 𝑑1
[0 1 0 𝑑2] transformado
0 0 1 𝑑3

pág. 2
METODO NUMERICO 1 IMF

Ejemplo:
Resolver el S.E.L.

2𝑥 − 𝑦 + 3𝑧 = 5
2𝑥 + 2𝑦 + 3𝑧 = 5
−2𝑥 + 3𝑦 + 0𝑧 = −3

Solucionn
2 −1 3 5
[2 2 3 7 ]
−2 3 0 −3

A la fila 1 lo dividimos entre 2

1 3 5
1 −
2 2 2
[2 2 3 7 ] se necesita que el primer
−2 3 0 −3
elemento de la 2 fila sea cero

Al primer elemento de la fila 1 lo multiplique por (-2) y


hacemos la operación: fila (2) + fila (1)

2 + (1)(−2) = 2 − 2 = 0
1
2 + (− )(−2) = 2 + 1 = 3
2
3
3 + ( ) (−2) = 3 − 3 = 0
2
5
3 + ( ) (−2) = 7 − 5 = 2
2

Para el primer elemento de la fila 3 hacerce cero por lo que el


primer elemento de la primera fila lo multiplicamos por(+2)
La operación: fila 3 + la fila 1

−2 + (1)(2) = −2 + 2 = 0
1
3 + (− ) (2) = 3 − 1 = 2
2
3
0 + ( ) (2) = 0 − 3 = 3
2
5
−3 + ( ) (2) = −3 + 5 = 2
2

pág. 3
METODO NUMERICO 1 IMF

La matriz queda:

1 3 5
1 −
[ 2 2 2]
0 3 0 2
0 2 3 2

El segundo elemento de la fila 2 debe de ser 1, por lo tanto la


vamos a dividir ÷3

1 3 5
1 −
2 2 2
2
0 1 0
3
[0 3 3 2]

Al segundo elemento de la fila 2 le ultiplicamos por(-2)


La operación es fila 3+fila 2
0 + 0(−2) = 0
2 + 1(−2) = 0
3 + 0(−2) = 3
2 4 2
3 + ( ) (−2) = 2 − =
3 3 3

1 3 5
1 −
2 2 2
2
0 1 0
3
2
[0 0 3
3]

Ala fila 3 la dividimos÷3

pág. 4
METODO NUMERICO 1 IMF

1 3 5
1 −
2 2 2
2
0 1 0
3
2
[0 0 1
9]

Tarea 1
Resolver el ejemplo de clare por gauss jordan
Por Matlab

 Programa
clear all
clc
disp(' GAUSS SIMPLE ')
format
a=input('ingrese matriz a: '); %[2 -1 3;2 2 3;-2 3 0]
b=input('ingrese matriz b: '); %[5 7 -3]
n=length(b);
u=1;
for k=1:n-1
for i=k+1:n
f(u)=a(i,k)/a(k,k);
for j=1:n
a(i,j)=a(i,j)-f(u)*a(k,j);
end
b(i)=b(i)-f(u)*b(k);
u=u+1;
end
end
x(n)=b(n)/a(n,n);
for i=n-1:-1:1
sum=0;
for j=i+1:n
sum=sum+a(i,j)*x(j);
end
x(i)=(b(i)-sum)/a(i,i);
end
disp('los incognitas son ')
fprintf('\n')
disp(x)

 Resultado

pág. 5
METODO NUMERICO 1 IMF

Tarea 2
Elaborar un programa que resuelva el ejemplo por eliminación de
gauss simple
Por matlab

 Funcion gaus
function [x]=gauss(a,b,tol)
%[x]=gauss([2 -1 3;2 2 3;-2 3 0],[5 7 -3],0.0001)
er=0;
n=length(b);
s=zeros(1,n);
for i=1:n
s(i)=abs(a(i,1));
for j=2:n
if abs(a(i,j))>s(i)
s(i)=abs(a(i,j));
end
end
end
[a,b,er,f]=eliminacion(a,b,n,tol,s,er);
if er~=-1
x=sustitucion(a,b,n);
end
end

 Funcion Eliminacion
function [a,b,er,f]=eliminacion(a,b,n,tol,s,er)
u=1;
for k=1:n-1
[a,b]=pivot(a,b,n,s,k);
if abs(a(k,k)/s(k))<tol
er=-1;
break
end
for i=k+1:n
f(u)=a(i,k)/a(k,k);
for j=1:n
a(i,j)=a(i,j)-f(u)*a(k,j);
end
b(i)=b(i)-f(u)*b(k);
u=u+1;
end
end

pág. 6
METODO NUMERICO 1 IMF

if abs(a(n,n)/s(n))<tol
er=-1;
end
end

 Funcion pivot
function [a,b]=pivot(a,b,n,s,k)
p=k;
big=abs(a(k,k)/s(k));
for z=k+1:n
t=abs(a(z,k)/s(z));
if t>big
big=t;
p=z;
end
end
if p~=k
for w=k:n
t=a(p,w);
a(p,w)=a(k,w);
a(k,w)=t;
end
t=b(p);
b(p)=b(k);
b(k)=t;
t=s(p);
s(p)=s(k);
s(k)=t;
end
end

 funcion sustitucion
function x=sustitucion(a,b,n)
x(n)=b(n)/a(n,n);
for i=n-1:-1:1
sum=0;
for j=i+1:n
sum=sum+a(i,j)*x(j);
end
x(i)=(b(i)-sum)/a(i,i);
end
end

 Resultado

pág. 7
METODO NUMERICO 1 IMF

METODO DE GAUSS SEIDEL (método iterativo)


Este método se basa en el criterio de recuperación, el cual debe
converger a una solución en el S.E.L.
Una primera aproximación o solución del S.E.L, es considerar un
vector inicial de ceros si es que no se conoce la solución, también
debemos tener en cuenta el error permisible para cada incógnita a
medida que va encontrando su solución
10𝑥 + 0𝑦 − 𝑧 = −1 1
4𝑥 + 12𝑦 − 4𝑧 = 8 2
4𝑥 + 4𝑦 + 10𝑧 = 4 3
 Cumple con el criterio de diagonal dominante
En 1 despejamos la incógnita x
−1+𝑧
𝑥= ……… 1a
10

En 2 despejamos la incógnita y
8−4𝑥+4𝑧
𝑦= ......2b
12

En 3 despejamos la incógnita z
4−4𝑥−4𝑦
𝑧= ……..3c
10

𝑘
−1 + 𝑧 𝑘−1
𝑥 =
10

pág. 8
METODO NUMERICO 1 IMF

𝑘
8 − 4𝑥 𝑘−1 + 4𝑧 𝑘−1
𝑦 =
12

𝑘
4 − 4𝑥 𝑘−1 − 4𝑦 𝑘−1
𝑧 =
10
𝑘 =1,2,3,4,5,….
Para 𝑘 =1

1
−1 + 𝑧 0
𝑥 =
10

1
8 − 4𝑥 0 + 4𝑧 0
𝑦 =
12

1
4 − 4𝑥 0 − 4𝑦 0
𝑧 =
10
Vector inicial [x0 y0 z0 ]
PRIMERA ITERACION
−1 + 0
𝑥= = −0.1
10

8 − 4(−0.1) + 4(0)
𝑦= = 0.7
12

4 − 4(−0.1) − 4(0.7)
𝑧= = 0.16
10
SEGUNDA ITERACION

−1 + (0.6)
𝑥= = −0.084
10
8 − 4(−0.084) + 4(0.16)
𝑦= = 0.748
12
4 − 4(−0.084) − 4(0.718)
𝑧= = 0.1344
10

pág. 9
METODO NUMERICO 1 IMF

ERROR DE X
−0.084 − (−0.1)
𝐸a𝑥 = | | × 100 = 19.0
−0.084

0.748 − 0.7
𝐸a𝑦 = | | × 100 = 69
0.748

−0.1344 − 0.16
𝐸a𝑧 = | | × 100 = 19
0.1344
Tarea 3
Presentar un programa que resuelva el método de gauss seidel con
aplicación de ejemplo de la clase
Por matlab

 Funcion
function y=GaussSeidel(A,b,x,NumIters)
%y=GaussSeidel([20 0 -1;4 12 -4;4 4 10],[-1 8 4],[0 0 0],1)
D=diag(A);
A=A-diag(D);
D=1./D;
n=length(x);
x=x(:);
y=zeros(n,NumIters);
for j=1:NumIters
for k=1:n
x(k)=(b(k)-A(k,:)*x)*D(k);
end
y(:,j)=x;
end

 Resultado

pág. 10

You might also like