Académique Documents
Professionnel Documents
Culture Documents
MÉTODOS NUMÉRICOS
DEBER 3
AUTORES
Carlos Vega
Dennys Peña
Roberto Rivera
PROFESOR
NRC:1121
AULA:G205
Sangolqui-Pichincha
Problema 1
Desarrolle un algoritmo que permita determinar la transpuesta de una matriz.
CÓDIGO EN OCTAVE
function Tr = trans(A)
%Peña, Vega, Rivera
%Tr=trans([2 -1; -2 0; 3 2])
[n,m]=size(A);
i=1;
j=1;
A
while (i<=n || j<=m)
B(:,i)=A(j,:)’;
i=i+1;
j=j+1;
endwhile
Tr=B;
endfunction
Problema 2
Desarrolle un algoritmo que permita determinar el producto escalar de 2 matrices.
CÓDIGO EN OCTAVE
function P = ProdEs(A,B)
%Peña, Vega, Rivera
%P= ProdEs([1 2 8; 4 -3 6],[2 3 4; 6 7 8])
[n,m]=size(A);
[p,q]=size(B);
if m˜=p
disp ’No se puede realizar el producto’;
P=0;
return
endif
A
B
for i=1:1:n
2
for j=1:1:q
P(i,j)=dot(A(i,:),B(:,j)’);
endfor
endfor
endfunction
Problema 3
Desarrolle un código que calcule la norma de un vector.
CÓDIGO EN OCTAVE
function N = norma(V)
%Peña, Vega, Rivera
%N = norma([1 2 2 4 5])
V
[n,n]=size(V);
s=0;
for i=1:1:n
s=V(i)ˆ2+s;
endfor
N=sqrt(s);
endfunction
3
Problema 4
Construya un código que determine la traza de una matriz.
CÓDIGO EN OCTAVE
function T = traza(A)
%Peña, Vega, Rivera
%T=traza([4 2 3; 4 12 6; 7 3 9])
[n,n]=size(A);
i=1;
j=1;
T=0;
A
while (i<=n && j<=n)
T=A(i,j)+T;
i=i+1;
j=j+1;
endwhile
endfunction
Problema 5
Construya un código que determine si una matriz es estrictamente dominante por filas
CÓDIGO EN OCTAVE
function DomF(A)
%Peña, Vega, Rivera
%DomF([4 -1 2; -1 5 3; 4 -2 -7])
A
[n,n]=size(A);
c=1;
for i=1:1:n
s=0;
for j=1:1:n
s=abs(A(i,j))+s;
endfor
s=s-abs(A(i,i));
if (s<abs(A(i,i)) && c==1)
c=1;
else
c=0;
4
endif
endfor
if c==1
disp ’Matriz diagonal dominante por Filas’;
else
disp ’Matriz NO dominante’;
endif
endfunction
Problema 6
5 2 1
−1 0 3
−3 1 6
Para U:
5 2 1
−1 0 3
−3 1 6
1
F2 + F1
5
3
F3 + F1
5
5 2 1
2 16
0
5 5
11 33
0 5 5
F2 ↔ F3
5 2 1
11 33
0
5 5
2 16
0 5 5
2
F3 − F2
11
5 2 1
11 33
0 =U
5 5
0 0 2
5
Para L:
1 0 0
I3 = 0 1 0
0 0 1
1 0 0
1
L1 = − 5 1 0
− 35 0 1
1 0 0
3
L2 = − 5 1 0
− 15 0 1
1 0 0
3
L3 = − 5 1 0=L
− 15 2
11
1
Para p:
1 0 0
0 1 0
I3 =
0 0 1
1 0 0
p1 = 0 0 1 = p
0 1 0
Problema 7
2 3 1
4 −1 −2
5 3 2
Para U:
2 3 1
4 −1 −2
5 3 2
F1 ↔ F3
5 3 2
4 −1 −2
2 3 1
4
F2 − F1
5
2
F3 − F1
5
5 3 2
17 18
0 − 5 − 5
0 95 1
5
6
9
F3 + F2
17
5 3 2
17 18
0 − 5 − 5 = U
0 0 − 2917
Para L:
1 0 0
I3 = 0 1 0
0 0 1
1 0 0
4
L1 = 5 1 0
2
5
0 1
1 0 0
4
L2 =
5 1 0 =L
2 9
5
− 17 1
Para p:
1 0 0
0 1 0
I3 =
0 0 1
0 0 1
p1 = 0 1 0 = p
1 0 0
Problema 8
−5 1 −2
3 5 −2
1 2 −5
Para U:
−5 1 −2
3 5 −2
1 2 −5
3
F2 + F1
5
1
F3 + F1
5
−5 1 −2
28
0
5
− 16
5
11
0 5
− 27
5
11
F3 − F2
28
7
−5 1 −2
28
0
5
− 16
5
=U
29
0 0 −5
Para L:
1 0 0
I3 = 0 1 0
0 0 1
1 0 0
3
− 5 1 0
L1 =
− 15 0 1
1 0 0
3
L2 = − 5 1 0=L
− 15 11
28
1
Para p:
1 0 0
I3 = 0 1 0
0 0 1
1 0 0
p1 = 0 1 0 = p
0 0 1
Problema 9
2 1 0 4
3 1 −4 2
5 −3 4 2
3 −1 0 4
Para U:
2 1 0 4
3 1 −4 2
5 −3 4 2
3 −1 0 4
F1 ↔ F3
5 −3 4 2
3 1 −4 2
2 1 0 4
3 −1 0 4
3
F2 − F1
5
2
F3 − F1
5
3
F4 − F1
5
8
5 −3 4 2
0 14 − 32 4
5 5 5
0 11 8 16
−5 5
5
0 5 − 12
4
5
14
5
11
F3 − F2
14
4
F4 − F2
14
5 −3 4 2
0 14 − 32 4
5 5 5
0 0
24 18
7 7
4 18
0 0 −5 7
4
F4 + F2
24
5 −3 4 2
0 14 − 32 4
5 5 5 =U
0 0
24 18
7 7
0 0 0 3
Para L:
1 0 0 0
0 1 0 0
I4 =
0 0 1 0
0 0 0 1
1 0 0 0
3 1 0 0
L1 = 52
5 0 1 0
3
5
0 0 1
1 0 0 0
3 1 0 0
52
L2 =
11
1 0
5 14
3 4
5 14
0 1
1 0 0 0
3 1 0 0
L3 = 52 =L
11
5 14
1 0
3 4 4
5 14
− 14 1
Para p:
1 0 0 0
0 1 0 0
I4 =
0 0 1 0
0 0 0 1
0 0 1 0
0 1 0 0
p1 = =p
1 0 0 0
0 0 0 1
9
Halle la solución de los siguientes sistemas lineales, utilizando la factorización LU
Problema 10
x1 + 2x2 = 7
2x1 + 3x2 − x3 = 9
4x2 + 2x3 + 3x4 = 10
2x3 − 4x4 = 12
Solución:
1 2 0 0 7
2 3 −1 0
9
A= ,B=
0 4 2 3 10
0 0 2 −4 12
2 3 −1 0
0 4 2 3
⇒U =
0 0 2 −4
1
0 0 0
8
Para L
10
1 0 0 0 1 0 0 0 1 0 0 0
1
0 1 0 0 1 0 0 0 1 0 0
2
I=
⇒ L1 =
;
⇒ L2 =
1 ;
0 0 1 0 0 0 1 0 0 1 0
2
0 0 0 1 0 0 0 1 0 0 0 1
1 0 0 0 1 0 0 0 1 0 0 0
0 1 0 0 0 1 0 0 0 1 0 0
⇒ L3 = ; ⇒ L4 = ; ⇒ L5 = ;
1 1
1 0 0 0 1 0 0 0 1 0
2 8
1 1 1 1 1
0 0 0 1 0 1 1
2 8 2 8 8
1 0 0 0
0 1 0 0
⇒L=
0 0 1 0
1 1 1
1
2 8 8
0 1 0 0
0 0 1 0
⇒P =
0 0 0 1
1 0 0 0
Resolviendo:
L∗y =P ∗b
11
1 0 0 0 y1 0 1 0 0 7
0 1 0 0 y2 0 0 1 0 9
∗ = ∗
0 0 1 0 y3 0 0 0 1 10
1 1 1
1 y4 1 0 0 0 12
2 8 8
−1
y1 1 0 0 0 0 1 0 0 7
y2 0 1 0 0 0 0 1 0 9
= ∗
y3 0 0 1 0 0 0 0 1 10
1 1 1
y4 1 1 0 0 0 12
2 8 8
y1 1 0 0 0 0 1 0 0 7
y2 0 1 0 0 0 0 1 0 9
= ∗
y3 0 0 1 0 0 0 0 1 10
1
y4 − 2 − 18 − 18 1 1 0 0 0 12
y1 = 9
y2 = 10
y3 = 12
y4 = − 81
U ∗x=y
2 3 −1 0 x1 9
0 4 2 3 x2 10
* =
0 0 2 −4 x3 12
1 1
0 0 0 x4 − 8
8
12
−1
x1 2 3 −1 0 9
x2 0 4 2 3 10
= *
x3 0 0 2 −4 12
1 1
x4 0 0 0 − 8
8
x2 = 3
x3 = 2
x4 = −2
Problema 11
x1 + 20x2 − x3 + 0, 001x4 = 0
2x1 − 5x2 + 30x3 − 0, 1x4 = 1
5x1 + x2 − 100x3 − 10x4 = 0
2x1 − 100x2 − x3 + x4 = 0
Solución:
1
1 20 −1 1000
0
1
−5 − 10
2 30 1
A= ,B=
5 1 −100 −10 0
2 −100 −1 1 0
13
5 1 −100 −10 5 1 −100 −10
− 502 − 502
0 39 5 0 39 5
5 5
99 27
F2 ↔ F4
99
2001 ; F3 + 502
F2 F4 − 502
F2 =
13399
749751 ;
0 19 0 0
5 1000 502 251000
0 − 27 70 39
0 0 34087 4557
5 10 502 1255
5 1 −100 −10 5 1 −100 −10
− 502 − 502
0 39 5 0 39 5
5 5
13399
F3 ↔ F4
34087 4557
; F4 − 34087
F3 =
34087 4557
0 0 0 0
502 1255 502 1255
13399 749751 53166987
0 0 0 0 0
502 251000 34087000
5 1 −100 −10
− 502
0 39 5
5
⇒U =
0 34087 4557
0
502 1255
53166987
0 0 0
34087000
Para L
1 0 0 0 1 0 0 0 1 0 0 0
2 2
0 1 0 0 1 0 0 1 0 0
5 5
I=
⇒ L1 =
1 ;
⇒ L2 =
1 ;
0 0 1 0 0 1 0 0 1 0
5 5
2 2
0 0 0 1 0 0 1 0 0 1
5 5
1 0 0 0 1 0 0 0 1 0 0 0
2 2 2
5 1 0 0
5 1 0 0
5 1 0 0
⇒ L3 =
1 99 ;
⇒ L4 =
2 27 ;
⇒ L5 =
2 27 ;
5 − 502 1 0
5 502
1 0
5 502
1 0
2 27 1 99 1 99 13399
0 1 − 502 0 1 − 502 1
5 502 5 5 34087
14
1 0 0 0
2
5 1 0 0
⇒L=
2 27
1 0
5 502
1 99 13399
− 502 1
5 34087
0 0 1 0
0 0 0 1
⇒P =
0 1 0 0
1 0 0 0
Resolviendo:
L∗y =P ∗b
1 0 0 0 y1 0 0 1 0 0
2
5 1 0 0
y2
0
0 0 1
1
∗ = ∗
2 27
1 0 y3 0 1 0 0 0
5 502
1 99 13399
− 502 1 y4 1 0 0 0 0
5 34087
−1
y1 1 0 0 0 0 0 1 0 0
2
y2
5 1 0 0
0
0 0 1
1
= ∗
2 27
y3 1 0 0 1 0 0 0
5 502
1 99 13399
y4 − 502 1 1 0 0 0 0
5 34087
15
y1 1 0 0 0 0 0 1 0 0
−2
y2
5
1 0 0
0
0 0 1
1
= ∗
y3 − 95 27
− 502 1 0 0 1 0 0 0
251
4435 7443
y4 − 34087 − 93335 1 1 0 0 0 0
34087 34087
y1 = 0
y2 = 0
y3 = 1
13399
y4 = − 34087
U ∗x=y
x1 0
5 1 −100 −10
x2 0
− 502
0 39 5
5
* =
x3 1
0 34087 4557
0 502
1255
13399
x4 − 34087
53166987
0 0 0 34087000
x1 −1 0
5 1 −100 −10
x2 0
− 502
0 39 5
5
= *
x3 1
0 34087 4557
0 502
1255
13399
x4 − 34087
53166987
0 0 0 34087000
84805
x2 = − 53166987
499834
x3 = 17722329
x4 = − 13399000
53166987
16