A planar calibration residual records how far a measured feature moved from its predicted position along two axes. A report can keep both signed differences and add a length for sorting or plotting observations. With differences of minus three and plus four in the same unit, the length is five. The negative sign still belongs in the record because it identifies the direction of the horizontal error. Two observations with opposite signed components can have identical magnitudes and inform entirely different adjustments to the calibration.

The familiar expression for the length is the square root of the sum of both squared components. Although that expression is correct on paper, the intermediate squared values have to fit in the machine's floating-point format. A batch can therefore contain finite inputs and a representable length while the direct expression returns infinity or zero. NumPy's hypot evaluates the two-component length element by element without requiring the caller to form those squares.

Check one batch at both ends of the range

The following fixture uses NumPy 2.5.2 and Python 3.14.7. The extreme numbers deliberately stress float64 arithmetic and do not describe actual robot measurements. The two smaller examples show the expected behavior for a conventional signed residual and a genuine zero.

import math

import numpy as np

residuals = np.array([

[3e200, 4e200],

[3e-200, 4e-200],

[-3.0, 4.0],

[0.0, 0.0],

], dtype=np.float64)

dx, dy = residuals.T

with np.errstate(over="ignore", under="ignore"):

direct = np.sqrt(dx * dx + dy * dy)

magnitudes = np.hypot(dx, dy)

reference = np.array([math.hypot(x, y) for x, y in residuals])

assert np.isposinf(direct[0])

assert direct[1] == 0.0

assert magnitudes[1] > 0.0

for actual, expected in zip(magnitudes, reference, strict=True):

assert math.isclose(actual, expected, rel_tol=1e-15, abs_tol=0)

The direct result was infinity, zero, five, and zero. The hypot result was approximately 5e200, 5e-200, five, and zero. Python's scalar math.hypot agreed on all four rows. The comparison uses a zero absolute tolerance so a result of zero cannot pass for the tiny positive reference. Error suppression applies only to the intentionally fragile calculation. The agreement with the scalar reference covers this fixture and gives a reproducible comparison for future runtime upgrades.

Why the square changes the usable range

Squaring a component near 4e200 produces a value near 1.6e401. That product lies outside float64 even though the length near 5e200 fits comfortably. For 4e-200, its square is near 1.6e-399, too small even for a positive float64 subnormal. The loss occurs before the square root runs, so that last operation cannot recover a finite length from infinity or a positive length from zero.

A scaled calculation illustrates how a length routine can avoid these intermediates. Divide the components by the larger absolute component, compute the length of the scaled pair, and then multiply by that larger component. The absolute values of the divided components are at most one, and at least one has absolute value one for a finite nonzero pair. A zero pair can return zero directly. This explains the numerical idea without assuming that every implementation uses identical branches or rounding.

Check the limits before producing a report

A valid pair of finite inputs can still have a length larger than the largest representable output. In a separate check with two components of 1.5e308, the NumPy result was positive infinity. In that case the true length itself exceeds float64. A report can record a distinct reason when the computed magnitude exceeds the output range, because that calls for a different investigation from a missing coordinate. For example, a reporting pipeline could retain the original signed pair and leave the magnitude field empty with an explicit reason code.

An explicit per-row validity mask can keep missing or nonfinite components out of the result. In a check with [3, 4], [NaN, 4], and [infinity, NaN], applying isfinite to each pair and requiring both components to pass marked only the first row valid. Keep that mask with the row identifiers when computing magnitudes. Filtering an array and then assigning the shortened output to the original row order can attach a valid distance to the wrong feature.

Retain the numeric and geometric context

The example starts from residual components that already exist in a common coordinate frame. If they are initially stored as two positions, subtraction is a separate numerical step. A small offset lost when the positions were rounded cannot be reconstructed by a stable magnitude calculation. If one axis is reported in millimeters and the other in meters, convert units before combining them. A Euclidean length also represents a particular physical metric. A score that weights components by sensor uncertainty has a different definition and needs its own verification.

Store the two signed components alongside the magnitude and record the array's data type so someone can reproduce the comparison later. Add a genuine zero to the regression fixture along with the tiny nonzero case. Seeing separate expected outcomes for those rows makes accidental underflow easier to catch in a report exporter. Compare the vectorized result with a scalar reference for the same pairs and check both row order and the returned length count. Test the stored values as well as the in-memory array if the exporter rounds or restricts the number of significant digits.

The image is an AI-generated concept illustration. It shows two orthogonal offsets and the resulting diagonal on a calibration plate. The diagram illustrates the geometry of the residual while the reproducible fixture provides numerical evidence.

Sources checked November 28, 2026. NumPy hypot reference at https://numpy.org/doc/stable/reference/generated/numpy.hypot.html and Python math.hypot reference at https://docs.python.org/3/library/math.html#math.hypot. The stress tests are original calculations with synthetic data.