(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 x))) (t_2 (cbrt t_1)) (t_3 (- (+ a z) b)))
(if (<= y -9.070353256782471e+119)
t_3
(if (<= y 1.7234148892206226e+128)
(-
(+
(/ (* y z) t_1)
(+ (* z (/ x t_1)) (+ (* a (/ t (+ t (+ y x)))) (/ (* y a) t_1))))
(/ (* b (/ y (* t_2 t_2))) t_2))
t_3))))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 + x);
double t_2 = cbrt(t_1);
double t_3 = (a + z) - b;
double tmp;
if (y <= -9.070353256782471e+119) {
tmp = t_3;
} else if (y <= 1.7234148892206226e+128) {
tmp = (((y * z) / t_1) + ((z * (x / t_1)) + ((a * (t / (t + (y + x)))) + ((y * a) / t_1)))) - ((b * (y / (t_2 * t_2))) / t_2);
} else {
tmp = t_3;
}
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 + (t + x);
double t_2 = Math.cbrt(t_1);
double t_3 = (a + z) - b;
double tmp;
if (y <= -9.070353256782471e+119) {
tmp = t_3;
} else if (y <= 1.7234148892206226e+128) {
tmp = (((y * z) / t_1) + ((z * (x / t_1)) + ((a * (t / (t + (y + x)))) + ((y * a) / t_1)))) - ((b * (y / (t_2 * t_2))) / t_2);
} else {
tmp = t_3;
}
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(t + x)) t_2 = cbrt(t_1) t_3 = Float64(Float64(a + z) - b) tmp = 0.0 if (y <= -9.070353256782471e+119) tmp = t_3; elseif (y <= 1.7234148892206226e+128) tmp = Float64(Float64(Float64(Float64(y * z) / t_1) + Float64(Float64(z * Float64(x / t_1)) + Float64(Float64(a * Float64(t / Float64(t + Float64(y + x)))) + Float64(Float64(y * a) / t_1)))) - Float64(Float64(b * Float64(y / Float64(t_2 * t_2))) / t_2)); else tmp = t_3; 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[(y + N[(t + x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[t$95$1, 1/3], $MachinePrecision]}, Block[{t$95$3 = N[(N[(a + z), $MachinePrecision] - b), $MachinePrecision]}, If[LessEqual[y, -9.070353256782471e+119], t$95$3, If[LessEqual[y, 1.7234148892206226e+128], N[(N[(N[(N[(y * z), $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[(z * N[(x / t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(a * N[(t / N[(t + N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(y * a), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(b * N[(y / N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision]), $MachinePrecision], t$95$3]]]]]
\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(t + x\right)\\
t_2 := \sqrt[3]{t_1}\\
t_3 := \left(a + z\right) - b\\
\mathbf{if}\;y \leq -9.070353256782471 \cdot 10^{+119}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;y \leq 1.7234148892206226 \cdot 10^{+128}:\\
\;\;\;\;\left(\frac{y \cdot z}{t_1} + \left(z \cdot \frac{x}{t_1} + \left(a \cdot \frac{t}{t + \left(y + x\right)} + \frac{y \cdot a}{t_1}\right)\right)\right) - \frac{b \cdot \frac{y}{t_2 \cdot t_2}}{t_2}\\
\mathbf{else}:\\
\;\;\;\;t_3\\
\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 | 27.1 |
|---|---|
| Target | 11.3 |
| Herbie | 7.0 |
if y < -9.07035325678247137e119 or 1.72341488922062257e128 < y Initial program 46.7
Simplified46.7
Taylor expanded in y around inf 12.7
if -9.07035325678247137e119 < y < 1.72341488922062257e128Initial program 18.7
Simplified18.7
Taylor expanded in a around 0 18.7
Applied *-un-lft-identity_binary6418.7
Applied times-frac_binary6412.4
Simplified12.4
Simplified12.4
Applied *-un-lft-identity_binary6412.4
Applied times-frac_binary645.6
Simplified5.6
Simplified5.6
Applied add-cube-cbrt_binary645.7
Applied associate-/r*_binary645.7
Simplified4.6
Final simplification7.0
herbie shell --seed 2022131
(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)))