Skip to main content\(\newcommand{\N}{\mathbb{N}}
\newcommand{\Z}{\mathbb{Z}}
\newcommand{\Q}{\mathbb{Q}}
\newcommand{\R}{\mathbb{R}}
\newcommand{\dimens}{\operatorname{dim}}
\DeclareMathOperator{\row}{\operatorname{row}}
\DeclareMathOperator{\col}{\operatorname{col}}
\newcommand{\im}{\operatorname{im}}
\newcommand{\nulls}{\operatorname{null}}
\newcommand{\minor}{\operatorname{minor}}
\newcommand{\spans}{\operatorname{span}}
\newcommand{\nullity}{\operatorname{nullity}}
\newcommand{\kers}{\operatorname{ker}}
\newcommand{\proj}{\operatorname{proj}}
\newcommand{\diag}{\operatorname{diag}}
\newcommand{\Tr}{\operatorname{Tr}}
\newcommand{\rank}{\operatorname{rank}}
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section B.9 Numerical Checks and Roundoff
This section helps you read numerical checks that decide whether computed quantities are close enough for interpretation.
np.isclose(0.1 + 0.2, 0.3)
np.allclose(A @ x, b)
np.round(x, 3)
xhat = np.linalg.lstsq(A, b, rcond=None)[0]
r = b - A @ xhat
np.allclose(A.T @ r, 0)
Scalar closeness.
Read as. Approximate scalar equality.
Array closeness.
Read as. Approximate array equality.
Used for. Vector and matrix checks.
Rounded display.
Read as. Round for display.
Output. A number or array.
Used for. Readable output.
Fitted values.
Read as. Evaluate the fitted model at the sampled inputs.
Shape/return. A vector of fitted values.
Used for. Sampled polynomial least-squares fits.
Trapezoid approximation.
np.trapezoid(values, grid)
Read as. Approximate an integral from sampled values.
Used for. Polynomial inner products and residual-size comparisons.
Residual vector.
Read as. Observed or sampled values minus fitted values.
Shape/return. A vector of residuals.
Used for. Residual checks such as
A.T @ r.
Solution check.
Read as. Check an approximate solution.
Used for. Numerical systems.
Residual orthogonality.
Read as. Check residual orthogonality.
-
Numerical linear algebra may produce tiny numbers such as
1e-15.
-
Close to zero is often the right numerical interpretation.
-
A.T @ r checks residual orthogonality, not whether
r itself is zero.