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

You are not logged in.

#1 2013-11-24 06:44:32

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

Not sure if output is right

Hello smile
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

#2 2013-11-24 15:17:35

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,249

Re: Not sure if output is right

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

#3 2013-11-25 08:40:15

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

Re: Not sure if output is right

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

#4 2013-11-25 12:34:57

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,249

Re: Not sure if output is right

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

#5 2013-11-25 12:51:25

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

Re: Not sure if output is right

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

#6 2013-11-25 12:58:26

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,249

Re: Not sure if output is right

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

#7 2013-11-25 13:02:35

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

Re: Not sure if output is right

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

#8 2013-11-25 13:03:51

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,249

Re: Not sure if output is right

More jargon, it means successive over relaxation.


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

#9 2013-11-25 13:07:45

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

Re: Not sure if output is right

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

#10 2013-11-25 13:09:13

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,249

Re: Not sure if output is right

It should be jargone.


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

#11 2013-11-25 13:29:26

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

Re: Not sure if output is right

The Jacobi is not converging for some reason.


“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

#12 2013-11-25 21:29:39

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,249

Re: Not sure if output is right

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.


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

#13 2013-11-29 23:45:18

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

Re: Not sure if output is right

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

Offline

#14 2013-11-29 23:48:18

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,249

Re: Not sure if output is right

Hi;

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


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

#15 2013-11-30 01:11:50

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

Re: Not sure if output is right

bobbym wrote:

Hi;

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

How can I do this?? hmm

Offline

#16 2013-11-30 02:46:57

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,249

Re: Not sure if output is right

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


Can you do that or do you require help?


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

#17 2013-12-01 04:12:07

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

Re: Not sure if output is right

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 dunno I think I need some help.. smile

Offline

#18 2013-12-01 04:44:39

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,249

Re: Not sure if output is right

Use this matrix here:


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

#19 2013-12-01 05:19:03

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

Re: Not sure if output is right

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.. hmm

Offline

#20 2013-12-01 05:21:27

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,249

Re: Not sure if output is right

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.


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

#21 2013-12-01 06:32:09

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

Re: Not sure if output is right

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

#22 2013-12-01 06:35:07

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,249

Re: Not sure if output is right

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


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

#23 2013-12-01 06:40:45

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

Re: Not sure if output is right

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

#24 2013-12-01 06:46:17

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 83,249

Re: Not sure if output is right

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!


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

#25 2013-12-01 06:50:31

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

Re: Not sure if output is right

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?? hmm

Offline

Board footer

Powered by FluxBB