x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}
\begin{array}{l}
\mathbf{if}\;\begin{array}{l}
t_1 := x + \frac{\left(y - x\right) \cdot \left(z - t\right)}{a - t}\\
t_1 \leq -2.167735062580595 \cdot 10^{-297} \lor \neg \left(t_1 \leq 0\right)
\end{array}:\\
\;\;\;\;\mathsf{fma}\left(y - x, \frac{z}{a - t} - \frac{t}{a - t}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\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)\\
\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
(if (let* ((t_1 (+ x (/ (* (- y x) (- z t)) (- a t)))))
(or (<= t_1 -2.167735062580595e-297) (not (<= t_1 0.0))))
(fma (- y x) (- (/ z (- a t)) (/ t (- a t))) x)
(- (+ y (+ (/ (* x z) t) (/ (* y a) t))) (+ (/ (* x a) t) (/ (* y 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 <= -2.167735062580595e-297) || !(t_1 <= 0.0)) {
tmp = fma((y - x), ((z / (a - t)) - (t / (a - t))), x);
} else {
tmp = (y + (((x * z) / t) + ((y * a) / t))) - (((x * a) / t) + ((y * 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.7 |
|---|---|
| Target | 9.0 |
| Herbie | 6.8 |
if (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < -2.1677350625805951e-297 or 0.0 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) Initial program 21.5
Simplified7.4
Applied *-un-lft-identity_binary647.4
Applied add-cube-cbrt_binary648.1
Applied times-frac_binary648.1
Simplified8.1
Taylor expanded in z around 0 7.4
if -2.1677350625805951e-297 < (+.f64 x (/.f64 (*.f64 (-.f64 y x) (-.f64 z t)) (-.f64 a t))) < 0.0Initial program 60.6
Simplified60.5
Taylor expanded in t around inf 1.1
Final simplification6.8
herbie shell --seed 2022081
(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))))