How this calculation works
Diagonal similarity balancing transforms a square matrix A into B equal to D inverse A D, where D is diagonal with positive entries. This rescales the coordinate system while preserving exact eigenvalues. It differs from independently adjusting row and column totals, which generally changes the spectrum and solves a different problem.
B=D⁻¹ A D,with D diagonal and power-of-two entries.A worked example
For the default3×3 matrix,the one-norm changes from1002.1 to4.25. D has diagonal4096,4,0.5,and the direct similarity residual is zero.
Good to know
Real square matrix order1–6;bounded power-of-two Osborne-style updates using off-diagonal one-norms;no permutation isolation or condition-number/eigenvalue-accuracy guarantee.
Reference: Diagonal similarity balancing reference (opens in a new tab) ↗
Balance a matrix by changing coordinate scales
Diagonal similarity balancing transforms a square matrix A into B equal to D inverse A D, where D is diagonal with positive entries. This rescales the coordinate system while preserving exact eigenvalues. It differs from independently adjusting row and column totals, which generally changes the spectrum and solves a different problem.
The calculator uses powers of two for the diagonal scale factors and reports the balanced matrix, scale vector, matrix one-norms and a similarity residual. It supports finite real matrices of order one through six. The purpose is transparent numerical preprocessing, not a guarantee that every matrix calculation becomes more accurate.
Compare this with the Matrix balancing calculator with target row column totals. Find B=D^-1 A D to balance off-diagonal norms while preserving eigenvalues; row/column-total raking uses independent scalings and does not preserve spectrum.
Understand the row-column tradeoff
Changing one diagonal factor divides the corresponding row by that factor and multiplies the corresponding column by it. The diagonal entry remains unchanged. The algorithm compares off-diagonal row and column absolute sums, seeking a scaling that reduces their combined imbalance without altering the underlying linear transformation up to similarity.
A large row paired with a small column suggests increasing that coordinate scale; the opposite suggests decreasing it. Rows or columns with zero off-diagonal mass are skipped by this scaling pass. No permutation stage is performed, so structurally isolated blocks remain in their original order throughout the calculation.
Use radix-two updates for reproducibility
Each proposed factor is a power of two chosen from the row-to-column magnitude ratio, with a bounded exponent. The update is accepted only when the new combined off-diagonal sum improves sufficiently. Repeating these passes produces a deterministic small-matrix scaling under the stated traversal order.
Power-of-two multiplication and division avoid unnecessary rounding from arbitrary decimal scale factors when the values remain representable. That benefit does not eliminate floating-point error or prevent extreme input conditioning. The routine rejects excessive scale factors or a failure to settle within its bounded number of passes.
Inspect the strongly unbalanced example
The default matrix contains an entry one thousand in the first row while the corresponding reverse-direction entry is 0.001. Another pair contains ten and 0.1. Such disparities make a coordinate-scale adjustment natural without changing the exact eigenvalues or the diagonal entries one, two and three.
The returned scale vector is 4096, four and one half, giving a balanced matrix whose one-norm is 4.25 instead of 1002.1. Multiplying every scale by the same nonzero constant would produce the same balanced matrix. The scale ratios, rather than their shared overall normalization, define the similarity transformation.
Read the norm diagnostic precisely
The matrix one-norm is the largest absolute column sum. It is not the largest entry, the spectral radius or a direct condition number. A dramatic one-norm reduction can be helpful for some subsequent numerical algorithms, but it does not establish an equivalent dramatic reduction in eigenvalue sensitivity.
The similarity residual compares each returned balanced entry with the explicitly reconstructed A entry times its column scale divided by its row scale. A tiny residual checks the implemented transformation. It does not compare computed eigenvalues or prove that a downstream eigensolver will deliver more accurate eigenvectors in the original coordinates.
Transform vectors back with the correct convention
If v is a right eigenvector of B, then Dv is a right eigenvector of A for the same eigenvalue. Left eigenvectors transform with the inverse scaling. Forgetting this back-transformation can make balanced coordinates look like physical-state eigenvectors even though they represent a different numerical basis.
The calculator prints D through its diagonal entries and states the B equals D inverse A D convention. Preserve that convention when applying a result to a differential equation or matrix function. Reversing D and its inverse changes the entries and reverses the intended relation between coordinate representations.
Know when balancing may be unhelpful
Some already balanced matrices need no changes, and some sparse or highly structured matrices gain little from diagonal scaling alone. Balancing is not a replacement for a suitable decomposition or a careful study of an ill-conditioned eigenproblem. There are also problems where aggressive scaling can worsen parts of a subsequent calculation.
The page does not symmetrize the matrix, normalize probability transitions or impose prescribed margins. It returns a bounded deterministic similarity scaling with explicit diagnostics. Keep the original matrix, scale vector and balanced matrix together so any downstream improvement can be assessed against the transformation that was actually performed.
A few questions, answered
Is this row/column total raking?
No. The inverse left scaling is tied to the right scaling,so the operation is a similarity transformation.
Are eigenvalues preserved mathematically?
Yes,for a nonsingular diagonal D. Numerical eigensolver accuracy is a separate issue.
Must the norm decrease strictly?
No. An already balanced or structurally unscalable matrix may require no updates.
What are zero off-diagonal rows handled as?
They are skipped by the scaling step rather than divided by zero.