```-------- Original-Nachricht --------
> Datum: Thu, 22 Nov 2007 17:05:09 +0900
> Von: unbewusst.sein / weltanschauung.com.invalid
> An: ruby-talk / ruby-lang.org
> Betreff: eigenvector discrepency was (Re: [Matrix] eigenvalues, eigenvectors in Ruby ???)

Eigenvectors form an orthogonal basis of a vector space. As a basis
is just a maximal set of linear independent vectors, there
are infinitely many of them ... the only condition is that they
span the eigenspace corresponding to the eigenvalue.
So, if the eigenvalue equations matrix*vector=eigenvalue*vector
hold, I'd not be concerned.

> Cameron McBride <cameron.mcbride / gmail.com> wrote:
>
> > Do you know right off how its accuracy compares to GSL/LAPACK routines?

That statement refers to inaccuracies in numerical
calculations introduced due to the fact that Float or Double precision
numbers cannot exactly represent certain numbers (this
actually holds true for any number that is not a 'very' finite
sum of powers of 2 and (1/2) - think of
1/10, sqrt(2),sqrt(3), pi.
It has nothing to do with differences in eigenvectors, even though
an entry in them might probably be 1/sqrt(2), rather than 0.7172,
as a numerical software might claim.
Now, as we know thanks to Ed Borasky, in Ruby, you have two choices:

a.) use bindings to GSL or R or Lapack or ... , and thus ultimately to do calculations in a fast language like C or Fortran, which
uses Double precision, and gives a fast, yet not quite exact result.
That's what you would do almost exclusively. People who teach numerics
at universities will tell you you can't do otherwise (i.e., that's
their translation of the English "Matlab,
Octave etc. can't do otherwise unless you rewrite almost everything
- once for being able to use Rationals, and then again, to be able
to use continued fractions - because you learned about them only
two months later ....")

b.) use a pure Ruby, object-oriented implementation of numerical
algorithms as in the extended matrix.rb suggested by Ed Borasky.
That will give you exact calculations using Rationals right away,
and exact results of expressions like sqrt(2)+sqrt(3) via a
(yet to be written addition method for a class of continued fractions,
see http://perl.plover.com/yak/cftalk/, as the expressions
for sqrt(2) and sqrt(3) lead to periodic continued fractions, i.e.,
representations involving finite information).
The calculations to be done are far more involved than adding two Floats,
and, additionally, Ruby is slower than C or Fortran, but it can be done,
using Ruby, in very finite coding time.

In most situations, sticking with a.) is ok., but if you really
wanted b.), no numerical software will do it for you, unless you rewrite
a substantial part of the code ... in Ruby, you just define
another class and some methods to it.

Best regards,

Axel

>
> I don't know, however i found a discreapency between GSL and
> extendedMatrix for eigenvectors :
>
> require 'extendmatrix.rb'
>
> a = Matrix[ [ 0, 1, 1, 0 ],
>             [ 1, 0, 1, 0 ],
>             [ 1, 1, 0, 1 ],
>             [ 0, 0, 1, 0 ] ]
>
> p a.det
> # => 2
> p a.trace
> # => 0
> p a.eigenvaluesJacobi
> # Vector[-1.0, 2.17008648662603, -1.48119430409202, 0.311107817465982]
> # GSL : a.eigval = [ 2.170e+00 3.111e-01 -1.000e+00 -1.481e+00 ]
> p a.cJacobiV
> =begin
> Matrix[[0.707106781186547, 0.522720725656538, -0.302028136647909,
> -0.368160355880552],
>       [-0.707106781186547, 0.522720725656538, -0.302028136647909,
> -0.368160355880552],
>       [0.0, 0.611628457346727, 0.749390492326316, 0.253622791118195],
>       [0.0, 0.281845198827065, -0.505936655478633, 0.815224744804294]]
> GSL : a.eigvec =
>     [  5.227e-01  3.682e-01 -7.071e-01  3.020e-01
>        5.227e-01  3.682e-01  7.071e-01  3.020e-01
>        6.116e-01 -2.536e-01 -9.158e-16 -7.494e-01
>        2.818e-01 -8.152e-01  4.852e-16  5.059e-01 ]
> =end
>
> the eigenvalues are "the same" however eigenvectors doesn't have even
> the same sign to within a multiplicative constant ???
>
> what did i miss this morning ?
> a cofee cup ??
> --
> Une Bñ×ue

--
Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten