From hin-tak.leung at cimr.cam.ac.uk  Tue Jan 10 14:42:55 2006
From: hin-tak.leung at cimr.cam.ac.uk (Hin-Tak Leung)
Date: Tue, 10 Jan 2006 13:42:55 +0000
Subject: [Rd] eigen()
In-Reply-To: <x2zmm49qb3.fsf@viggo.kubism.ku.dk>
References: <3B7754B8-4982-49BE-B424-A0D9CFC6F056@soc.soton.ac.uk>
	<x2zmm49qb3.fsf@viggo.kubism.ku.dk>
Message-ID: <43C3B9DF.1090803@cimr.cam.ac.uk>

Peter Dalgaard wrote:
> Robin Hankin <r.hankin at noc.soton.ac.uk> writes:
> 
> 
>>Hi
>>
>>I am having difficulty with eigen() on   R-devel_2006-01-05.tar.gz
>>
>>Specifically,  in R-2.2.0 I get expected behaviour:
>>
>>
>> > eigen(matrix(1:100,10,10),FALSE,TRUE)$values
>>[1]  5.208398e+02+0.000000e+00i -1.583980e+01+0.000000e+00i
>>[3] -4.805412e-15+0.000000e+00i  1.347691e-15+4.487511e-15i
>>[5]  1.347691e-15-4.487511e-15i -4.269863e-16+0.000000e+00i
>>[7]  1.364748e-16+0.000000e+00i -1.269735e-16+0.000000e+00i
>>[9] -1.878758e-18+5.031259e-17i -1.878758e-18-5.031259e-17i
>> >
>>
>>
>>The same command gives different results in the development version:
>>
>>
>> > eigen(matrix(1:100,10,10),FALSE,TRUE)$values
>>[1]  3.903094e-118 -3.903094e-118 -2.610848e-312 -2.995687e-313  
>>-2.748516e-313
>>[6] -1.073138e-314 -1.061000e-314 -1.060998e-314  4.940656e-324    
>>0.000000e+00
>> > R.version()
>>Error: attempt to apply non-function
>> > R.version
> 
> 
> Strange and semi-random results on SuSE 9.3 as well:
> 
> 
>> eigen(matrix(1:100,10,10))$values
> 
>  [1] -5.393552e+194   3.512001e-68   0.000000e+00   0.000000e+00   0.000000e+00
>  [6]   0.000000e+00   0.000000e+00   0.000000e+00   0.000000e+00   0.000000e+00
> 
>> eigen(matrix(1:100,10,10))$values
> 
>  [1]  1.526259e-311 -1.041529e-311  1.181720e-313   0.000000e+00   0.000000e+00
>  [6]   0.000000e+00   0.000000e+00   0.000000e+00   0.000000e+00   0.000000e+00
> 
>> eigen(matrix(1:100,10,10))$values
> 
>  [1] -9.338774e+93  0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00
>  [6]  0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00  0.000000e+00
> 
>> eigen(matrix(1:100,10,10))$values
> 
>  [1]  5.4e-311+ 0.0e+00i -2.5e-311+3.7e-311i -2.5e-311-3.7e-311i
>  [4]  2.5e-312+ 0.0e+00i -2.4e-312+ 0.0e+00i  3.2e-317+ 0.0e+00i
>  [7]   0.0e+00+ 0.0e+00i   0.0e+00+ 0.0e+00i   0.0e+00+ 0.0e+00i
> [10]   0.0e+00+ 0.0e+00i
> 
> 
> 

Mine is closer to Robin's, but not the same (EL4 x86).

 > eigen(matrix(1:100,10,10))$values
  [1]  5.208398e+02+0.000000e+00i -1.583980e+01+0.000000e+00i
  [3]  6.292457e-16+2.785369e-15i  6.292457e-16-2.785369e-15i
  [5] -1.055022e-15+0.000000e+00i  3.629676e-16+0.000000e+00i
  [7]  1.356222e-16+2.682405e-16i  1.356222e-16-2.682405e-16i
  [9]  1.029077e-16+0.000000e+00i -1.269181e-17+0.000000e+00i
 >

But surely, my matrix algebra is a bit rusty, I think this matrix is
solveable analytically? Most of the eigenvalues shown are almost
exactly zero, except the first two, actually, which is about 521
and -16 to the closest integer.

I think the difference between mine and Robin's are rounding errors
(the matrix is simple enough I expect the solution to be simple integers
or easily expressible analystical expressions, so 8 e-values being zero
is fine). Peter's number seems to be all 10 e-values are zero or one 
being a huge number! So Peter's is odd... and Peter's machine also seems
to be of a different archtecture (64-bit machine)?

HTL



[Rd] eigen()
Hin-Tak Leung