(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 (+ x t)))
(t_2 (/ a t_1))
(t_3 (+ (* t t_2) (* y t_2)))
(t_4 (* b (/ y t_1)))
(t_5 (/ (- (+ (* (+ x y) z) (* (+ y t) a)) (* y b)) t_1))
(t_6 (/ t_1 z))
(t_7 (/ y t_6)))
(if (<= t_5 (- INFINITY))
(+ t_7 (- (+ (* x (/ z t_1)) t_3) t_4))
(if (<= t_5 1e+268)
(-
(+
(/ (* y z) t_1)
(+ (/ (* x z) t_1) (+ (/ (* t a) t_1) (/ (* y a) t_1))))
(/ (* y b) t_1))
(+ t_7 (- (+ t_3 (/ x t_6)) t_4))))))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 + (x + t);
double t_2 = a / t_1;
double t_3 = (t * t_2) + (y * t_2);
double t_4 = b * (y / t_1);
double t_5 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / t_1;
double t_6 = t_1 / z;
double t_7 = y / t_6;
double tmp;
if (t_5 <= -((double) INFINITY)) {
tmp = t_7 + (((x * (z / t_1)) + t_3) - t_4);
} else if (t_5 <= 1e+268) {
tmp = (((y * z) / t_1) + (((x * z) / t_1) + (((t * a) / t_1) + ((y * a) / t_1)))) - ((y * b) / t_1);
} else {
tmp = t_7 + ((t_3 + (x / t_6)) - t_4);
}
return tmp;
}
public static 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);
}
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = y + (x + t);
double t_2 = a / t_1;
double t_3 = (t * t_2) + (y * t_2);
double t_4 = b * (y / t_1);
double t_5 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / t_1;
double t_6 = t_1 / z;
double t_7 = y / t_6;
double tmp;
if (t_5 <= -Double.POSITIVE_INFINITY) {
tmp = t_7 + (((x * (z / t_1)) + t_3) - t_4);
} else if (t_5 <= 1e+268) {
tmp = (((y * z) / t_1) + (((x * z) / t_1) + (((t * a) / t_1) + ((y * a) / t_1)))) - ((y * b) / t_1);
} else {
tmp = t_7 + ((t_3 + (x / t_6)) - t_4);
}
return tmp;
}
def code(x, y, z, t, a, b): return ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y)
def code(x, y, z, t, a, b): t_1 = y + (x + t) t_2 = a / t_1 t_3 = (t * t_2) + (y * t_2) t_4 = b * (y / t_1) t_5 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / t_1 t_6 = t_1 / z t_7 = y / t_6 tmp = 0 if t_5 <= -math.inf: tmp = t_7 + (((x * (z / t_1)) + t_3) - t_4) elif t_5 <= 1e+268: tmp = (((y * z) / t_1) + (((x * z) / t_1) + (((t * a) / t_1) + ((y * a) / t_1)))) - ((y * b) / t_1) else: tmp = t_7 + ((t_3 + (x / t_6)) - t_4) 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(y + Float64(x + t)) t_2 = Float64(a / t_1) t_3 = Float64(Float64(t * t_2) + Float64(y * t_2)) t_4 = Float64(b * Float64(y / t_1)) t_5 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(y + t) * a)) - Float64(y * b)) / t_1) t_6 = Float64(t_1 / z) t_7 = Float64(y / t_6) tmp = 0.0 if (t_5 <= Float64(-Inf)) tmp = Float64(t_7 + Float64(Float64(Float64(x * Float64(z / t_1)) + t_3) - t_4)); elseif (t_5 <= 1e+268) tmp = Float64(Float64(Float64(Float64(y * z) / t_1) + Float64(Float64(Float64(x * z) / t_1) + Float64(Float64(Float64(t * a) / t_1) + Float64(Float64(y * a) / t_1)))) - Float64(Float64(y * b) / t_1)); else tmp = Float64(t_7 + Float64(Float64(t_3 + Float64(x / t_6)) - t_4)); end return tmp end
function tmp = code(x, y, z, t, a, b) tmp = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y); end
function tmp_2 = code(x, y, z, t, a, b) t_1 = y + (x + t); t_2 = a / t_1; t_3 = (t * t_2) + (y * t_2); t_4 = b * (y / t_1); t_5 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / t_1; t_6 = t_1 / z; t_7 = y / t_6; tmp = 0.0; if (t_5 <= -Inf) tmp = t_7 + (((x * (z / t_1)) + t_3) - t_4); elseif (t_5 <= 1e+268) tmp = (((y * z) / t_1) + (((x * z) / t_1) + (((t * a) / t_1) + ((y * a) / t_1)))) - ((y * b) / t_1); else tmp = t_7 + ((t_3 + (x / t_6)) - t_4); end tmp_2 = 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[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(a / t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(t * t$95$2), $MachinePrecision] + N[(y * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(b * N[(y / t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[(N[(N[(x + y), $MachinePrecision] * z), $MachinePrecision] + N[(N[(y + t), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]}, Block[{t$95$6 = N[(t$95$1 / z), $MachinePrecision]}, Block[{t$95$7 = N[(y / t$95$6), $MachinePrecision]}, If[LessEqual[t$95$5, (-Infinity)], N[(t$95$7 + N[(N[(N[(x * N[(z / t$95$1), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision] - t$95$4), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$5, 1e+268], N[(N[(N[(N[(y * z), $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[(N[(x * z), $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[(N[(t * a), $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[(y * a), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(y * b), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(t$95$7 + N[(N[(t$95$3 + N[(x / t$95$6), $MachinePrecision]), $MachinePrecision] - t$95$4), $MachinePrecision]), $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 := y + \left(x + t\right)\\
t_2 := \frac{a}{t_1}\\
t_3 := t \cdot t_2 + y \cdot t_2\\
t_4 := b \cdot \frac{y}{t_1}\\
t_5 := \frac{\left(\left(x + y\right) \cdot z + \left(y + t\right) \cdot a\right) - y \cdot b}{t_1}\\
t_6 := \frac{t_1}{z}\\
t_7 := \frac{y}{t_6}\\
\mathbf{if}\;t_5 \leq -\infty:\\
\;\;\;\;t_7 + \left(\left(x \cdot \frac{z}{t_1} + t_3\right) - t_4\right)\\
\mathbf{elif}\;t_5 \leq 10^{+268}:\\
\;\;\;\;\left(\frac{y \cdot z}{t_1} + \left(\frac{x \cdot z}{t_1} + \left(\frac{t \cdot a}{t_1} + \frac{y \cdot a}{t_1}\right)\right)\right) - \frac{y \cdot b}{t_1}\\
\mathbf{else}:\\
\;\;\;\;t_7 + \left(\left(t_3 + \frac{x}{t_6}\right) - t_4\right)\\
\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
Results
| Original | 26.9 |
|---|---|
| Target | 11.4 |
| Herbie | 0.5 |
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
Simplified64.0
Taylor expanded in a around 0 64.0
Simplified0.1
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 9.9999999999999997e267Initial program 0.3
Simplified0.3
Taylor expanded in a around 0 0.3
if 9.9999999999999997e267 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 62.2
Simplified62.2
Taylor expanded in a around 0 62.2
Simplified1.3
Applied egg-rr1.3
Final simplification0.5
herbie shell --seed 2022166
(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)))