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

You are not logged in.

#1 2013-11-29 23:55:34

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

What have I done wrong??

Hi smile

I wrote a function in matlab,that implements the Jacobi and Gauss-Seidel method.I have to do this for different matrices..I am facing difficulties when I call my function,giving the Hilbert matrix..
I have to find the error ||x_{k}-d|| (where d is the accurate solution) of the last iteration,with ε=0.000001.I tried to find this and for MAXITERATIONS>=250 I get Nan as result..Isn't it wrong??What should I change? dunno

Offline

#2 2013-11-30 00:24:48

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,627

Re: What have I done wrong??

Hi;

The Hilbert matrix as described in the other thread is notoriously ill conditioned. That is the reason for the problem. You would have to work to many digits of precision or in exact arithmetic. Matlab as far as remember can do neither.


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-30 01:09:54

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

Re: What have I done wrong??

bobbym wrote:

Hi;

The Hilbert matrix as described in the other thread is notoriously ill conditioned. That is the reason for the problem. You would have to work to many digits of precision or in exact arithmetic. Matlab as far as remember can do neither.

So,if I am asked to write the error of the last iteration for different n,is the right answer that it is Nan for n>=250??

Offline

#4 2013-11-30 01:37:00

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

Re: What have I done wrong??

Also,now I ran the Gauss-Seidel function I wrote for the Hilbert Matrix for MAXITERATIONS>=250..The method does not converge but I get a number,for example for  MAXITERATIONS=250 I get this number:1.4455...Why does this happen???

Last edited by evinda (2013-11-30 01:57:29)

Offline

#5 2013-11-30 02:50:33

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,627

Re: What have I done wrong??

Are you being asked to use your routine on a Hilbert Matrix?


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

#6 2013-11-30 03:07:23

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

Re: What have I done wrong??

bobbym wrote:

Are you being asked to use your routine on a Hilbert Matrix?

Yes,and I did it using this: hilb(n)..

Offline

#7 2013-11-30 03:08:36

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,627

Re: What have I done wrong??

Which Hilbert Matrix? I will try my routine on it.


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

#8 2013-11-30 03:15:53

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

Re: What have I done wrong??

bobbym wrote:

Which Hilbert Matrix? I will try my routine on it.

What do you mean???Which dimension??I wrote this command H=hilb(n) in a function and each time I call it I give different values..The formula for this matrix is

Offline

#9 2013-11-30 03:17:00

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,627

Re: What have I done wrong??

You need to provide the n.


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

#10 2013-11-30 03:23:37

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

Re: What have I done wrong??

bobbym wrote:

You need to provide the n.

It is given from the user when he calls the function..You could take n=250,to check if you get the same results as mine.. hmm

Offline

#11 2013-11-30 03:25:32

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,627

Re: What have I done wrong??

You are trying to invert a 250 x 250 Hilbert Matrix!!!!!!!


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

#12 2013-11-30 03:34:45

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

Re: What have I done wrong??

bobbym wrote:

You are trying to invert a 250 x 250 Hilbert Matrix!!!!!!!

What do you mean???Isn't is possible to do this??? dunno

Offline

#13 2013-11-30 03:37:01

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,627

Re: What have I done wrong??

Why are you using such a large matrix?


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

#14 2013-11-30 03:40:43

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

Re: What have I done wrong??

bobbym wrote:

Why are you using such a large matrix?

I have to implement the methods for different values of n,with 50<=n<=1000..

Offline

#15 2013-11-30 03:46:43

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,627

Re: What have I done wrong??

A 250 x 250 Hilbert matrix has a condition number of around 4.35 x 10^380. That means doing arithmetic on it could potentially lose 380 digits of precision.

To show why this is deadly please post what Matlab thinks hilb(4) is.


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

#16 2013-11-30 03:54:39

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

Re: What have I done wrong??

bobbym wrote:

A 250 x 250 Hilbert matrix has a condition number of around 4.35 x 10^380. That means doing arithmetic on it could potentially lose 380 digits of precision.

To show why this is deadly please post what Matlab thinks hilb(4) is.

I also have to find the condition number for different values of n and for the 250 x 250 Hilbert matrix,I found it like that:  3.9067e+020..Is it equal with your result,if we consider that Matlab looses a lot of digits of precision??

hilb(4):

    1.0000    0.5000    0.3333    0.2500
    0.5000    0.3333    0.2500    0.2000
    0.3333    0.2500    0.2000    0.1667
    0.2500    0.2000    0.1667    0.1429

Offline

#17 2013-11-30 03:58:48

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,627

Re: What have I done wrong??

You are not remembering the other threads. That condition number is kaboobly doo. A Hilbert matrix will not allow arithmetic to be done on it easily. So even when you ask for the condition number it gives the wrong answer! My answer is correct.

Look at Hilbert 4 x 4. It only gives 4 digits! You need 400 digits to get an accurate answer.


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

#18 2013-11-30 04:03:17

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

Re: What have I done wrong??

bobbym wrote:

You are not remembering the other threads. That condition number is kaboobly doo. A Hilbert matrix will not allow arithmetic to be done on it easily. So even when you ask for the condition number it gives the wrong answer! My answer is correct.

Ok,I got it... smile


Look at Hilbert 4 x 4. It only gives 4 digits! You need 400 digits to get an accurate answer.

So,what does this mean?? Has the precision to do something with the fact that I get Nan as result??? dunno:

Offline

#19 2013-11-30 04:06:04

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,627

Re: What have I done wrong??

This is what a real Hilbert 4 x 4 matrix looks like.

Notice the differences between what Matlab thinks and what really is.


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

#20 2013-11-30 04:09:55

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

Re: What have I done wrong??

bobbym wrote:

This is what a real Hilbert 4 x 4 matrix looks like.

Notice the differences between what Matlab thinks and what really is.

Isn't it the same matrix??

        1              1/2            1/3            1/4     
       1/2            1/3            1/4            1/5     
       1/3            1/4            1/5            1/6     
       1/4            1/5            1/6            1/7   

I have written the command format rat and get now the numbers as fractions.. hmm

Offline

#21 2013-11-30 04:10:52

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,627

Re: What have I done wrong??

Do you believe that .3333 and 1 / 3 are the same thing?


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

#22 2013-11-30 04:12:00

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

Re: What have I done wrong??

bobbym wrote:

Do you believe that .3333 and 1 / 3 are the same thing?

No,it is like that: 0.3333333333333333333333333....................................................

Offline

#23 2013-11-30 04:13:54

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,627

Re: What have I done wrong??

Let's do a little experiment, we know that

(1/3) x 900000 = 300000

Enter just as you see it

.3333 x 900000 = ?


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

#24 2013-11-30 04:15:09

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

Re: What have I done wrong??

bobbym wrote:

Let's do a little experiment, we know that

(1/3) x 900000 = 300000

Enter just as you see it

.3333 x 900000 = ?

This is the result I get: 299970

Last edited by evinda (2013-11-30 04:15:53)

Offline

#25 2013-11-30 04:18:18

bobbym
Administrator
From: Bumpkinland
Registered: 2009-04-12
Posts: 82,627

Re: What have I done wrong??

So you see .3333 is not 1 / 3. When you did a calculation with it the error was magnified until it has a difference of 30.


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

Board footer

Powered by FluxBB