[D,B] = balance(A)
B = balance(A)
cond(V) = norm(V)*norm(inv(V))
where
[V,D] = 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.
[D,B] = balance(A)
returns a diagonal matrix D
whose elements are integer powers of two, and a balanced matrix B
so that
IfB = D\A
*D
A
is symmetric, then B == A
and D
is the identity.
B = balance(A)
returns just the balanced matrix B
.
MATLAB's eigenvalue function, eig(A)
, automatically balances A
before computing its eigenvalues. Turn off the balancing with eig(A,'nobalance')
.
A
has large elements in the upper right and small elements in the lower left. It is far from being symmetric.
Balancing produces a diagonalA = [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
D
matrix with elements which are powers of two and a balanced matrix B
which is closer to symmetric than A
.
To see the effect on eigenvectors, first compute the eigenvectors of[D,B] = balance(A)
D =
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.7812
0.8192 1.2800 1.0000
A
.
Note that all three vectors have the first component the largest. This indicates[V,E] = eig(A); V
V =
-1.0000 0.9999 -1.0000
0.0050 0.0100 0.0034
0.0000 0.0001 0.0001
V
is badly conditioned; in fact cond(V)
is 1.5325e+04
. Next, look at the eigenvectors of B
.
Now the eigenvectors are well behaved and[V,E] = eig(B); V
V =
-0.8873 0.6933 -0.8642
0.2839 0.4437 0.1887
0.3634 0.5679 0.4664
cond(V)
is 14.903
. The ill conditioning is concentrated in the scaling matrix; cond(D)
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.
balance
is built into the MATLAB interpreter. It uses the algorithm in [1] originally published in Algol, but popularized by the FORTRAN routines BALANC
and BALBAK
from EISPACK.
Successive similarity transformations via diagonal matrices are applied to A
to produce B
. The transformations are accumulated in the transformation matrix D
.
The eig
function automatically uses balancing to prepare its input matrix.
A
is not a square matrix:
Matrix must be square.
eig
,hess
,schur
(c) Copyright 1994 by The MathWorks, Inc.