MATLAB Function Reference | ![]() ![]() |
Improve accuracy of computed eigenvalues
Syntax
[T,
B] = balance(A)
B = balance(A)
Description
[T,B] = balance(A)
returns a permutation of a diagonal matrix T
whose elements are integer powers of two, and a balanced matrix B
so that B = T\A
*T
. If A
is symmetric, then B == A
and T
is the identity matrix.
B = balance(A)
returns just the balanced matrix B
.
Remarks
Nonsymmetric matrices can have poorly conditioned eigenvalues. Small perturbations in the matrix, such as roundoff errors, can lead to large perturbations in the eigenvalues. The quantity which relates the size of the matrix perturbation to the size of the eigenvalue perturbation is the condition number of the eigenvector matrix,
cond(V) = norm(V)*norm(inv(V))
[V,T] = eig(A)
(The condition number of A
itself is irrelevant to the eigenvalue problem.)
Balancing is an attempt to concentrate any ill conditioning of the eigenvector matrix into a diagonal scaling. Balancing usually cannot turn a nonsymmetric matrix into a symmetric matrix; it only attempts to make the norm of each row equal to the norm of the corresponding column. Furthermore, the diagonal scale factors are limited to powers of two so they do not introduce any roundoff error.
MATLAB's eigenvalue function, eig(A)
, automatically balances A
before computing its eigenvalues. Turn off the balancing with eig(A,'nobalance')
.
Examples
This example shows the basic idea. The matrix A
has large elements in the upper right and small elements in the lower left. It is far from being symmetric.
A = [1 100 10000; .01 1 100; .0001 .01 1] A = 1.0e+04 * 0.0001 0.0100 1.0000 0.0000 0.0001 0.0100 0.0000 0.0000 0.0001
Balancing produces a diagonal T
matrix with elements that are powers of two and a balanced matrix B
that is closer to symmetric than A
.
[T,
B] = balance(A)
T =
1.0e+03 *
2.0480 0 0
0 0.0320 0
0 0 0.0003
B =
1.0000 1.5625 1.2207
0.6400 1.0000 0.7813
0.8192 1.2800 1.0000
To see the effect on eigenvectors, first compute the eigenvectors of A
.
[V,E] = eig(A); V V = -1.0000 0.9999 0.9937 0.0050 0.0100 -0.1120 0.0000 0.0001 0.0010
Note that all three vectors have the first component the largest. This indicates V
is badly conditioned; in fact cond(V)
is 8.7766e+003
. Next, look at the eigenvectors of B
.
[V,
E] = eig(B); V
V =
-0.8873 0.6933 0.0898
0.2839 0.4437 -0.6482
0.3634 0.5679 -0.7561
Now the eigenvectors are well behaved and cond(V)
is 1.4421
. The ill conditioning is concentrated in the scaling matrix; cond(T)
is 8192
.
This example is small and not really badly scaled, so the computed eigenvalues of A
and B
agree within roundoff error; balancing has little effect on the computed results.
Algorithm
The eig
function automatically uses balancing to prepare its input matrix. balance
uses LAPACK routines DGEBAL
(real) and ZGEBAL
(complex). If you request the output T
, it also uses the LAPACK routines DGEBAK
(real) and ZGEBAK
(complex).
Limitations
Balancing can destroy the properties of certain matrices; use it with some care. If a matrix contains small elements that are due to roundoff error, balancing may scale them up to make them as significant as the other elements of the original matrix.
See Also
References
[1] Anderson, E., Z. Bai, C. Bischof, S. Blackford, J. Demmel, J. Dongarra, J. Du Croz, A. Greenbaum, S. Hammarling, A. McKenney, and D. Sorensen, LAPACK User's Guide, Third Edition, SIAM, Philadelphia, 1999.
![]() | axis | bar, barh | ![]() |