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

Simulacion

The document describes solving a system of linear equations using different iterative methods like Jacobi, Gauss-Seidel and over-relaxation. It provides the mathematical operations and iterations involved in applying these methods to find the solution.

Uploaded by

Belen Intriago
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 views20 pages

Simulacion

The document describes solving a system of linear equations using different iterative methods like Jacobi, Gauss-Seidel and over-relaxation. It provides the mathematical operations and iterations involved in applying these methods to find the solution.

Uploaded by

Belen Intriago
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

>> A= [2, -1, 1; 3, 3, 9; 3, 3, 5]; b=[1; 2; 3];

U= triu (A, 1); L= tril (A, -1); D= diag (diag (A));

B= L+D+U

B=

2 -1 1

3 3 9

3 3 5

>> x0= b./diag (A)

x0 =

0.5000

0.6667

0.6000

>> D1= diag (A)

D1 =

5
>> x=(b-(L+U)*x0)./D1

x=

0.5333

-1.6333

-0.1000

>> x=(b-(L+U)*x0)./D1

x=

0.5333

-1.6333

-0.1000

>> x0=x

x0 =

0.5333

-1.6333

-0.1000

>> x=(b-(L+U)*x0)./D1
x=

-0.2667

0.4333

1.2600

>> x0=x

x0 =

-0.2667

0.4333

1.2600

>> x=(b-(L+U)*x0)./D1

x=

0.0867

-2.8467

0.5000

>> x0=x

x0 =
0.0867

-2.8467

0.5000

>> x=(b-(L+U)*x0)./D1

x=

-1.1733

-0.9200

2.2560

>> x0=x

x0 =

-1.1733

-0.9200

2.2560

>> x=(b-(L+U)*x0)./D1

x=

-1.0880

-4.9280
1.8560

>> x0=x

x0 =

-1.0880

-4.9280

1.8560

>> x=(b-(L+U)*x0)./D1

x=

-2.8920

-3.8133

4.2096

>> x0=x

x0 =

-2.8920

-3.8133

4.2096
>> x=(b-(L+U)*x0)./D1

x=

-3.5115

-9.0701

4.6232

>> x0=x

x0 =

-3.5115

-9.0701

4.6232

>> x=(b-(L+U)*x0)./D1

x=

-6.3467

-9.6915

8.1490

>> x0=x
x0 =

-6.3467

-9.6915

8.1490

>> x=(b-(L+U)*x0)./D1

x=

-8.4202

-17.4335

10.2229

>> %El metodo de jacobi no coverge

>> %Método Gauss Seidel

>> x0= b./diag (A)

x0 =

0.5000

0.6667

0.6000

>> x=(L+D1)\(b-U*x0)

Error using +
Matrix dimensions must agree.

>> x=(L+D)\(b-U*x0)

x=

0.5333

-1.6667

1.2800

>> x0=x

x0 =

0.5333

-1.6667

1.2800

>> x=(L+D)\(b-U*x0)

x=

-0.9733

-2.2000

2.5040
>> x0=x

x0 =

-0.9733

-2.2000

2.5040

>> x=(L+D)\(b-U*x0)

x=

-1.8520

-4.9933

4.7072

>> x0=x

x0 =

-1.8520

-4.9933

4.7072

>> x=(L+D)\(b-U*x0)
x=

-4.3503

-9.1047

8.6730

>> x0=x

x0 =

-4.3503

-9.1047

8.6730

>> x=(L+D)\(b-U*x0)

x=

-8.3888

-16.9634

15.8113

>> x0=x

x0 =
-8.3888

-16.9634

15.8113

>> x=(L+D)\(b-U*x0)

x=

-15.8874

-30.8800

28.6604

>> x0=x

x0 =

-15.8874

-30.8800

28.6604

>> x=(L+D)\(b-U*x0)

x=

-29.2702

-56.0443
51.7887

>> x0=x

x0 =

-29.2702

-56.0443

51.7887

>> x=(L+D)\(b-U*x0)

x=

-53.4165

-101.2829

93.4197

>> x0=x

x0 =

-53.4165

-101.2829

93.4197
>> x=(L+D)\(b-U*x0)

x=

-96.8513

-182.7410

168.3554

>> %El método de Gauss Seidel no converge

>> %Método de sobrerelación

>> w=0.5

w=

0.5000

>> c= w*b

c=

0.5000

1.0000

1.5000

>> C=(1-w)*D-w*U
C=

1.0000 0.5000 -0.5000

0 1.5000 -4.5000

0 0 2.5000

>> x0= b./diag (A)

x0 =

0.5000

0.6667

0.6000

>> x=(w*L+D)\(c-C*x0)

x=

-0.0167

0.9083

-0.2675

>> x0=x

x0 =
-0.0167

0.9083

-0.2675

>> x=(w*L+D)\(c-C*x0)

x=

-0.0356

-0.5043

0.5957

>> x0=x

x0 =

-0.0356

-0.5043

0.5957

>> x=(w*L+D)\(c-C*x0)

x=

0.5428

1.2076
-0.5230

>> x0=x

x0 =

0.5428

1.2076

-0.5230

>> x=(w*L+D)\(c-C*x0)

x=

-0.4541

-0.8279

0.9461

>> x0=x

x0 =

-0.4541

-0.8279

0.9461
>> x=(w*L+D)\(c-C*x0)

x=

0.9205

1.7062

-0.9611

>> x0=x

x0 =

0.9205

1.7062

-0.9611

>> x=(w*L+D)\(c-C*x0)

x=

-0.8771

-1.5228

1.5005

>> x0=x
x0 =

-0.8771

-1.5228

1.5005

>> x=(w*L+D)\(c-C*x0)

x=

1.4444

2.6233

-1.6706

>> x0=x

x0 =

1.4444

2.6233

-1.6706

>> x=(w*L+D)\(c-C*x0)

x=
-1.5457

-2.7113

2.4124

>> x0=x

x0 =

-1.5457

-2.7113

2.4124

>> x=(w*L+D)\(c-C*x0)

x=

2.3038

4.1557

-2.8440

>> x0=x

x0 =

2.3038

4.1557
-2.8440

>> x=(w*L+D)\(c-C*x0)

x=

-2.6518

-4.6846

3.9229

You might also like