(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 (/ (- (+ (* (+ x y) z) (* (+ y t) a)) (* y b)) t_1))
(t_3 (/ y t_1))
(t_4 (* a (+ t_3 (/ t t_1))))
(t_5 (/ z (/ t_1 (+ x y)))))
(if (<= t_2 -500000.0)
(+ t_4 (- t_5 (/ y (/ (+ x (+ y t)) b))))
(if (<= t_2 5e+193)
(+ t_4 (/ (fma z (+ x y) (* y (- b))) t_1))
(+ t_4 (- t_5 (* b 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 + (x + t);
double t_2 = ((((x + y) * z) + ((y + t) * a)) - (y * b)) / t_1;
double t_3 = y / t_1;
double t_4 = a * (t_3 + (t / t_1));
double t_5 = z / (t_1 / (x + y));
double tmp;
if (t_2 <= -500000.0) {
tmp = t_4 + (t_5 - (y / ((x + (y + t)) / b)));
} else if (t_2 <= 5e+193) {
tmp = t_4 + (fma(z, (x + y), (y * -b)) / t_1);
} else {
tmp = t_4 + (t_5 - (b * 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(x + t)) t_2 = Float64(Float64(Float64(Float64(Float64(x + y) * z) + Float64(Float64(y + t) * a)) - Float64(y * b)) / t_1) t_3 = Float64(y / t_1) t_4 = Float64(a * Float64(t_3 + Float64(t / t_1))) t_5 = Float64(z / Float64(t_1 / Float64(x + y))) tmp = 0.0 if (t_2 <= -500000.0) tmp = Float64(t_4 + Float64(t_5 - Float64(y / Float64(Float64(x + Float64(y + t)) / b)))); elseif (t_2 <= 5e+193) tmp = Float64(t_4 + Float64(fma(z, Float64(x + y), Float64(y * Float64(-b))) / t_1)); else tmp = Float64(t_4 + Float64(t_5 - Float64(b * 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[(x + t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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$3 = N[(y / t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[(a * N[(t$95$3 + N[(t / t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(z / N[(t$95$1 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -500000.0], N[(t$95$4 + N[(t$95$5 - N[(y / N[(N[(x + N[(y + t), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+193], N[(t$95$4 + N[(N[(z * N[(x + y), $MachinePrecision] + N[(y * (-b)), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision]), $MachinePrecision], N[(t$95$4 + N[(t$95$5 - N[(b * t$95$3), $MachinePrecision]), $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{\left(\left(x + y\right) \cdot z + \left(y + t\right) \cdot a\right) - y \cdot b}{t_1}\\
t_3 := \frac{y}{t_1}\\
t_4 := a \cdot \left(t_3 + \frac{t}{t_1}\right)\\
t_5 := \frac{z}{\frac{t_1}{x + y}}\\
\mathbf{if}\;t_2 \leq -500000:\\
\;\;\;\;t_4 + \left(t_5 - \frac{y}{\frac{x + \left(y + t\right)}{b}}\right)\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+193}:\\
\;\;\;\;t_4 + \frac{\mathsf{fma}\left(z, x + y, y \cdot \left(-b\right)\right)}{t_1}\\
\mathbf{else}:\\
\;\;\;\;t_4 + \left(t_5 - b \cdot t_3\right)\\
\end{array}
| Original | 26.8 |
|---|---|
| Target | 11.0 |
| Herbie | 0.7 |
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -5e5Initial program 32.9
Taylor expanded in a around 0 20.7
Simplified20.7
Taylor expanded in z around inf 20.7
Simplified0.1
Applied egg-rr1.0
if -5e5 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 4.99999999999999972e193Initial program 0.4
Taylor expanded in a around 0 0.8
Simplified0.8
if 4.99999999999999972e193 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 56.7
Taylor expanded in a around 0 41.9
Simplified41.9
Taylor expanded in z around inf 41.9
Simplified0.1
Final simplification0.7
herbie shell --seed 2022186
(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)))