(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 (+ y (+ x t)))
(t_3 (/ (- (+ (* (+ x y) z) t_1) (* y b)) t_2))
(t_4 (+ x (+ y t))))
(if (<= t_3 (- INFINITY))
(+
(/ (* y z) t_2)
(+
(/ a (/ (+ y t) y))
(- (+ (* x (/ z t_2)) (* t (/ a (+ x t)))) (* b (/ y t_2)))))
(if (<= t_3 4.0686503761068925e+289)
(- (/ (fma (+ x y) z t_1) t_4) (/ (* y b) t_4))
(- (+ z a) b)))))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 = y + (x + t);
double t_3 = ((((x + y) * z) + t_1) - (y * b)) / t_2;
double t_4 = x + (y + t);
double tmp;
if (t_3 <= -((double) INFINITY)) {
tmp = ((y * z) / t_2) + ((a / ((y + t) / y)) + (((x * (z / t_2)) + (t * (a / (x + t)))) - (b * (y / t_2))));
} else if (t_3 <= 4.0686503761068925e+289) {
tmp = (fma((x + y), z, t_1) / t_4) - ((y * b) / t_4);
} else {
tmp = (z + a) - b;
}
return tmp;
}
function code(x, y, z, t, a, b) return Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(t + y) * a)) - Float64(y * b)) / Float64(Float64(x + t) + y)) end
function code(x, y, z, t, a, b) t_1 = Float64(Float64(y + t) * a) t_2 = Float64(y + Float64(x + t)) t_3 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + t_1) - Float64(y * b)) / t_2) t_4 = Float64(x + Float64(y + t)) tmp = 0.0 if (t_3 <= Float64(-Inf)) tmp = Float64(Float64(Float64(y * z) / t_2) + Float64(Float64(a / Float64(Float64(y + t) / y)) + Float64(Float64(Float64(x * Float64(z / t_2)) + Float64(t * Float64(a / Float64(x + t)))) - Float64(b * Float64(y / t_2))))); elseif (t_3 <= 4.0686503761068925e+289) tmp = Float64(Float64(fma(Float64(x + y), z, t_1) / t_4) - Float64(Float64(y * b) / t_4)); else tmp = Float64(Float64(z + a) - b); end return tmp end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(t + y), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(N[(x + t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(y + t), $MachinePrecision] * a), $MachinePrecision]}, Block[{t$95$2 = N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + t$95$1), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(x + N[(y + t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, (-Infinity)], N[(N[(N[(y * z), $MachinePrecision] / t$95$2), $MachinePrecision] + N[(N[(a / N[(N[(y + t), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(x * N[(z / t$95$2), $MachinePrecision]), $MachinePrecision] + N[(t * N[(a / N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b * N[(y / t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 4.0686503761068925e+289], N[(N[(N[(N[(x + y), $MachinePrecision] * z + t$95$1), $MachinePrecision] / t$95$4), $MachinePrecision] - N[(N[(y * b), $MachinePrecision] / t$95$4), $MachinePrecision]), $MachinePrecision], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision]]]]]]]
\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 := y + \left(x + t\right)\\
t_3 := \frac{\left(\left(x + y\right) \cdot z + t_1\right) - y \cdot b}{t_2}\\
t_4 := x + \left(y + t\right)\\
\mathbf{if}\;t_3 \leq -\infty:\\
\;\;\;\;\frac{y \cdot z}{t_2} + \left(\frac{a}{\frac{y + t}{y}} + \left(\left(x \cdot \frac{z}{t_2} + t \cdot \frac{a}{x + t}\right) - b \cdot \frac{y}{t_2}\right)\right)\\
\mathbf{elif}\;t_3 \leq 4.0686503761068925 \cdot 10^{+289}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x + y, z, t_1\right)}{t_4} - \frac{y \cdot b}{t_4}\\
\mathbf{else}:\\
\;\;\;\;\left(z + a\right) - b\\
\end{array}




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.2 |
|---|---|
| Target | 11.3 |
| Herbie | 8.1 |
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -inf.0Initial program 64.0
Taylor expanded in z around 0 64.0
Simplified41.0
Taylor expanded in y around 0 41.0
Simplified27.2
Taylor expanded in x around 0 28.4
Simplified21.8
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 4.06865037610689251e289Initial program 0.3
Applied egg-rr0.3
if 4.06865037610689251e289 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 63.0
Taylor expanded in y around inf 17.5
Final simplification8.1
herbie shell --seed 2022153
(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)))