What is a residual, and why should a numerical answer be checked?
A numerical output should be compared with the original mathematical conditions.
Learning goal
Understand residuals for linear systems and their role in checking numerical solutions.
Prerequisites
- Basic linear algebra
- Basic norm notation
Residual
For Ax=b and an approximate solution x̂, the residual measures what remains when x̂ is substituted into the equation.
Measuring the residual
A smaller norm means the computed result satisfies that equation more closely. In numerical work, scaling and conditioning also matter.
Connection to optimization
For a constrained solver, the objective value is not enough. Stationarity, primal feasibility, complementarity, and duality gap provide independent checks of solve quality.
Simple example
Here A x̂=[3,0], so the residual is zero. The transferable habit is to check the computed answer against the original equation.
Related project
Convex QP Solver
The project exposes numerical diagnostics for checking KKT-related conditions.
Open sourceHave a numerical problem?
We can define mathematical and numerical checks for the output.