Compute the condition number κ(A) of a 2×2 matrix and visualize its ill-conditioning. As you change the matrix entries, the singular values, determinant and solution error amplification update in real time, and the image of the unit circle shows you intuitively how badly a tiny data error can corrupt the numerical solution of A·x=b.
Parameters
Matrix entry a11
Row 1, column 1 (top-left) entry of matrix A
Matrix entry a12
Row 1, column 2 (top-right) entry of matrix A
Matrix entry a21
Row 2, column 1 (bottom-left) entry of matrix A
Matrix entry a22
Row 2, column 2 (bottom-right) entry of matrix A
Perturbation size δ of input b
Tiny error added to the right-hand-side vector b. The tool measures how much it is amplified in the solution x
Results
—
Condition number κ(A)
—
Max singular value σ_max
—
Min singular value σ_min
—
Determinant det(A)
—
Solution error amplification
—
Conditioning verdict
—
Linear map — unit circle to ellipse
Matrix A maps the unit circle into an ellipse. The semi-axis lengths are exactly σ_max and σ_min. A near-circular ellipse means well-conditioned; a thin sliver means ill-conditioned.
Singular values and condition number
Error amplification — solution error vs input error
The 2-norm condition number κ(A). σ_max and σ_min are the largest and smallest singular values of A — the stretch factors of A's most-stretched and most-compressed directions.
The error bound. A relative error in the right-hand side b can be magnified in the solution x by at most a factor κ(A). κ=1 is ideal (no amplification); κ≫1 is ill-conditioned and numerically dangerous.
How the singular values are found. The square roots of the eigenvalues λ of the symmetric matrix M=AᵀA are the singular values of A. For a 2×2, the eigenvalues follow analytically from the trace and determinant.
What is the Matrix Condition Number?
🙋
The term "condition number" came up in my numerical methods class — but what number is it, really?
🎓
In plain terms, it measures "how sensitive this problem is to tiny errors in the data". Think of solving a linear system A·x=b. The right-hand side b is often a measurement, so it always carries a little error. The condition number κ(A) is the worst-case factor by which that relative error in b is magnified into the relative error of the answer x. If κ is 1, the error passes through unchanged; if κ is 1000, it can blow up to 1000× in the worst case.
🙋
Whoa, up to 1000× in the worst case... With the default sliders κ already reads about 399. How is that computed?
🎓
The 2-norm condition number is κ(A)=σ_max/σ_min — the largest singular value divided by the smallest. A singular value tells you how much the matrix A "stretches or compresses" space, and the canvas above makes it visible. A maps the unit circle into an ellipse, whose long semi-axis is σ_max and short semi-axis is σ_min. With the default matrix the ellipse becomes a flattened cigar shape, right? σ_max≈3.99 against σ_min≈0.01. Take the ratio and you get about 399.
🙋
I see — the flatter the ellipse, the worse the matrix. But I thought a small determinant (det) means nearly singular. Isn't det good enough?
🎓
Great question — and that is a very common misconception. The determinant is dragged around by scale. Multiply the whole matrix by 1000 and det grows a million times, yet the ill-conditioning has not changed at all. The condition number σ_max/σ_min is a ratio, so it is scale-invariant — that is the correct measure. The default matrix has det = 0.0399, small indeed, but what really matters is κ≈399. "Small det = looks singular" is only a hint; judge with κ.
🙋
There's a card lower down called "solution error amplification". Is that something different from κ?
🎓
That one is a "measured value". We take a fixed right-hand side b, perturb it by δ, actually solve the system twice, and measure how much the solution x changed. In theory this amplification always stays below κ — that is the inequality ‖Δx‖/‖x‖ ≤ κ·‖Δb‖/‖b‖. So κ is the "guaranteed worst case", and the amplification is "this particular measurement". The amplification stays roughly constant as you move the δ slider because the system is linear. Check the error-amplification chart below and see how κ acts as the ceiling.
🙋
So if I run into an ill-conditioned matrix, what should I do?
🎓
The most important thing is to "notice" it. The real danger is solving naively without computing κ and trusting the answer. In practice, you scale rows and columns to lower the apparent κ, or use stable algorithms like LU with partial pivoting or QR factorization. For least-squares problems, avoid the normal equations (which square the condition number) and use QR or SVD. If the problem is intrinsically ill-conditioned, stabilize the solution with regularization such as ridge regression. The point is: know κ first, then pick a method that matches it.
Frequently Asked Questions
The condition number κ(A) is the worst-case factor by which a relative error in the data b (or in the matrix A, or in floating-point rounding) of a linear system A·x=b can be magnified in the solution x. In the 2-norm it is defined as κ(A)=σ_max/σ_min, the largest singular value divided by the smallest. κ≈1 is perfectly conditioned (an orthogonal matrix), while a large κ means the matrix is nearly singular and the numerical solution is unreliable.
From the error bound ‖Δx‖/‖x‖ ≤ κ(A)·‖Δb‖/‖b‖, the larger κ is, the more a small input error blows up in the solution. For example, if κ=10^6, a relative data error of 10^-7 can be amplified to 10^-1 (10%) in the solution. Even the rounding error of double precision (about 10^-16) is enough to destroy the significant digits once κ exceeds about 10^14. The condition number measures the numerical trustworthiness of a linear system.
A small determinant det(A) is often said to mean 'nearly singular', but det depends on scale and is a poor measure of ill-conditioning. Multiplying the whole matrix by 1000 multiplies det by 10^6, yet the condition number does not change at all. The condition number is the ratio σ_max/σ_min, so it is scale-invariant and reflects ill-conditioning correctly. A det near 0 is only a hint of singularity; whether a matrix is ill-conditioned should be judged by κ.
First, revisit how the problem is formulated. Scaling (normalizing rows and columns) can sometimes improve the apparent condition number. If the problem is intrinsically ill-conditioned, use a stable algorithm with pivoting (LU with partial pivoting, QR factorization), and for least-squares problems use QR or SVD instead of the normal equations. Regularization (ridge regression, Tikhonov regularization) can further stabilize the solution. The key is to know the condition number in advance and choose a method that matches it.
Real-World Applications
Finite element (FEM) stiffness matrices: The stiffness matrix of a structural analysis becomes ill-conditioned when thin elements, extreme aspect-ratio meshes and widely varying material stiffnesses are mixed. A bad condition number makes iterative solvers (such as conjugate gradient) converge painfully slowly, and even direct solvers produce displacements and stresses corrupted by rounding error. CAE engineers police mesh quality so strictly not just for appearance, but to keep the stiffness matrix's condition number healthy.
Least squares and regression: In polynomial regression or with strongly correlated predictors, the normal-equations matrix AᵀA·x=Aᵀb becomes nearly singular. Since the condition number of AᵀA is the square of that of A, ill-conditioning suddenly becomes far more severe. This is exactly what "multicollinearity" is, and it is why regression coefficients swing wildly under observation noise. In practice it is handled with QR factorization, SVD or ridge regression.
Inverse problems and image restoration: Inverse problems such as CT reconstruction, deconvolution and geophysical inversion are intrinsically ill-conditioned (often "ill-posed" with a condition number near infinity). Because tiny noise in the measured data badly disturbs the reconstruction, Tikhonov regularization or truncated SVD adds "smoothness" or prior knowledge to stabilize the solution. The concept of the condition number guides the choice of these regularization parameters.
Control theory and numerical optimization: The controllability and observability Gramians of a state-space model, and the Hessian of a quadratic form in optimization, are also assessed by their condition number. When the Hessian's condition number is large, steepest descent zig-zags down a "long narrow valley" and converges slowly. That is why Newton's method or preconditioned gradient methods are needed — the condition number is a common language for numerical method selection.
Common Misconceptions and Pitfalls
The biggest misconception is "a small determinant means ill-conditioned and a large one means well-conditioned". The determinant det(A) depends entirely on scale. For example, the 2×2 identity matrix scaled by 0.001, that is 0.001·I, has a det of only 10^-6 yet a condition number of 1 (perfectly well-conditioned). Conversely, a matrix with a large det can be extremely ill-conditioned. The condition number σ_max/σ_min is a ratio, so it is scale-invariant — it is the only correct measure of ill-conditioning. Keep det as merely a "hint of singularity".
Next, "a large condition number is the matrix's or algorithm's fault" is a misconception. The condition number is a property intrinsic to the problem itself, independent of how you solve it. A problem with κ=10^10 will, no matter how excellent the algorithm, amplify input errors up to 10^10× — that fact does not change. A good (backward-stable) algorithm only guarantees that "the algorithm itself does not add extra error"; the error amplification caused by the problem's intrinsic condition number is unavoidable. An ill-conditioned problem can only be improved by changing the problem formulation, not the solver.
Finally, the belief that "a small residual means an accurate solution". For a solution x̂ of a linear system, even if the residual ‖b−A·x̂‖ is small, the error ‖x−x̂‖ from the true solution is not necessarily small. The error can be as large as the residual multiplied by the condition number — with an ill-conditioned matrix, "the residual is almost zero yet the solution is completely wrong" really happens. Conversely, under ill-conditioning even an x close to the true solution can show a large residual. Judging accuracy from the residual alone is dangerous; always evaluate it together with the condition number.
How to Use
Enter matrix elements a₁₁, a₁₂, a₂₁, a₂₂ into the input fields or drag the range sliders to modify coefficients between -10 and +10.
Click "Compute" to calculate singular values σ_max and σ_min, determinant det(A), and condition number κ(A) = σ_max/σ_min.
Consider a 2×2 stiffness matrix from a 1D bar element: A = [[200, -200], [-200, 200]] (units: kN/mm). σ_max = 400, σ_min = 0.0001 due to rigid-body mode, κ(A) ≈ 4,000,000. When solving for nodal displacement with 0.1% input perturbation, solution error amplifies to 400,000%, making iterative refinement essential. Applying boundary constraints reduces κ to ~1, restoring numerical stability.
Practical Notes
Nearly singular matrices (det(A) ≈ 0) produce κ(A) > 10⁷; preconditioning or rank-revealing QR factorization mitigates round-off in Gaussian elimination solvers.
Structural mechanics: mass matrices with κ(A) > 10⁵ cause poor convergence in conjugate-gradient eigenvalue algorithms; scale by dividing by max diagonal entry.
CFD pressure-correction schemes exhibit κ(A) scaling as O(1/h²) for grid spacing h; use multigrid or incomplete LU preconditioners for h < 0.01 m domains.
Matrix reordering (Cuthill-McKee) and equilibration (scaling rows/columns by 1/√|aᵢᵢ|) reduce κ before sparse LU decomposition without altering solution.