Testing a Calculation Under a Change of Units
A change of units can supply an independent relation that a correctly implemented numerical routine should preserve.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 4
- Reading time
- 1 min
In this article4 chapters
Trace distances
Coordinates in meters become one hundred times larger numerically in centimeters. The Euclidean distance then becomes one hundred times the original under exact arithmetic. Units and values define that factor.
Choose a suitable tolerance
Floating-point scaling can introduce its own rounding. Check the predicted numerical relation with a meaningful tolerance and one independently known answer. See metamorphic tests.[1][2]
Compare outputs after converting their units consistently
A rectangle four metres by two metres has area eight square metres. Expressing its sides as four hundred and two hundred centimetres yields eighty thousand square centimetres. Dividing by ten thousand returns eight square metres. See values with units.
Scale length by 100
Scale area by 100² = 10000
400×200 = 80000 cm²
80000 cm² = 8 m²
Use a dimensionally correct tolerance
Converting an area tolerance uses the square of the length factor as well. Include noninteger measurements and validate output units. Preserve the original problem under the transformed inputs.