Clamping and medians in ordered additive groups #
In a linearly ordered additive group, clamping to a symmetric interval is bounded by its
height and does not increase absolute value. Clamping t to [0, a + b], for 0 ≤ a and
0 ≤ b, is the sum of clamping t to [0, a] and clamping the remaining time t - a to
[0, b]. This is how a constant-speed run along a segment of duration a + b splits into its
runs along the two pieces of durations a and b.
The median max 0 (min a b) + min 0 (max a b) of 0, a and b is the common initial segment
of a and b, viewed as segments from 0 on the line: it lies between 0 and each of them, and
twice its absolute value is |a| + |b| - |b - a|.
Main results #
TauCeti.max_zero_min_add:max 0 (min t (a + b)) = max 0 (min t a) + max 0 (min (t - a) b).TauCeti.abs_max_min_le: the max-min clipping formula is bounded by|M|for any heightM.TauCeti.abs_max_min_le_abs: clipping at a nonnegative height does not increase absolute value.TauCeti.add_max_neg_min_nonneg: clamping two elements with nonnegative sum to[-r, r]leaves a nonnegative sum.TauCeti.abs_max_zero_min_add_min_zero_max_add_abs_sub: the medianuof0,aandbsatisfies|u| + |a - u| = |a|.TauCeti.two_nsmul_abs_max_zero_min_add_min_zero_max:2 • |u| = |a| + |b| - |b - a|.
Clamping t to [0, a + b] is the sum of clamping t to [0, a] and clamping the remaining
time t - a to [0, b].
The max-min clipping formula is bounded by the absolute value of its height, including when the height is negative.
Clipping to a symmetric interval does not increase absolute value.
Clamping two elements with nonnegative sum to [-r, r] leaves a nonnegative sum.
The median u = max 0 (min a b) + min 0 (max a b) of 0, a and b lies between 0 and
a: |u| + |a - u| = |a|.
Twice the absolute value of the median u = max 0 (min a b) + min 0 (max a b) of 0, a
and b is |a| + |b| - |b - a|: u is the common initial segment of a and b.