Discussion about math, puzzles, games and fun. Useful symbols: ÷ × ½ √ ∞ ≠ ≤ ≥ ≈ ⇒ ± ∈ Δ θ ∴ ∑ ∫ π -¹ ² ³ °

You are not logged in.

- Topics: Active | Unanswered

**evinda****Member**- Registered: 2013-04-13
- Posts: 104

Hello

I have written two programs using matlab,in which I implement the Jacobi and Gauss Seidel method.

Both of the programs should terminate either if the number of iterations surpass the maximum number of iterations MAXITERATIONS or if one of these conditions/or both of them:

|| x_{k}-x_{k-1} ||<ε , || b-Ax_{k} ||<ε

are valid.

Could you give me the results of an example with an initial value [tex] x_{0} [/tex],an array A ,a specific b,a specific MAXITERATIONS and a specific small number ε,so I can check my output?For example,if :

A=[4 5 1 5;6 3 1 2;9 9 6 1;1 2 3 5]

x0 =[0;0;0;0]

b=[3;2;1;4]

MAXITERATIONS=100

ε=0.001

which should be the solution of x,at the first code,and which at the second one?

*Last edited by evinda (2013-11-24 06:47:27)*

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,414

There are lots of different algorithms that have those names. Please point me to the exact ones or describe them further.

I do not program in Matlab but I can easily program the relevant algorithms in Mathematica and iterate 100 times.

**In mathematics, you don't understand things. You just get used to them.I have the result, but I do not yet know how to get it.All physicists, and a good many quite respectable mathematicians are contemptuous about proof.**

Offline

**evinda****Member**- Registered: 2013-04-13
- Posts: 104

bobbym wrote:

There are lots of different algorithms that have those names. Please point me to the exact ones or describe them further.

I do not program in Matlab but I can easily program the relevant algorithms in Mathematica and iterate 100 times.

The formula I have to use for the Jacobi method is this: D*x_{k+1}=-(U+L)*x_{k}+b,

for the Gauss Seidel method the formula I have to use is this:(D+L)*x_{k+1}=b-U*x_{k}.

( L is the lower triangular and U the upper triangular matrix)

Both of the programs should terminate either if the number of iterations surpass the maximum number of iterations MAXITERATIONS or if one of these conditions/or both of them:

|| x_{k}-x_{k-1} ||<ε , || b-Ax_{k} ||<ε

are valid.

Could you tell me the solution of x of both methods and also the number of iterations each method needed to converge?

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,414

Hi;

Okay, I give up. What is D?

**In mathematics, you don't understand things. You just get used to them.I have the result, but I do not yet know how to get it.All physicists, and a good many quite respectable mathematicians are contemptuous about proof.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 14,809

D is the diagonal component of the matrix A, i.e., it is a matrix whose diagonal elements are equal to the elements on the diagonals of A, while the rest are 0.

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,414

Now why on earth would anyone use all that linear algebra jargon for such a simple process as iteration and SOR?

**In mathematics, you don't understand things. You just get used to them.I have the result, but I do not yet know how to get it.All physicists, and a good many quite respectable mathematicians are contemptuous about proof.**

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 14,809

Sor?

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,414

More jargon, it means successive over relaxation.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 14,809

The word jargon always reminds me of the 'e'-less game.

Here lies the reader who will never open this book. He is forever dead.

Taking a new step, uttering a new word, is what people fear most. ― Fyodor Dostoyevsky, Crime and Punishment

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,414

It should be jargone.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**anonimnystefy****Real Member**- From: The Foundation
- Registered: 2011-05-23
- Posts: 14,809

The Jacobi is not converging for some reason.

Here lies the reader who will never open this book. He is forever dead.

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,414

Hi;

By 30 iterations with Gauss Seidel I am not getting convergence to the answers of the system. Same thing for Jacobi.

Am I correct in assuming this is A

There is an easy trick that will make Gauss Seidel converge but the convergence will be slow. The Jacobi has imaginary eigenvalues so I do not think it will converge.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**evinda****Member**- Registered: 2013-04-13
- Posts: 104

I checked if it converges using the Gauss-Sheidel method,but it doesn't...

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,414

Hi;

That is not exactly correct, it can be made to converge using Gauss Seidel.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**evinda****Member**- Registered: 2013-04-13
- Posts: 104

bobbym wrote:

Hi;

That is not exactly correct, it can be made to converge using Gauss Seidel.

How can I do this??

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,414

You can rearrange the matrix until it is diagonally dominant or close to it.

Can you do that or do you require help?

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**evinda****Member**- Registered: 2013-04-13
- Posts: 104

bobbym wrote:

You can rearrange the matrix until it is diagonally dominant or close to it.

Can you do that or do you require help?

I don't know how to do this I think I need some help..

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,414

Use this matrix here:

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**evinda****Member**- Registered: 2013-04-13
- Posts: 104

bobbym wrote:

Use this matrix here:

How did you rearrange the matrix??Because I have to do this for the general case,and not for a special matrix..

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,414

You can not do it for a general case. Each one is different and it may not work next time. Numerical work is a hands on skill. You must experiment.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**evinda****Member**- Registered: 2013-04-13
- Posts: 104

bobbym wrote:

You can not do it for a general case. Each one is different and it may not work next time. Numerical work is a hands on skill. You must experiment.

How can I rearrange,for example,a 250x250 Hilbert Matrix??

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,414

You are not following. Nothing on this earth will ever get the answer to that linear system using Matlab's precision.

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**evinda****Member**- Registered: 2013-04-13
- Posts: 104

bobbym wrote:

You are not following. Nothing on this earth will ever get the answer to that linear system using Matlab's precision.

And what if I want to apply the methods at a 250x250 tridiagonal matrix with the number 2 at the main diagonal,-1 at the first diagonal below this and also -1 at the diagonal above this?Because both of the methods do not converge for this matrix..

*Last edited by evinda (2013-12-01 06:43:44)*

Offline

**bobbym****Administrator**- From: Bumpkinland
- Registered: 2009-04-12
- Posts: 81,414

The matrix is already diagonally dominant. There is nothing else to be done with it. Numerical methods are not like Algebra. They do not always work!

I have the result, but I do not yet know how to get it.

All physicists, and a good many quite respectable mathematicians are contemptuous about proof.

Offline

**evinda****Member**- Registered: 2013-04-13
- Posts: 104

bobbym wrote:

The matrix is already diagonally dominant. There is nothing else to be done with it. Numerical methods are not like Algebra. They do not always work!

So,why do the methods not converge,although the matrix is diagonally dominant??

Offline