Skip to content
Prev 167081 / 398502 Next

Precision in R

I'm using:
"solve(a, b, tol, LINPACK = FALSE, ...)"
Therefore,tol ==.Machine$double.eps
[1] 2.220446e-16

It explains why 'solve' works for 'tcp1' but not for 'tcp2':
  
 eigen(tcp1)$values
[1]  5.208856e+09  2.585816e+08 -3.660671e-06

-3.660671e-06/5.208856e+09
[1] -7.027783e-16

eigen(tcp2)$values
[1]  5.208856e+09  2.585816e+08 -6.416393e-08
-6.416393e-08/5.208856e+09
[1] -1.231824e-17

My question would be why 'tcrossprod' and 'crossprod' leads to such
difference?

Marlon.

-----Original Message-----
From: David Winsemius [mailto:dwinsemius at comcast.net] 
Sent: Thursday, 15 January 2009 6:04 p.m.
To: Charles C. Berry
Cc: dos Reis, Marlon; r-help at r-project.org
Subject: Re: [R] Precision in R

I am seeing different behavior than don Reis on my installation as well:
mtx is the same as his WBtWB

 > mtx <- matrix(c(1916061939, 2281366606,  678696067, 2281366606,  
3098975504, 1092911209, 678696067, 1092911209,  452399849), ncol=3)
 >
 > mtx
            [,1]       [,2]       [,3]
[1,] 1916061939 2281366606  678696067
[2,] 2281366606 3098975504 1092911209
[3,]  678696067 1092911209  452399849
 > eigen(mtx)
$values
[1]  5.208856e+09  2.585816e+08 -4.276959e-01

$vectors
            [,1]       [,2]       [,3]
[1,] -0.5855545 -0.7092633  0.3925195
[2,] -0.7678140  0.3299775 -0.5491599
[3,] -0.2599763  0.6229449  0.7378021

 > rcond(mtx)
[1] 5.33209e-11

Despite a very ill-conditioned matrix, solve still proceeds
 >
 > solve(mtx)
            [,1]       [,2]       [,3]
[1,] -0.3602361  0.5039933 -0.6771204
[2,]  0.5039933 -0.7051189  0.9473348
[3,] -0.6771204  0.9473348 -1.2727543
 >
 > sessionInfo()
R version 2.8.1 Patched (2009-01-07 r47515)
i386-apple-darwin9.6.0

locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

snipped package info