\frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}
\begin{array}{l}
t_1 := \left(y + t\right) \cdot a\\
t_2 := \frac{\left(\left(x + y\right) \cdot z + t_1\right) - y \cdot b}{y + \left(x + t\right)}\\
t_3 := x + \left(y + t\right)\\
t_4 := \frac{y}{t_3}\\
t_5 := b \cdot t_4\\
t_6 := \mathsf{fma}\left(1, z + a, -t_5\right)\\
t_7 := -t_4\\
\mathbf{if}\;t_2 \leq -1.8770167269899472 \cdot 10^{+236}:\\
\;\;\;\;t_6 + \mathsf{fma}\left(y \cdot \frac{-1}{t_3}, b, t_5\right)\\
\mathbf{elif}\;t_2 \leq 8.371234403385252 \cdot 10^{+216}:\\
\;\;\;\;\mathsf{fma}\left(1, \frac{\mathsf{fma}\left(x + y, z, t_1\right)}{t_3}, -\frac{b}{\frac{t_3}{y}}\right) + \mathsf{fma}\left(t_7, b, t_5\right)\\
\mathbf{else}:\\
\;\;\;\;t_6 + \mathsf{fma}\left(t_7, b, \frac{1}{\frac{1}{t_5}}\right)\\
\end{array}
(FPCore (x y z t a b) :precision binary64 (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (* (+ y t) a))
(t_2 (/ (- (+ (* (+ x y) z) t_1) (* y b)) (+ y (+ x t))))
(t_3 (+ x (+ y t)))
(t_4 (/ y t_3))
(t_5 (* b t_4))
(t_6 (fma 1.0 (+ z a) (- t_5)))
(t_7 (- t_4)))
(if (<= t_2 -1.8770167269899472e+236)
(+ t_6 (fma (* y (/ -1.0 t_3)) b t_5))
(if (<= t_2 8.371234403385252e+216)
(+
(fma 1.0 (/ (fma (+ x y) z t_1) t_3) (- (/ b (/ t_3 y))))
(fma t_7 b t_5))
(+ t_6 (fma t_7 b (/ 1.0 (/ 1.0 t_5))))))))double code(double x, double y, double z, double t, double a, double b) {
return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y);
}
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (y + t) * a;
double t_2 = ((((x + y) * z) + t_1) - (y * b)) / (y + (x + t));
double t_3 = x + (y + t);
double t_4 = y / t_3;
double t_5 = b * t_4;
double t_6 = fma(1.0, (z + a), -t_5);
double t_7 = -t_4;
double tmp;
if (t_2 <= -1.8770167269899472e+236) {
tmp = t_6 + fma((y * (-1.0 / t_3)), b, t_5);
} else if (t_2 <= 8.371234403385252e+216) {
tmp = fma(1.0, (fma((x + y), z, t_1) / t_3), -(b / (t_3 / y))) + fma(t_7, b, t_5);
} else {
tmp = t_6 + fma(t_7, b, (1.0 / (1.0 / t_5)));
}
return tmp;
}




Bits error versus x




Bits error versus y




Bits error versus z




Bits error versus t




Bits error versus a




Bits error versus b
| Original | 26.9 |
|---|---|
| Target | 11.8 |
| Herbie | 6.1 |
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -1.8770167269899472e236Initial program 57.4
Applied egg-rr49.3
Taylor expanded in y around inf 10.9
Applied egg-rr10.9
if -1.8770167269899472e236 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 8.37123440338525229e216Initial program 0.3
Applied egg-rr1.1
Applied egg-rr1.2
if 8.37123440338525229e216 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 57.8
Applied egg-rr51.6
Taylor expanded in y around inf 12.2
Applied egg-rr12.2
Final simplification6.1
herbie shell --seed 2022125
(FPCore (x y z t a b)
:name "AI.Clustering.Hierarchical.Internal:ward from clustering-0.2.1"
:precision binary64
:herbie-target
(if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) -3.5813117084150564e+153) (- (+ z a) b) (if (< (/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)) 1.2285964308315609e+82) (/ 1.0 (/ (+ (+ x t) y) (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)))) (- (+ z a) b)))
(/ (- (+ (* (+ x y) z) (* (+ t y) a)) (* y b)) (+ (+ x t) y)))