Checking a Numerical Routine Across Scales
A numerical test can vary magnitude and structure separately so it reveals both model errors and representation limits.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace norm input choices
A norm of (3,4) tests the expected answer five. A vector with very large components can test whether intermediate squares overflow even when the norm fits. See scaled norms.
Retain a zero and a small value
Test zero and a small nonzero vector to check absent or underflow behavior under the chosen limits. Tolerance design should state how near-zero results are compared.[1][2]
Change numerical scale while keeping the operation shape
A Euclidean norm test can use \((3,4)\), its scaled version \((3\cdot10^{100},4\cdot10^{100})\) and a very small version. The norm scales by the magnitude of the common factor in exact arithmetic. The vector length and shape stay the same. See overflow in norms.
Base norm 5
Large norm 5e100
Small norm 5e-100 for a factor 1e-100
Use tolerances appropriate to each scale
Test dimension separately from magnitude
A routine may also behave differently for empty, singleton or high-dimensional inputs. Vary one property at a time to identify why a check fails.