Jacobi Gauss Sor Matlab

Embed Size (px)

Citation preview

RESOLUCION DES SISTEMA DE ECUACIONES MEDIANTE JACOBI Encontrar las 6 iteraciones por jacobi y calcular las cotas de error al asumir el valor

DESPEJAMOS LAS VARIABLES:

EL PROCEDIMIENTO SE HARA COMO SE APLICO EN LABORATORIO MEDIANTE EL PROGRAMA MAT LAB Introducimos la matriz >> A=[10 5 0 0 ; 5 10 -4 0 ; 0 -4 8 -1 ; 0 0 -1 5] A= 10 5 0 0 0

5 10 -4 0 -4 0

8 -1 5

0 -1

>> B=[6;25;-11;-11] B= 6 25 -11 -11 >> D=diag(diag(A)) D= 10 0 0 0 8 0 0 0 0 5

0 10 0 0 0 0

>> U=triu(A)-D U= 0 0 0 0 5 0 0 0

0 -4 0 0

0 -1 0 0

>> L=tril(A)-D L= 0 5 0 0 0 0 0 0 0 0 0

0 -4 0

0 -1

>> BJ=inv(D)*(-U-L) BJ = 0 -0.5000 -0.5000 0 0 0

0 0.4000

0 0.5000 0

0 0.1250 0

0 0.2000

>> CJ=inv(D)*B CJ = 0.6000 2.5000 -1.3750 -2.2000 >> norm(BJ,1) ans = 1

>> norm(BJ,inf) ans = 0.9000 >> eig(BJ) ans = -0.6793 0.6793 -0.1164 0.1164

>> abs(eig(BJ)) ans = 0.6793 0.6793 0.1164 0.1164 >> x0=[0;0;0;0] x0 = 0 0 0 0 >> X1=BJ*x0+CJ X1 = 0.6000 2.5000 -1.3750 -2.2000 >> X2=BJ*X1+CJ X2 = -0.6500 1.6500 -0.4000 -2.4750

>> X3=BJ*X2+CJ X3 = -0.2250 2.6650 -0.8594 -2.2800 >> X4=BJ*X3+CJ X4 = -0.7325 2.2687 -0.3275 -2.3719 >> X5=BJ*X4+CJ X5 = -0.5344 2.7352 -0.5371 -2.2655 >> X6=BJ*X5+CJ X6 = -0.7676 2.5523 -0.2906 -2.3074

Para hallar las cotas de error >> IA=inv(A) IA = 0.1459 -0.0918 -0.0471 -0.0094 -0.0918 0.1835 0.0941 0.0188 -0.0471 0.0941 0.1765 0.0353 -0.0094 0.0188 0.0353 0.2071 >> NC=norm(A,inf)*norm(IA,inf) NC = 7.3765 >> X6=[-0.77 ; 2.55 ; -0.29 ; -2.31] X6 = -0.7700 2.5500 -0.2900 -2.3100 >> A*X6-B ans = -0.9500 -2.1900 0.7900 -0.2600

>> R=A*X6-B R= -0.9500 -2.1900 0.7900 -0.2600 >> Cinf=norm(R,inf)/(norm(B,inf)*NC) Cinf = 0.0119 >> CSUP=(NC*norm(R,inf))/norm(B,inf) CSUP = 0.6462

GAUUSS SEIDEL >> BG=inv(D+L)*(-U)

BG =

0 -0.5000

0

0 0

0 0.2500 0.4000

0 0.1250 0.2000 0.1250 0 0.0250 0.0400 0.0250

>> CG=inv(D+L)*B

CG =

0.6000 2.2000 -0.2750 -2.2550

>> eig(BG)

ans =

0 0.4615 0.0135 0.0000

>> abs(eig(BG))

ans =

0 0.4615

0.0135 0.0000 >> format long >> X0=[0;0;0;0]

X0 =

0 0 0 0

>> X1=BG*X0+CG

X1 =

0.600000000000000 2.200000000000000 -0.275000000000000 -2.255000000000000

>> X2=BG*X1+CG

X2 =

-0.500000000000000 2.640000000000000 -0.336875000000000 -2.267375000000000

>> X3=BG*X2+CG

X3 =

-0.720000000000000 2.725250000000000 -0.295796875000000 -2.259159375000000

>> X4=BG*X3+CG

X4 =

-0.762625000000000 2.762993750000000 -0.275898046875000 -2.255179609375000

>> X5=BG*X4+CG

X5 =

-0.781496875000000 2.780389218750000 -0.266702841796875 -2.253340568359375

>> X6=BG*X5+CG

X6 =

-0.790194609375000 2.788416167968750 -0.262459487060547 -2.252491897412110 PARA AVERIGUAR EL ERROR: >> IA=inv(A)

IA =

0.145882352941176 -0.091764705882353 -0.047058823529412 0.009411764705882

-0.091764705882353 0.183529411764706 0.094117647058824 0.018823529411765 -0.047058823529412 0.094117647058824 0.176470588235294 0.035294117647059 -0.009411764705882 0.018823529411765 0.035294117647059 0.207058823529412

>> NC=norm(A,inf)*norm(IA,inf)

NC =

7.376470588235293

>> X6=[-0.79 ; 2.79 ; -0.26 ; -2.25]

X6 =

-0.790000000000000 2.790000000000000 -0.260000000000000 -2.250000000000000

>> A*X6-B

ans =

0.049999999999999 -0.010000000000002 0.010000000000000 0.010000000000000

>> R=A*X6-B

R=

0.049999999999999 -0.010000000000002 0.010000000000000 0.010000000000000

>> Cinf=norm(R,inf)/(norm(B,inf)*NC)

Cinf =

2.711323763955286e-004

>> CSUP=(NC*norm(R,inf))/norm(B,inf)

CSUP =

0.014752941176470 ENCONTRAR POR SOR >> RVBJ=norm(abs(eig(BJ)),inf)

RVBJ =

0.679305462100528

>> W=2/(1+((1-(RVBJ^2))^(1/2)))

W=

1.153498574311418

>> BW=inv(D+W*L)*((1-W)*D-W*U)

BW =

-0.153498574311418 -0.576749287155709

0

0

0.088530193313528 0.179141165923201 0.461399429724567 0 0.051059725885334 0.103319539746448 0.112613217876277 0.144187321788927

0.011779464202693 0.023835788359208 0.025979837253781 0.120234600287956

>> CW=inv(D+W*L)*W*b ??? Undefined function or variable 'b'.

>> CW=inv(D+W*L)*W*B

CW =

0.692099144586851 2.484578747497003 -0.153081518177079 -2.573012726079257

>> X0=[0;0;0;0]

X0 =

0 0 0 0

>> X1=BW*X0+CW

X1 =

0.692099144586851 2.484578747497003 -0.153081518177079 -2.573012726079257

>> X2=BW*X1+CW

X2 =

-0.847116108890503 2.920309027025747 -0.249272409175304 -2.200250152066596

>> X3=BW*X2+CW

X3 =

-0.862155890033703 2.817716811135809

-0.239929594717546 -2.255313291102778

>> X4=BW*X3+CW

X4 =

-0.800677317688019 2.802317616497472 -0.258184584494219 -2.251072598699905

>> X5=BW*X4+CW

X5 =

-0.801232716363350 2.796578854837500 -0.258080842205874 -2.251699605621499

>> X6=BW*X5+CW

X6 =

-0.797837636761968 2.795549503463365 -0.258780850619264 -2.251764852694321 PARA EL ERROR: >> IA=inv(A)

IA =

0.145882352941176 -0.091764705882353 -0.047058823529412 0.009411764705882 -0.091764705882353 0.183529411764706 0.094117647058824 0.018823529411765 -0.047058823529412 0.094117647058824 0.176470588235294 0.035294117647059 -0.009411764705882 0.018823529411765 0.035294117647059 0.207058823529412

>> NC=norm(A,inf)*norm(IA,inf)

NC =

7.376470588235293

>> X6=[-0.80 ; 2.80 ; -0.26 ; -2.25]

X6 =

-0.800000000000000 2.800000000000000 -0.260000000000000 -2.250000000000000

>> A*X6-B

ans =

0 0.039999999999999 -0.029999999999999 0.010000000000000

>> R=A*X6-B

R=

0 0.039999999999999

-0.029999999999999 0.010000000000000

>> Cinf=norm(R,inf)/(norm(B,inf)*NC)

Cinf =

2.169059011164228e-004

>> CSUP=(NC*norm(R,inf))/norm(B,inf)

CSUP =

0.011802352941176