[R] identity matrix

Robert samrobertsmith at yahoo.com
Sun Oct 30 22:14:16 CET 2005


I found a very odd thing.
A matrix multiplied by its inverse matrix should be an
identity matrix.
But why the following thing happens?
<a%*%solve(a) is not an identity matrix>
> x%*%t(x)
       [,1]   [,2]  [,3]   [,4]   [,5]
[1,] 108.16  58.24 32.24  66.56 225.68
[2,]  58.24  31.36 17.36  35.84 121.52
[3,]  32.24  17.36  9.61  19.84  67.27
[4,]  66.56  35.84 19.84  40.96 138.88
[5,] 225.68 121.52 67.27 138.88 470.89
> a=x%*%t(x)
> solve(a)
              [,1]          [,2]          [,3]        
 [,4]          [,5]
[1,] -1.372649e+14  1.078492e+14 -2.553747e+14 
1.126842e+14  4.120191e+13
[2,] -1.174558e+14  1.543860e+14  2.323143e+14
-1.375074e+14  2.381809e+13
[3,] -3.062129e+14  6.914056e+14 -1.656744e+15 
7.007732e+14 -1.672741e+12
[4,]  1.761208e+14 -3.724017e+14  7.773835e+14
-2.156631e+14 -3.575351e+13
[5,]  8.789836e+13 -8.046912e+13  6.984285e+13
-5.502429e+13 -1.510937e+13
> a%*%solve(a)
           [,1]       [,2]      [,3]       [,4]     
[,5]
[1,]  2.0410156  1.4433594 -4.169922  0.4003906
1.2170410
[2,] -2.5146484  1.9208984 -1.84912w=1  1.1879883
1.1203613
[3,] -1.5356445 -0.8549805 -1.008789  0.4116211
0.6218872
[4,] -0.5898438 -0.2539063  3.592773  2.0351563
0.7849121
[5,]  1.5000000 -1.1289063 -2.070313 -0.4003906
2.1386719
>




More information about the R-help mailing list