x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
\mathbf{if}\;t_1 \leq -1.4371011941947292 \cdot 10^{-304}:\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z - t}{a - t}, x\right)\\
\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;\left(y + \left(\frac{x \cdot z}{t} + \frac{y \cdot a}{t}\right)\right) - \left(\frac{x \cdot a}{t} + \frac{y \cdot z}{t}\right)\\
\mathbf{else}:\\
\;\;\;\;x + \frac{y - x}{\frac{a - t}{z - t}}\\
\end{array}
(FPCore (x y z t a) :precision binary64 (+ x (/ (* (- y x) (- z t)) (- a t))))
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(if (<= t_1 -1.4371011941947292e-304)
(fma (- y x) (/ (- z t) (- a t)) x)
(if (<= t_1 0.0)
(-
(+ y (+ (/ (* x z) t) (/ (* y a) t)))
(+ (/ (* x a) t) (/ (* y z) t)))
(+ x (/ (- y x) (/ (- a t) (- z t))))))))double code(double x, double y, double z, double t, double a) {
return x + (((y - x) * (z - t)) / (a - t));
}
double code(double x, double y, double z, double t, double a) {
double t_1 = x + (((y - x) * (z - t)) / (a - t));
double tmp;
if (t_1 <= -1.4371011941947292e-304) {
tmp = fma((y - x), ((z - t) / (a - t)), x);
} else if (t_1 <= 0.0) {
tmp = (y + (((x * z) / t) + ((y * a) / t))) - (((x * a) / t) + ((y * z) / t));
} else {
tmp = x + ((y - x) / ((a - t) / (z - t)));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a
| Original | 24.9 |
|---|---|
| Target | 9.5 |
| Herbie | 6.6 |
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -1.43710119419472919e-304Initial program 21.1
Simplified7.1
Applied *-un-lft-identity_binary647.1
Applied *-un-lft-identity_binary647.1
Applied times-frac_binary647.1
Simplified7.1
if -1.43710119419472919e-304 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 61.0
Simplified60.8
Taylor expanded in t around inf 0.7
if 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 21.7
Simplified7.4
Applied clear-num_binary647.5
Applied fma-udef_binary647.5
Simplified7.3
Final simplification6.6
herbie shell --seed 2022077
(FPCore (x y z t a)
:name "Graphics.Rendering.Chart.Axis.Types:linMap from Chart-1.5.3"
:precision binary64
:herbie-target
(if (< a -1.6153062845442575e-142) (+ x (* (/ (- y x) 1.0) (/ (- z t) (- a t)))) (if (< a 3.774403170083174e-182) (- y (* (/ z t) (- y x))) (+ x (* (/ (- y x) 1.0) (/ (- z t) (- a t))))))
(+ x (/ (* (- y x) (- z t)) (- a t))))