DSPRelated.com
Forums

Eigenvalue Accuracy in Matlab

Started by Randy Yates December 10, 2005
Hi Folks,

Consider the following integer matrix:

A =

     1     0    -1
    -1     1     0
     3    -1    -2

A is a nilpotent matrix of index 3, as can be seen by evaluating A^3. 
So then the only eigenvalues of A are zero. 

However, Matlab's "eig" function returns:

ans =

    -7.178125070607518e-006                         
     3.589062535291640e-006 +6.216541114106220e-006i
     3.589062535291640e-006 -6.216541114106220e-006i

Is there no way to get exact results for such simple matrices? Or
is there a way to establish some sort of rounding for these types
of functions?
-- 
%  Randy Yates                  % "So now it's getting late,
%% Fuquay-Varina, NC            %    and those who hesitate
%%% 919-577-9882                %    got no one..."
%%%% <yates@ieee.org>           % 'Waterfall', *Face The Music*, ELO
http://home.earthlink.net/~yatescr
 

"Randy Yates" <yates@ieee.org> wrote in message 
news:irtwxu9y.fsf@ieee.org...
> Hi Folks, > > Consider the following integer matrix: > > A = > > 1 0 -1 > -1 1 0 > 3 -1 -2 > > A is a nilpotent matrix of index 3, as can be seen by evaluating > A^3. > So then the only eigenvalues of A are zero. > > However, Matlab's "eig" function returns: > > ans = > > -7.178125070607518e-006 > 3.589062535291640e-006 +6.216541114106220e-006i > 3.589062535291640e-006 -6.216541114106220e-006i > > Is there no way to get exact results for such simple matrices? Or > is there a way to establish some sort of rounding for these types > of functions? > -- > % Randy Yates % "So now it's getting late, > %% Fuquay-Varina, NC % and those who hesitate > %%% 919-577-9882 % got no one..." > %%%% <yates@ieee.org> % 'Waterfall', *Face The Music*, ELO > http://home.earthlink.net/~yatescr >
If you want accurate use symbolic.
>>
A = 1 0 -1 -1 1 0 3 -1 -2
>> eig(sym(A))
ans = 0 0 0 Nasser
"Nasser Abbasi" <nma@12000.org> writes:
> [...] > If you want accurate use symbolic.
Very nice! Thanks Nasser. -- % Randy Yates % "Ticket to the moon, flight leaves here today %% Fuquay-Varina, NC % from Satellite 2" %%% 919-577-9882 % 'Ticket To The Moon' %%%% <yates@ieee.org> % *Time*, Electric Light Orchestra http://home.earthlink.net/~yatescr
"Randy Yates" <yates@ieee.org> wrote in message
news:irtwxu9y.fsf@ieee.org...
> Hi Folks, > > Consider the following integer matrix: > > A = > > 1 0 -1 > -1 1 0 > 3 -1 -2 > > A is a nilpotent matrix of index 3, as can be seen by evaluating A^3. > So then the only eigenvalues of A are zero. >
schur(A) is upper triangular with A's eigenvalues along the diagonal. -- HTH, Hrundi V.B.
"Mr Hrundi V Bakshi" <mrhrundivbakshi@hotmail.com> writes:

> "Randy Yates" <yates@ieee.org> wrote in message > news:irtwxu9y.fsf@ieee.org... >> Hi Folks, >> >> Consider the following integer matrix: >> >> A = >> >> 1 0 -1 >> -1 1 0 >> 3 -1 -2 >> >> A is a nilpotent matrix of index 3, as can be seen by evaluating A^3. >> So then the only eigenvalues of A are zero. >> > > schur(A) is upper triangular with A's eigenvalues along the diagonal.
Same problem. -- % Randy Yates % "...the answer lies within your soul %% Fuquay-Varina, NC % 'cause no one knows which side %%% 919-577-9882 % the coin will fall." %%%% <yates@ieee.org> % 'Big Wheels', *Out of the Blue*, ELO http://home.earthlink.net/~yatescr
"Randy Yates" <yates@ieee.org> wrote in message
news:fyp0wbm9.fsf@ieee.org...
> "Mr Hrundi V Bakshi" <mrhrundivbakshi@hotmail.com> writes: > > > "Randy Yates" <yates@ieee.org> wrote in message > > news:irtwxu9y.fsf@ieee.org... > >> Hi Folks, > >> > >> Consider the following integer matrix: > >> > >> A = > >> > >> 1 0 -1 > >> -1 1 0 > >> 3 -1 -2 > >> > >> A is a nilpotent matrix of index 3, as can be seen by evaluating A^3. > >> So then the only eigenvalues of A are zero. > >> > > > > schur(A) is upper triangular with A's eigenvalues along the diagonal. > > Same problem.
Nah, ans = -0.0000 -1.2247 -2.1213 0 0.0000 -3.4641 0 0.0000 0.0000
In article <irtwxu9y.fsf@ieee.org>, Randy Yates <yates@ieee.org> wrote:

> Hi Folks, > > Consider the following integer matrix: > > A = > > 1 0 -1 > -1 1 0 > 3 -1 -2 > > A is a nilpotent matrix of index 3, as can be seen by evaluating A^3. > So then the only eigenvalues of A are zero. > > However, Matlab's "eig" function returns: > > ans = > > -7.178125070607518e-006 > 3.589062535291640e-006 +6.216541114106220e-006i > 3.589062535291640e-006 -6.216541114106220e-006i > > Is there no way to get exact results for such simple matrices? Or > is there a way to establish some sort of rounding for these types > of functions?
No. Not without use of symbolic tools. Even they must fail miserably on a "simple" 5x5 matrix. Ask Galois why. Remember that solving for the eigenvalues of a matrix is a problem highly related to finding the roots of a polynomial. The characteristic polynomial of this matrix is a cubic polynomial with a root at zero of multiplicity 3. Its a surprisingly hard problem to solve exactly for a root-finding tool. Note that the accuracy of these eigenvalues is on the order of the cube root of eps. Its no coincidence. HTH, John D'Errico
In article <irtwxu9y.fsf@ieee.org>, Randy Yates <yates@ieee.org> wrote:

> Hi Folks, > > Consider the following integer matrix: > > A = > > 1 0 -1 > -1 1 0 > 3 -1 -2 > > A is a nilpotent matrix of index 3, as can be seen by evaluating A^3. > So then the only eigenvalues of A are zero. > > However, Matlab's "eig" function returns: > > ans = > > -7.178125070607518e-006 > 3.589062535291640e-006 +6.216541114106220e-006i > 3.589062535291640e-006 -6.216541114106220e-006i > > Is there no way to get exact results for such simple matrices? Or > is there a way to establish some sort of rounding for these types > of functions? > -- > % Randy Yates
---------------------------- As to the numerical computation of A's eigenvalues, in this case they are the roots to the cubic equation 0 = det(A - lambda*eye(3)) = -lambda^3 Suppose that matlab, in the process of carrying out a complicated algorithm for eigenvalue/eigenvector solutions makes a very small roundoff error out in the 16-th decimal place in the process and arrives at this equation -lambda^3 = 3.698563363842292e-16 instead. In this case the solutions for lambda would be: -7.178125070607523e-06 3.589062535303763e-06 + 6.216438662688082e-06i 3.589062535303763e-06 - 6.216438662688082e-06i which are quite close to those you obtained! The point here is that, for this particular ill-conditioned matrix, a very small rounding error in computing the eigenvalue equation, well within the limits that could be expected for 64-bit floating point accuracy, will result in greatly expanded errors for the eigenvalues themselves. Such instability is inherent in a matrix in which a multiplicity of its eigenvalues are at, or very close to, zero. (Remove "xyzzy" and ".invalid" to send me email.) Roger Stafford
"Mr Hrundi V Bakshi" <mrhrundivbakshi@hotmail.com> writes:

> "Randy Yates" <yates@ieee.org> wrote in message > news:fyp0wbm9.fsf@ieee.org... > > "Mr Hrundi V Bakshi" <mrhrundivbakshi@hotmail.com> writes: > > > > > "Randy Yates" <yates@ieee.org> wrote in message > > > news:irtwxu9y.fsf@ieee.org... > > >> Hi Folks, > > >> > > >> Consider the following integer matrix: > > >> > > >> A = > > >> > > >> 1 0 -1 > > >> -1 1 0 > > >> 3 -1 -2 > > >> > > >> A is a nilpotent matrix of index 3, as can be seen by evaluating A^3. > > >> So then the only eigenvalues of A are zero. > > >> > > > > > > schur(A) is upper triangular with A's eigenvalues along the diagonal. > > > > Same problem. > > Nah, > > ans = > > -0.0000 -1.2247 -2.1213 > 0 0.0000 -3.4641 > 0 0.0000 0.0000
Yup! &#4294967295; diag(schur(A)) ans = 1.0e-004 * -0.0872 0.5866 -0.4994
John D'Errico <NoKnownAddress@noplace.com> writes:

> In article <irtwxu9y.fsf@ieee.org>, Randy Yates <yates@ieee.org> wrote: > >> Hi Folks, >> >> Consider the following integer matrix: >> >> A = >> >> 1 0 -1 >> -1 1 0 >> 3 -1 -2 >> >> A is a nilpotent matrix of index 3, as can be seen by evaluating A^3. >> So then the only eigenvalues of A are zero. >> >> However, Matlab's "eig" function returns: >> >> ans = >> >> -7.178125070607518e-006 >> 3.589062535291640e-006 +6.216541114106220e-006i >> 3.589062535291640e-006 -6.216541114106220e-006i >> >> Is there no way to get exact results for such simple matrices? Or >> is there a way to establish some sort of rounding for these types >> of functions? > > > No. Not without use of symbolic tools. Even they must > fail miserably on a "simple" 5x5 matrix. Ask Galois > why. > > Remember that solving for the eigenvalues of a matrix > is a problem highly related to finding the roots of > a polynomial. The characteristic polynomial of this > matrix is a cubic polynomial with a root at zero of > multiplicity 3. Its a surprisingly hard problem to > solve exactly for a root-finding tool. Note that the > accuracy of these eigenvalues is on the order of the > cube root of eps. Its no coincidence.
Thank you very much, John, not only for the answer, but for the insight on why. Makes perfect sense. -- % Randy Yates % "Ticket to the moon, flight leaves here today %% Fuquay-Varina, NC % from Satellite 2" %%% 919-577-9882 % 'Ticket To The Moon' %%%% <yates@ieee.org> % *Time*, Electric Light Orchestra http://home.earthlink.net/~yatescr