Você está na página 1de 12

PARTE II – CON MATLAB

EJERCICIO 1 CON MATLAB x0 =

Dado el sistema de 100


ecuaciones: 200
12 x1 + x2 + 2 x3 − 3 x4 = 56 500
3 x1 + 11 x2 + 4 x3 + x4 = 39 300
2 x1 + x2+ 10 x3− x4 = 42
3x1 − 2 x2 + 2x3 + 8x4 = −21 >> tolerancia=10^(-6)
Obtenga una solución tolerancia =
aproximada usando el método de
Jacobi implementado con MATLAB 1.0000e-06
partiendo del punto inicial
x0 = (100, 200, 500, 300), una
tolerancia de 10−6 y un número >> max=60
máximo de 60 iteraciones.
max =
>> A=[12 1 2 -3;3 11 4 1;2 1
10 -1;3 -2 2 8] 60

A = >> x =
gaussseidel(A,b,x0,tolerancia
12 1 2 -3 ,max)
3 11 4 1
2 1 10 -1 k =
3 -2 2 8 1
x =
>> b=[56 39 42 -21]' -20.3333 -200.0000
58.2667 -59.5667
b =
56
k =
39
2
42
x =
-21
-3.2694 -11.3356
0.0308 -4.2406
>> x0=[100 200 500 300]'
k = k =
3 9
x = x =
4.5460 2.6799 3.0000 2.0000
2.5987 -4.3095 3.0000 -4.0000

k = k =
4 10
x = x =
2.9328 2.1924 3.0000 2.0000
2.9632 -3.9175 3.0000 -4.0000
k = k =
5 11
x = x =
3.0107 2.0029 3.0000 2.0000
3.0058 -4.0047 3.0000 -4.0000

k = x =
6 3.0000
x = 2.0000
2.9976 1.9990 3.0000
3.0001 -3.9994
-4.0000

k =
7
x =
3.0002 1.9998
3.0000 -4.0001

k =
8
x =
3.0000 2.0000
3.0000 -4.0000
EJERCICIO 2 CON MATLAB
Dado el sistema de >> tolerancia=10^(-6)
ecuaciones: tolerancia =
10x1 + 2x2 − x3 + 3x4 = 36 1.0000e-06
2x1 + 11x2 + 3x3 − 3x4 = 56 >> max=60
−x1 + 2x2 + 9x3 + 3x4 = 11 max =
2x1 − 3x2 + x3 + 10x4 = −43 60
Obtenga una solución
aproximada usando el método de
Jacobi implementado con MATLAB >>
partiendo del punto inicial x=jacobi(A,b,x0,tolerancia,ma
x0 = (360, 420, 680, 550), una x)
tolerancia de 10−6 y un número
k =
máximo de 60 iteraciones.
1
>> A=[10 2 -1 3;2 11 3 -3;-1
2 9 3;2 -3 1 10] x =
A = -177.4000 -95.8182
-235.4444 -18.3000
10 2 -1 3
2 11 3 -3
k =
-1 2 9 3
2
2 -3 1 10
x =
4.7092 96.5667
>> b=[36 56 11 -43]'
8.9040 25.9790
b =
36
56
k =
11
3
-43
x =
-22.6166 8.8915
>> x0=[360 420 680 550]' -28.3735 22.8378

x0 =
360 k =

420 4

680 x =

550 -7.8670 23.1697


-10.8792 5.7281
k = k =
5 11
x = x =
-3.8403 11.0505 4.3381 2.7746
-6.7101 5.3122 2.2754 -4.3254

k = k =
6 12
x = x =
-0.8748 9.0680 4.5702 2.5019
-3.4309 0.4542 2.5295 -4.5628

k = k =
7 13
x = x =
1.3070 6.3095 4.7214 2.3257
-1.0415 -1.0616 2.6950 -4.7164

k = k =
8 14
x = x =
2.5524 4.8478 4.8193 2.2112
0.3192 -2.5644 2.8021 -4.8161

k = k =
9 15
x = x =
3.4317 3.8404 4.8828 2.1370
1.2833 -3.3881 2.8717 -4.8807

k = k =
10 16
x = x =
3.9767 3.1929 4.9240 2.0888
1.8795 -3.9625 2.9168 -4.9226
k = k =
17 23
x = x =
4.9507 2.0576 4.9963 2.0043
2.9460 -4.9498 2.9960 -4.9963

k = k =
18 24
x = x =
4.9680 2.0374 4.9976 2.0028
2.9650 -4.9675 2.9974 -4.9976

k = k =
19 25
x = x =
4.9793 2.0242 4.9985 2.0018
2.9773 -4.9789 2.9983 -4.9984

k = k =
20 26
x = x =
4.9865 2.0157 4.9990 2.0012
2.9853 -4.9863 2.9989 -4.9990

k = k =
21 27
x = x =
4.9913 2.0102 4.9994 2.0008
2.9904 -4.9911 2.9993 -4.9993

k = k =
22 28
x = x =
4.9943 2.0066 4.9996 2.0005
2.9938 -4.9942 2.9995 -4.9996
k = k =
29 35
x = x =
4.9997 2.0003 5.0000 2.0000
2.9997 -4.9997 3.0000 -5.0000

k = k =
30 36
x = x =
4.9998 2.0002 5.0000 2.0000
2.9998 -4.9998 3.0000 -5.0000

k = k =
31 37
x = x =
4.9999 2.0001 5.0000 2.0000
2.9999 -4.9999 3.0000 -5.0000

k = k =
32 38
x = x =
4.9999 2.0001 5.0000 2.0000
2.9999 -4.9999 3.0000 -5.0000

k = k =
33 39
x = x =
5.0000 2.0001 5.0000 2.0000
2.9999 -5.0000 3.0000 -5.0000

k = k =
34 40
x = x =
5.0000 2.0000 5.0000 2.0000
3.0000 -5.0000 3.0000 -5.0000
k = EJERCICIO 3 CON MATLAB
41 Dado el sistema de
x = ecuaciones:

5.0000 2.0000 7x1 + 2x2 -1x3 + 2x4 = 40


3.0000 -5.0000 x1 + 9x2 + 2x3 + 3x4 = 11
2x1 − x2 + 8x3 + 3x4 = 54
x = x1 + 3x2 − x3 + 9x4 = 50
5.0000 a) Obtenga las matrices BJ y
2.0000 CJ

3.0000 b) Hallar ||BJ||

-5.0000 c) Obtenga x (1), x(2) ,…,


x(10) correspondientes al
método de Jacobi, partiendo de
x (0) = (2, 2, 2, 2), pero
usando las matrices BJ y CJ
INSTRUCCIONES
clc
clear
A=[7 2 -1 2;1 9 2 3;2 -1 8
3;1 3 -1 9]
b=[40 11 54 50]'
D=diag(diag(A))'
L=tril(A)-D
U=triu(A)-D
format rat
BJ=-inv(D)*(L+U)
CJ=inv(D)*b
n=norm(BJ,inf)
% iteracciones
format long
x0=[2 2 2 2]'
x1=BJ*x0+CJ
x2=BJ*x1+CJ
x3=BJ*x2+CJ
x4=BJ*x3+CJ
x5=BJ*x4+CJ
x6=BJ*x5+CJ
x7=BJ*x6+CJ
x8=BJ*x7+CJ
x9=BJ*x8+CJ;
x10=BJ*x9+CJ
RESULTADOS
A =
7 2 -1 2
1 9 2 3
2 -1 8 3
1 3 -1 9
b =
40
11
54
50
D =
7 0 0 0
0 9 0 0
0 0 8 0
0 0 0 9
L =
0 0 0 0
1 0 0 0
2 -1 0 0
1 3 -1 0
U =
0 2 -1 2
0 0 2 3
0 0 0 3
0 0 0 0
BJ =
0 -2/7 1/7 -2/7
-1/9 0 -2/9 -1/3
-1/4 1/8 0 -3/8
-1/9 -1/3 1/9 0
CJ = x4 =
40/7 4.988323570168808
11/9 -2.081973838918283
27/4 2.878995811287478
50/9 6.000202087007643

n = x5 =
3/4 5.006077045015537
-1.971880161529633
x0 = 2.992596594965147
2 6.015177084208169
2
2 x6 =
2 4.986571821372581
x1 = -2.004089054174482
4.857142857142857 2.996304311976848
-0.111111111111111 5.989128892726501
5.750000000000000
4.888888888888888 x7 =
5.003746376410401
x2 = -1.994063013722865
5.170634920634920 3.006922578112607
-2.224867724867725 6.002444405903079
3.688492063492064
5.691798941798941 x8 =
4.998594256250311
x3 = -2.002769416704983
5.250661375661375 2.998888876968387
-2.069223985890653 5.998373915874534
3.044808201058202
6.132495590828924
x9 = EJERCICIO 4 CON MATLAB
5.001097125518468 Dado el sistema de
-1.999054861978965 ecuaciones:

3.000615040396350 7x1 + 2x2 + 3x3 = 41

6.000955874537003 x1 + 5x2 + 2x3 = 9

x10 = 3x1 + 2x2 + 8x3 = 50

4.999544716468610 a) Obtenga las matrices BG y


CG
-2.000577203324687
b) Hallar||BG||
2.999485407921636
c) Obtenga x(1), x(2),…, x(10)
5.999631388979419 correspondientes al método de
Gauss Seidel, partiendo de x
(0) = (2, 0, 3), pero usando
solu = las matrices BG y CG

5.000000000000000 INSTRUCCIONES

-2.000000000000000 clc
clear
2.999999999999999
A=[7 2 3;1 5 2;3 2 8]
6.000000000000001 b=[41 9 50]'
D=diag(diag(A))'
L=tril(A)-D
U=triu(A)-D
format rat
BG=-inv(D+L)*(U)
CG=inv(D+L)*b
n=norm(BG,inf)
% iteracciones
format long
x0=[2 0 3]'
x1=BG*x0+CG
x2=BG*x1+CG
x3=BG*x2+CG
x4=BG*x3+CG
x5=BG*x4+CG
x6=BG*x5+CG
x7=BG*x6+CG
x8=BG*x7+CG
x9=BG*x8+CG
x10=BG*x9+CG
solu=inv(A)*b
RESULTADOS 22/35
A = 1091/280
7 2 3 n =
1 5 2 5/7
3 2 8 x0 =
2
b = 0
41 3
9 x1 =
50 4.571428571428571
-0.314285714285714
D = 4.614285714285715
7 0 0
0 5 0 x2 =
0 0 8 3.969387755102040
L = -0.839591836734694
0 0 0 4.971377551020408
1 0 0
3 2 0 x3 =
3.966435860058309
U = -0.981838192419825
0 2 3 5.008046100583091
0 0 2
0 0 0 x4 =
BG = 3.991362583298625
0 -2/7 -1.001490956892961
-3/7
5.003611770486256
0 2/35
-11/35
x5 =
0 13/140
67/280 3.998878086046736
-1.001220325403850
CG = 5.000725799083437
41/7
x6 =
4.000037607651056
-1.000297841163586
5.000060357421750

x7 =
4.000059230008846
-1.000035988970469
4.999986785989300

x8 =
4.000015945710434
-0.999997903537807
4.999993496243040

x9 =
4.000002188335214
-0.999997836164259
4.999998638415359

x10 =
3.999999965297491
-0.999999448425642
4.999999875119851
solu =
4.000000000000000
-1.000000000000000
5.000000000000000

Você também pode gostar