Definition
A matrix represents a linear transformation; a square matrix is invertible only if its determinant is non-zero, and the condition number measures how much a small input error is amplified. Eigenvalues describe stretching along special directions. A derivative is a local rate of change, a gradient points in the direction of fastest increase, and a Taylor expansion approximates a function with first- and second-order terms. Numerical stability means an algorithm still gives trustworthy results under floating-point error.
Intuition
A matrix is a table that puts several variables on the table at once; solving a linear system means finding values that satisfy all equations simultaneously. Calculus is a magnifying glass: over a small range, a curved function looks like a straight line, and the slope approximates the change. Numerical stability means the magnifying glass must not magnify noise: if a matrix is nearly singular, a tiny input error becomes a large solution error; if a finite-difference step is too small, floating-point rounding eats the significant digits. Regression, covariance, portfolio optimisation and option pricing all end up in these two ideas.
Mechanism
When solving linear systems, explicit inversion amplifies rounding error when the condition number is large; LU, QR or regularised least squares are more stable. Collinearity in regression makes the design matrix nearly singular, inflating coefficient variance and sometimes reversing signs. In optimisation, scale differences make gradient descent oscillate along one direction; standardisation, preconditioning and log transforms improve conditioning. Taylor approximation is local only; with a large step the second-order term cannot be ignored. Floating point has finite precision, and subtracting large nearly equal numbers loses digits, so avoid it [2][3].
Worked example
Suppose A = [[1, 1], [1, 1.0001]], with determinant about 0.0001 and condition number about 40,000. If the second element of b has an error of 0.0001, the solution can move by about one unit; apparently precise inputs produce very different coefficients. For f(x)=x² at x=10, a first-order Taylor approximation gives f(10.1)≈100+20×0.1=102 versus the true 102.01, an error of 0.01; with a step of 1, the approximation is 120 versus 121, an error of 1. If gradient scales differ by 1,000× before standardisation, one learning rate is too large for one variable and too small for another. These are teaching examples.
Second worked example: near-singular matrix and step size
Consider the system x + y = 2, x + 1.01y = 2.01, with solution x = 1, y = 1. If the second right-hand side rises by only 0.001 to 2.011, the system becomes x + 1.01y = 2.011, giving y = 1.1 and x = 0.9: a 0.05% change in the input causes a 10% change in the solution. The matrix [[1,1],[1,1.01]] has a condition number of about 400, so errors can be amplified hundreds of times. Another example: estimate the derivative of f(x) = x² at x = 3 with a forward difference. With step 0.01, (3.01² − 9)/0.01 = 6.01; with step 1e-8, floating-point rounding can push the result away from 6. Smaller is not always better; balance truncation error against rounding error. These are teaching examples.
Boundary and common mistakes
First, invertible is not well-conditioned: a tiny determinant or large condition number makes inversion unreliable. Second, high correlation does not automatically require dropping a variable; economic meaning and forecast objective matter. Third, a zero gradient is only a stationary point, not a global optimum; non-convex problems need multiple starts and constraint checks. Fourth, Taylor approximation is not global and fails far from the expansion point. Fifth, higher floating-point precision reduces rounding but cannot fix an ill-conditioned problem itself.
Failure modes
The first failure is solving least squares with normal equations: AᵀA squares the condition number, turning 400 into 160,000 and amplifying numerical error; use QR or SVD. The second is wildly different variable scales: one measured in yuan, another in millions, with six orders of magnitude between columns; the solver treats the small variable as noise. Standardise or scale first. The third is a finite-difference step so small that rounding drowns the derivative; use central differences, analytic derivatives or automatic differentiation. The fourth is extrapolating a linear approximation far from the expansion point; curvature makes the error uncontrollable. The fifth is ignoring floating-point precision and parallel summation order, which can make a covariance matrix lose positive definiteness.
Three checks
First, what is the matrix condition number, is it near singular, and do you need QR/SVD or regularisation? Second, are variables on the same scale, do they need standardisation, and is the numerical range of sums controllable? Third, are the approximation step and expansion point reasonable, and is there an analytic or numerical error bound? Beyond these, separate 'the model solves' from 'the answer is trustworthy': a solution is not necessarily a correct solution.
Adjacent concepts and a counterexample
Numerical stability is easily confused with model correctness and algorithm convergence. A correct model means the equations match the economic or statistical relationship; convergence means the iteration stops within finite steps; numerical stability means small input errors are not amplified into an untrustworthy solution. They are different: a correct model can be numerically unstable because the matrix is near singular, and a convergent algorithm can converge to a wrong answer. A counterexample is 'a small residual means the solution is right': a near-singular system can have a tiny residual while the solution is extremely sensitive to input error; check condition number, singular values and cross-validation, not residual alone. Another is 'a smaller step is more accurate': too small a finite-difference step is drowned by rounding and error rises. Compare methods on error bound, condition number, cost and reproducibility.
Scope and limits
This numerical-stability framework applies to linear algebra and optimisation problems where the matrix can be formed, the condition number estimated and error sources separated. If the matrix comes from a black-box simulation, is too large for singular values, or error is mainly in the data rather than the algorithm, condition analysis gives only partial information. It does not apply to treating convergence speed as correctness, nor to general solvers that ignore scaling and sparsity. Scale first, then check condition number and residual, and validate small cases against high precision or analytic solutions; a small residual does not prove a correct solution.
Finally, with inequality constraints or non-convex objectives, the condition number explains only local error; check active constraints, step size and starting values, and rerun from multiple starts to avoid mistaking local convergence for a global optimum.
If the matrix has missing values, check whether imputation changes the condition number; report solutions under alternative imputations side by side and run sensitivity analysis.
Also keep reproducible intermediate records and scripts.
Related
- RES-025 Mathematical Foundations: adjacent main article; read it before this supplement.
- RES-006 Indexing, Logarithms and Growth Rates: adjacent main article; read it before this supplement.
- RES-009 Probability Distributions, Expectation and Variance: adjacent main article; read it before this supplement.
- RES-013 Introduction to Linear Regression: adjacent main article; read it before this supplement.
Source note
This article uses NIST Physical Measurement Laboratory, OpenStax, Rice University, Cambridge University Press, 2020 to check definitions, institutions or measurement conventions; the exact terms, numbers and dates follow the sources [1][2][3].
Research problem
Matrices, calculus and numerical methods ask “under what conditions is this calculation credible?” The same formula can return a precise-looking but completely wrong answer when conditioning is poor, the step size is unsuitable or floating-point precision is insufficient.
Inputs
Inputs include matrices, vectors, functions, parameters, step sizes, iteration limits and tolerance; also record units, dimensions, data ranges and missing-value treatment.
Assumptions
The matrix is invertible or full rank, the function is continuous and differentiable, the step is small enough, and floating-point error is controllable. If the condition number approaches the inverse of machine precision, inversion and differences amplify rounding error.
Steps
Check units and scaling, inspect the condition number or spectral radius, choose a direct or iterative method, and for differences try several step sizes to see stability rather than picking the best-looking one.
Interpreting results
Report the value, residual, condition number and error magnitude together. A result near zero does not mean zero error; if the residual is large or the result is step-sensitive, it is only an approximation.
Failure conditions
Singular or near-singular matrices, ill-conditioned problems, steps too large or too small, non-convergence, overflow or underflow, and inconsistent units all invalidate the calculation.
Reproduction and verification
Keep the matrix, script, step sizes and precision settings; compare against a high-precision library or analytic solution, and verify with at least one alternative algorithm.
Figures in plain language
The four figures below check the mechanism, boundary and comparison in this article; labels come from its own sections, not new data.
Exercises
- Concept check: Concept check: are invertibility and numerical solvability the same thing?
- Calculation: Calculation: first-order Taylor approximation of f(x)=x² at x=3; estimate f(3.1) and give the true value.
- Boundary: Boundary: how does collinearity affect regression coefficients and prediction?
Answer key
- No. Invertibility only means the determinant is non-zero; with a large condition number, small input errors are amplified and the numerical solution is unreliable.
- Approximation 9 + 6×0.1 = 9.6; true value 9.61, error 0.01.
- Coefficient variance rises, signs can reverse and individual coefficients may be insignificant, while overall prediction can still work; interpret coefficients cautiously.
Sources
- National Institute of Standards and Technology. SI Units. NIST Physical Measurement Laboratory. U.S. Government work (public domain), 17 U.S.C. §105. https://www.nist.gov/pml/owm/metric-si/si-units (accessed 2026-11-21)
- OpenStax. Calculus Volume 1, 4.2 Linear Approximations and Differentials. OpenStax, Rice University. CC BY-NC-SA 4.0 (OpenStax Calculus Volume 1). https://openstax.org/books/calculus-volume-1/pages/4-2-linear-approximations-and-differentials (accessed 2026-11-21)
- Marc Peter Deisenroth, A. Aldo Faisal and Cheng Soon Ong. Mathematics for Machine Learning. Cambridge University Press, 2020. © authors; free PDF, linked summary only. https://mml-book.github.io/book/mml-book.pdf (accessed 2026-11-21)
Worked demo
Read-through check: can you say three things?
No recitation needed. Tick each sentence below and see whether you can explain the mechanism, one worked example and one boundary in your own words.
Ticked 0 / 3
The numbers are teaching assumptions that show relationships, not forecasts or investment advice.
This article has passed the current publication gate. Factual, calculation and translation revisions update both language versions together.