On 2/1/06, M. Edward (Ed) Borasky <znmeb / cesmail.net> wrote:
> I don't know what Ruby is doing here, but the R language gives a much
> different result for the matrix.
>
> Your input matrix:
>
>  > m1
>             [,1]        [,2]       [,3]
> [1,] -0.01082270 -0.22493468 -0.9743137
> [2,]  0.04682478  0.97318791 -0.2251949
> [3,] -0.99884449  0.04805924  0.0000000
>
> R's inverse, computed using the routine "ginv"
>
>  > library(MASS)
>  > m3<-ginv(m1)
>  > m3
>             [,1]        [,2]          [,3]
> [1,] -0.01082270  0.04682478 -9.988445e-01
> [2,] -0.22493468  0.97318791  4.805924e-02
> [3,] -0.97431374 -0.22519489  6.223320e-17

Comparing your inverse and Caleb's, they look pretty close. In only
did a cursory check of the first few digits in each number, but for
that they all matched up except the lower-right number. In that slot
Caleb's was of magnitude e-11 and R's is e-17. I blame that
discrepancy on different approaches and/or convergence criteria
(guessing that it's using a numerical approach).

There's big differences however between Caleb's inverse and Todd's,
same as between yours and Todd's. My only guess is that looking at
Todd's irb session he seems to be using Matrix#inverse while Caleb is
using Matrix#inv. The documentation[1], however, states that
Matrix#inv is just an alias for Matrix#inverse. So I'm not sure what
this is.

Todd, are there any other libraries you're loading which may be
changing the definition of Matrix#inverse?

Jacob Fugal

[1] http://www.ruby-doc.org/stdlib/libdoc/matrix/rdoc/classes/Matrix.html#M001009