Different precision of eig() in Matlab 7.1 and Matlab 7.9

2 Ansichten (letzte 30 Tage)
Wilson Bardeskar
Wilson Bardeskar am 17 Okt. 2011
When I run the eig() command in versions 7.1 and 7.9. I get different values for the Eigenvectors for the same Input Matrix. Even the signs seem to change for some elements. There are some modifications bty mathworks in the eig code but I am not able to find out what.
I need to get the values like in Version 7.1 from 7.9 Version. Can anybody tell how it can be done?
*From 7.1 -------------------------------------
>> B = [ 3 -2 -.9 2*eps; ...
-2 4 1 -eps; ...
-eps/4 eps/2 -1 0; ...
-.5 -.5 .1 1 ];
>> [VB,DB] = eig(B)
VB =
-0.6153 0.4176 0.0000 -0.1496
0.7881 0.3261 0.0000 0.1317
0.0000 0.0000 -0.0000 -0.9576
-0.0189 -0.8481 -1.0000 0.2078
DB =
5.5616 0 0 0
0 1.4384 0 0
0 0 1.0000 0
0 0 0 -1.0000
From 7.9 -------------------------------------
>> B = [ 3 -2 -.9 2*eps
-2 4 1 -eps
-eps/4 eps/2 -1 0
-.5 -.5 .1 1 ];
>> [VB,DB] = eig(B)
VB =
0.6153 -0.4176 -0.0000 -0.1437
-0.7881 -0.3261 -0.0000 0.1264
-0.0000 -0.0000 -0.0000 -0.9196
0.0189 0.8481 1.0000 0.3432
DB =
5.5616 0 0 0
0 1.4384 0 0
0 0 1.0000 0
0 0 0 -1.0000*
[EDITED, JSimon, 17-Oct-2011, 07:15 UTC, code formatted, B looked like a vector]
  1 Kommentar
Jan
Jan am 17 Okt. 2011
Please read the "Markup help" link abozut formatting the code. Using linebreaks as separators of rows is prone to errors, therefore I recommend to insert semicolons explicitely. The distribution of white-space characters should not change the results.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 17 Okt. 2011
In the releasenotes you find the documented change of the linear algebra libs:
MATLAB now uses new versions of the Basic Linear Algebra Subroutine (BLAS)
libraries. For Intel processors on Windows and Linux platforms, MATLAB supports
the Math Kernel Library (MKL) version 8.0.1. For AMD processors on Linux
platforms, MATLAB uses the AMD Core Math Library (ACML) version 2.7.
[EDITED, JSimon, 17-Oct-2011 15:27 UTC]
Now I see the problem.
B = [ 3, -2, -0.9, 2*eps; ...
-2, 4, 1, -eps; ...
-eps/4, eps/2, -1, 0; ...
-0.5, -0.5, 0.1 1];
[V, D] = eig(B);
% Matlab 2009a:
B*V - V*D
>> [1.7764e-015 1.1102e-016 -4.9304e-032 3.8858e-016
0 -5.5511e-016 1.2326e-031 -4.4409e-016
1.2326e-032 -1.5407e-032 1.3241e-033 2.2204e-016
0 1.3323e-015 7.7716e-016 0.6031]
^^^^^^
% Matlab 6.5:
B*V - V*D
>> [ -8.8818e-016 1.1102e-016 9.8608e-032 6.3838e-016
8.8818e-016 2.7756e-016 3.4513e-031 -2.2204e-016
4.9304e-032 1.2326e-032 1.1002e-032 2.2204e-016
9.7145e-017 4.4409e-016 0 0.44227]
^^^^^^^
The last element of the residual is in both cases much too large due to rounding errors. The matrix B suffers from the balancing!
[V, D] = eig(B, 'nobalance');
B*V - V*D
% 2009a:
>> [-2.6645e-015 1.1102e-016 -5.5875e-016 -1.6653e-016
4.4409e-015 1.2212e-015 3.3637e-016 -2.498e-016
2.1795e-017 1.8112e-018 6.6297e-018 0
3.3307e-016 -2.2204e-016 2.2204e-016 1.1102e-016]
% Matlab 6.5:
>> [ -2.6645e-015 0 -3.2346e-016 -2.7756e-017
4.4409e-015 1.1102e-015 4.2267e-017 -2.498e-016
2.1795e-017 1.8112e-018 6.6297e-018 0
5.5511e-017 -4.4409e-016 4.4409e-016 8.3267e-017]
  5 Kommentare
Walter Roberson
Walter Roberson am 17 Okt. 2011
Wilson, some of the vectors merely point in the opposite direction (sign change on all elements.) The direction of the vector is not specified in the eig() documentation and should not be relied upon.
Everything else is just small roundoff changes, which one must expect with eig even with the same MATLAB version if one uses a different processor. If you needed something more accurate you would need to switch over to symbolic computation -- the number of "guard digits" needed for "correct" numeric calculation of eigenvalues is pretty much unbounded.
Jan
Jan am 17 Okt. 2011
@Andreas: Please send me the address of the customer. I have collection of ready-to-use bugs, my so called "toolbugs". Perhaps he is interested in buying them.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by