\frac{x - lo}{hi - lo}
\begin{array}{l}
t_0 := 1 + \frac{hi}{lo}\\
\left(1 + \frac{hi}{lo} \cdot \sqrt{\mathsf{fma}\left(hi, \frac{1}{lo} \cdot t_0, t_0\right)}\right) - \frac{x}{lo}
\end{array}
(FPCore (lo hi x) :precision binary64 (/ (- x lo) (- hi lo)))
(FPCore (lo hi x) :precision binary64 (let* ((t_0 (+ 1.0 (/ hi lo)))) (- (+ 1.0 (* (/ hi lo) (sqrt (fma hi (* (/ 1.0 lo) t_0) t_0)))) (/ x lo))))
double code(double lo, double hi, double x) {
return (x - lo) / (hi - lo);
}
double code(double lo, double hi, double x) {
double t_0 = 1.0 + (hi / lo);
return (1.0 + ((hi / lo) * sqrt(fma(hi, ((1.0 / lo) * t_0), t_0)))) - (x / lo);
}



Bits error versus lo



Bits error versus hi



Bits error versus x
Initial program 62.0
Taylor expanded in lo around inf 64.0
Simplified51.9
Applied egg-rr51.5
Taylor expanded in hi around 0 51.5
Applied egg-rr51.5
Final simplification51.5
herbie shell --seed 2022125
(FPCore (lo hi x)
:name "(/ (- x lo) (- hi lo))"
:precision binary64
:pre (and (< lo -1e+308) (> hi 1e+308))
(/ (- x lo) (- hi lo)))