| Alternative 1 | |
|---|---|
| Accuracy | 88.1% |
| Cost | 4169 |
(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 (/ (- (+ (* z (+ x y)) (* a (+ y t))) (* y b)) (+ y (+ x t)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 2e+288)))
(- (+ z a) b)
(/ (fma y (- z b) (fma (+ y t) a (* x z))) (+ x (+ y t))))))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 = (((z * (x + y)) + (a * (y + t))) - (y * b)) / (y + (x + t));
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2e+288)) {
tmp = (z + a) - b;
} else {
tmp = fma(y, (z - b), fma((y + t), a, (x * z))) / (x + (y + t));
}
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(Float64(Float64(z * Float64(x + y)) + Float64(a * Float64(y + t))) - Float64(y * b)) / Float64(y + Float64(x + t))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 2e+288)) tmp = Float64(Float64(z + a) - b); else tmp = Float64(fma(y, Float64(z - b), fma(Float64(y + t), a, Float64(x * z))) / Float64(x + Float64(y + t))); 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[(N[(N[(z * N[(x + y), $MachinePrecision]), $MachinePrecision] + N[(a * N[(y + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(y * b), $MachinePrecision]), $MachinePrecision] / N[(y + N[(x + t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e+288]], $MachinePrecision]], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision], N[(N[(y * N[(z - b), $MachinePrecision] + N[(N[(y + t), $MachinePrecision] * a + N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(x + N[(y + t), $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 := \frac{\left(z \cdot \left(x + y\right) + a \cdot \left(y + t\right)\right) - y \cdot b}{y + \left(x + t\right)}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+288}\right):\\
\;\;\;\;\left(z + a\right) - b\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, z - b, \mathsf{fma}\left(y + t, a, x \cdot z\right)\right)}{x + \left(y + t\right)}\\
\end{array}
| Original | 58.6% |
|---|---|
| Target | 82.3% |
| Herbie | 88.1% |
if (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < -inf.0 or 2e288 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) Initial program 1.0%
Simplified1.0%
[Start]1.0 | \[ \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}
\] |
|---|---|
sub-neg [=>]1.0 | \[ \frac{\color{blue}{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) + \left(-y \cdot b\right)}}{\left(x + t\right) + y}
\] |
+-commutative [=>]1.0 | \[ \frac{\color{blue}{\left(-y \cdot b\right) + \left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right)}}{\left(x + t\right) + y}
\] |
*-commutative [=>]1.0 | \[ \frac{\left(-y \cdot b\right) + \left(\color{blue}{z \cdot \left(x + y\right)} + \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}
\] |
+-commutative [=>]1.0 | \[ \frac{\left(-y \cdot b\right) + \left(z \cdot \color{blue}{\left(y + x\right)} + \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}
\] |
distribute-rgt-in [=>]1.0 | \[ \frac{\left(-y \cdot b\right) + \left(\color{blue}{\left(y \cdot z + x \cdot z\right)} + \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}
\] |
associate-+l+ [=>]1.0 | \[ \frac{\left(-y \cdot b\right) + \color{blue}{\left(y \cdot z + \left(x \cdot z + \left(t + y\right) \cdot a\right)\right)}}{\left(x + t\right) + y}
\] |
associate-+r+ [=>]1.0 | \[ \frac{\color{blue}{\left(\left(-y \cdot b\right) + y \cdot z\right) + \left(x \cdot z + \left(t + y\right) \cdot a\right)}}{\left(x + t\right) + y}
\] |
+-commutative [<=]1.0 | \[ \frac{\color{blue}{\left(y \cdot z + \left(-y \cdot b\right)\right)} + \left(x \cdot z + \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}
\] |
sub-neg [<=]1.0 | \[ \frac{\color{blue}{\left(y \cdot z - y \cdot b\right)} + \left(x \cdot z + \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}
\] |
distribute-lft-out-- [=>]1.0 | \[ \frac{\color{blue}{y \cdot \left(z - b\right)} + \left(x \cdot z + \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}
\] |
fma-def [=>]1.0 | \[ \frac{\color{blue}{\mathsf{fma}\left(y, z - b, x \cdot z + \left(t + y\right) \cdot a\right)}}{\left(x + t\right) + y}
\] |
+-commutative [=>]1.0 | \[ \frac{\mathsf{fma}\left(y, z - b, \color{blue}{\left(t + y\right) \cdot a + x \cdot z}\right)}{\left(x + t\right) + y}
\] |
fma-def [=>]1.0 | \[ \frac{\mathsf{fma}\left(y, z - b, \color{blue}{\mathsf{fma}\left(t + y, a, x \cdot z\right)}\right)}{\left(x + t\right) + y}
\] |
+-commutative [=>]1.0 | \[ \frac{\mathsf{fma}\left(y, z - b, \mathsf{fma}\left(\color{blue}{y + t}, a, x \cdot z\right)\right)}{\left(x + t\right) + y}
\] |
associate-+l+ [=>]1.0 | \[ \frac{\mathsf{fma}\left(y, z - b, \mathsf{fma}\left(y + t, a, x \cdot z\right)\right)}{\color{blue}{x + \left(t + y\right)}}
\] |
+-commutative [=>]1.0 | \[ \frac{\mathsf{fma}\left(y, z - b, \mathsf{fma}\left(y + t, a, x \cdot z\right)\right)}{x + \color{blue}{\left(y + t\right)}}
\] |
Taylor expanded in y around inf 72.0%
Simplified72.0%
[Start]72.0 | \[ \left(a + z\right) - b
\] |
|---|---|
+-commutative [=>]72.0 | \[ \color{blue}{\left(z + a\right)} - b
\] |
if -inf.0 < (/.f64 (-.f64 (+.f64 (*.f64 (+.f64 x y) z) (*.f64 (+.f64 t y) a)) (*.f64 y b)) (+.f64 (+.f64 x t) y)) < 2e288Initial program 99.5%
Simplified99.5%
[Start]99.5 | \[ \frac{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) - y \cdot b}{\left(x + t\right) + y}
\] |
|---|---|
sub-neg [=>]99.5 | \[ \frac{\color{blue}{\left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right) + \left(-y \cdot b\right)}}{\left(x + t\right) + y}
\] |
+-commutative [=>]99.5 | \[ \frac{\color{blue}{\left(-y \cdot b\right) + \left(\left(x + y\right) \cdot z + \left(t + y\right) \cdot a\right)}}{\left(x + t\right) + y}
\] |
*-commutative [=>]99.5 | \[ \frac{\left(-y \cdot b\right) + \left(\color{blue}{z \cdot \left(x + y\right)} + \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}
\] |
+-commutative [=>]99.5 | \[ \frac{\left(-y \cdot b\right) + \left(z \cdot \color{blue}{\left(y + x\right)} + \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}
\] |
distribute-rgt-in [=>]99.4 | \[ \frac{\left(-y \cdot b\right) + \left(\color{blue}{\left(y \cdot z + x \cdot z\right)} + \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}
\] |
associate-+l+ [=>]99.4 | \[ \frac{\left(-y \cdot b\right) + \color{blue}{\left(y \cdot z + \left(x \cdot z + \left(t + y\right) \cdot a\right)\right)}}{\left(x + t\right) + y}
\] |
associate-+r+ [=>]99.4 | \[ \frac{\color{blue}{\left(\left(-y \cdot b\right) + y \cdot z\right) + \left(x \cdot z + \left(t + y\right) \cdot a\right)}}{\left(x + t\right) + y}
\] |
+-commutative [<=]99.4 | \[ \frac{\color{blue}{\left(y \cdot z + \left(-y \cdot b\right)\right)} + \left(x \cdot z + \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}
\] |
sub-neg [<=]99.4 | \[ \frac{\color{blue}{\left(y \cdot z - y \cdot b\right)} + \left(x \cdot z + \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}
\] |
distribute-lft-out-- [=>]99.5 | \[ \frac{\color{blue}{y \cdot \left(z - b\right)} + \left(x \cdot z + \left(t + y\right) \cdot a\right)}{\left(x + t\right) + y}
\] |
fma-def [=>]99.5 | \[ \frac{\color{blue}{\mathsf{fma}\left(y, z - b, x \cdot z + \left(t + y\right) \cdot a\right)}}{\left(x + t\right) + y}
\] |
+-commutative [=>]99.5 | \[ \frac{\mathsf{fma}\left(y, z - b, \color{blue}{\left(t + y\right) \cdot a + x \cdot z}\right)}{\left(x + t\right) + y}
\] |
fma-def [=>]99.5 | \[ \frac{\mathsf{fma}\left(y, z - b, \color{blue}{\mathsf{fma}\left(t + y, a, x \cdot z\right)}\right)}{\left(x + t\right) + y}
\] |
+-commutative [=>]99.5 | \[ \frac{\mathsf{fma}\left(y, z - b, \mathsf{fma}\left(\color{blue}{y + t}, a, x \cdot z\right)\right)}{\left(x + t\right) + y}
\] |
associate-+l+ [=>]99.5 | \[ \frac{\mathsf{fma}\left(y, z - b, \mathsf{fma}\left(y + t, a, x \cdot z\right)\right)}{\color{blue}{x + \left(t + y\right)}}
\] |
+-commutative [=>]99.5 | \[ \frac{\mathsf{fma}\left(y, z - b, \mathsf{fma}\left(y + t, a, x \cdot z\right)\right)}{x + \color{blue}{\left(y + t\right)}}
\] |
Final simplification88.1%
| Alternative 1 | |
|---|---|
| Accuracy | 88.1% |
| Cost | 4169 |
| Alternative 2 | |
|---|---|
| Accuracy | 55.1% |
| Cost | 2672 |
| Alternative 3 | |
|---|---|
| Accuracy | 59.7% |
| Cost | 2272 |
| Alternative 4 | |
|---|---|
| Accuracy | 55.7% |
| Cost | 2024 |
| Alternative 5 | |
|---|---|
| Accuracy | 57.5% |
| Cost | 1760 |
| Alternative 6 | |
|---|---|
| Accuracy | 53.4% |
| Cost | 1632 |
| Alternative 7 | |
|---|---|
| Accuracy | 55.4% |
| Cost | 1628 |
| Alternative 8 | |
|---|---|
| Accuracy | 53.7% |
| Cost | 1504 |
| Alternative 9 | |
|---|---|
| Accuracy | 54.6% |
| Cost | 1500 |
| Alternative 10 | |
|---|---|
| Accuracy | 55.0% |
| Cost | 1300 |
| Alternative 11 | |
|---|---|
| Accuracy | 54.9% |
| Cost | 1300 |
| Alternative 12 | |
|---|---|
| Accuracy | 55.4% |
| Cost | 1300 |
| Alternative 13 | |
|---|---|
| Accuracy | 53.8% |
| Cost | 1240 |
| Alternative 14 | |
|---|---|
| Accuracy | 57.1% |
| Cost | 976 |
| Alternative 15 | |
|---|---|
| Accuracy | 42.5% |
| Cost | 852 |
| Alternative 16 | |
|---|---|
| Accuracy | 42.4% |
| Cost | 592 |
| Alternative 17 | |
|---|---|
| Accuracy | 58.3% |
| Cost | 584 |
| Alternative 18 | |
|---|---|
| Accuracy | 44.4% |
| Cost | 328 |
| Alternative 19 | |
|---|---|
| Accuracy | 33.5% |
| Cost | 64 |
herbie shell --seed 2023135
(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)))