| Alternative 1 | |
|---|---|
| Accuracy | 88.2% |
| 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 (+ y (+ x t))))
(if (or (<= y -5.8e+126) (not (<= y 2e+138)))
(- (+ z a) b)
(+ (/ (* y (- z b)) t_1) (+ (/ z (/ t_1 x)) (/ a (/ t_1 (+ 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 = y + (x + t);
double tmp;
if ((y <= -5.8e+126) || !(y <= 2e+138)) {
tmp = (z + a) - b;
} else {
tmp = ((y * (z - b)) / t_1) + ((z / (t_1 / x)) + (a / (t_1 / (y + t))));
}
return tmp;
}
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
code = ((((x + y) * z) + ((t + y) * a)) - (y * b)) / ((x + t) + y)
end function
real(8) function code(x, y, z, t, a, b)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8) :: t_1
real(8) :: tmp
t_1 = y + (x + t)
if ((y <= (-5.8d+126)) .or. (.not. (y <= 2d+138))) then
tmp = (z + a) - b
else
tmp = ((y * (z - b)) / t_1) + ((z / (t_1 / x)) + (a / (t_1 / (y + t))))
end if
code = tmp
end function
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 tmp;
if ((y <= -5.8e+126) || !(y <= 2e+138)) {
tmp = (z + a) - b;
} else {
tmp = ((y * (z - b)) / t_1) + ((z / (t_1 / x)) + (a / (t_1 / (y + t))));
}
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) tmp = 0 if (y <= -5.8e+126) or not (y <= 2e+138): tmp = (z + a) - b else: tmp = ((y * (z - b)) / t_1) + ((z / (t_1 / x)) + (a / (t_1 / (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(y + Float64(x + t)) tmp = 0.0 if ((y <= -5.8e+126) || !(y <= 2e+138)) tmp = Float64(Float64(z + a) - b); else tmp = Float64(Float64(Float64(y * Float64(z - b)) / t_1) + Float64(Float64(z / Float64(t_1 / x)) + Float64(a / Float64(t_1 / Float64(y + t))))); 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); tmp = 0.0; if ((y <= -5.8e+126) || ~((y <= 2e+138))) tmp = (z + a) - b; else tmp = ((y * (z - b)) / t_1) + ((z / (t_1 / x)) + (a / (t_1 / (y + t)))); 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]}, If[Or[LessEqual[y, -5.8e+126], N[Not[LessEqual[y, 2e+138]], $MachinePrecision]], N[(N[(z + a), $MachinePrecision] - b), $MachinePrecision], N[(N[(N[(y * N[(z - b), $MachinePrecision]), $MachinePrecision] / t$95$1), $MachinePrecision] + N[(N[(z / N[(t$95$1 / x), $MachinePrecision]), $MachinePrecision] + N[(a / N[(t$95$1 / N[(y + t), $MachinePrecision]), $MachinePrecision]), $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)\\
\mathbf{if}\;y \leq -5.8 \cdot 10^{+126} \lor \neg \left(y \leq 2 \cdot 10^{+138}\right):\\
\;\;\;\;\left(z + a\right) - b\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot \left(z - b\right)}{t_1} + \left(\frac{z}{\frac{t_1}{x}} + \frac{a}{\frac{t_1}{y + t}}\right)\\
\end{array}
Results
| Original | 58.1% |
|---|---|
| Target | 82.4% |
| Herbie | 89.9% |
if y < -5.79999999999999971e126 or 2.0000000000000001e138 < y Initial program 25.2%
Simplified25.2%
[Start]25.2 | \[ \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 [=>]25.2 | \[ \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 [=>]25.2 | \[ \frac{\color{blue}{\left(\left(t + y\right) \cdot a + \left(x + y\right) \cdot z\right)} + \left(-y \cdot b\right)}{\left(x + t\right) + y}
\] |
associate-+l+ [=>]25.2 | \[ \frac{\color{blue}{\left(t + y\right) \cdot a + \left(\left(x + y\right) \cdot z + \left(-y \cdot b\right)\right)}}{\left(x + t\right) + y}
\] |
fma-def [=>]25.2 | \[ \frac{\color{blue}{\mathsf{fma}\left(t + y, a, \left(x + y\right) \cdot z + \left(-y \cdot b\right)\right)}}{\left(x + t\right) + y}
\] |
+-commutative [=>]25.2 | \[ \frac{\mathsf{fma}\left(\color{blue}{y + t}, a, \left(x + y\right) \cdot z + \left(-y \cdot b\right)\right)}{\left(x + t\right) + y}
\] |
*-commutative [=>]25.2 | \[ \frac{\mathsf{fma}\left(y + t, a, \color{blue}{z \cdot \left(x + y\right)} + \left(-y \cdot b\right)\right)}{\left(x + t\right) + y}
\] |
distribute-rgt-in [=>]25.2 | \[ \frac{\mathsf{fma}\left(y + t, a, \color{blue}{\left(x \cdot z + y \cdot z\right)} + \left(-y \cdot b\right)\right)}{\left(x + t\right) + y}
\] |
associate-+l+ [=>]25.2 | \[ \frac{\mathsf{fma}\left(y + t, a, \color{blue}{x \cdot z + \left(y \cdot z + \left(-y \cdot b\right)\right)}\right)}{\left(x + t\right) + y}
\] |
fma-def [=>]25.2 | \[ \frac{\mathsf{fma}\left(y + t, a, \color{blue}{\mathsf{fma}\left(x, z, y \cdot z + \left(-y \cdot b\right)\right)}\right)}{\left(x + t\right) + y}
\] |
sub-neg [<=]25.2 | \[ \frac{\mathsf{fma}\left(y + t, a, \mathsf{fma}\left(x, z, \color{blue}{y \cdot z - y \cdot b}\right)\right)}{\left(x + t\right) + y}
\] |
distribute-lft-out-- [=>]25.2 | \[ \frac{\mathsf{fma}\left(y + t, a, \mathsf{fma}\left(x, z, \color{blue}{y \cdot \left(z - b\right)}\right)\right)}{\left(x + t\right) + y}
\] |
+-commutative [=>]25.2 | \[ \frac{\mathsf{fma}\left(y + t, a, \mathsf{fma}\left(x, z, y \cdot \left(z - b\right)\right)\right)}{\color{blue}{y + \left(x + t\right)}}
\] |
Taylor expanded in y around inf 81.7%
Simplified81.7%
[Start]81.7 | \[ \left(a + z\right) - b
\] |
|---|---|
+-commutative [=>]81.7 | \[ \color{blue}{\left(z + a\right)} - b
\] |
if -5.79999999999999971e126 < y < 2.0000000000000001e138Initial program 70.9%
Simplified70.9%
[Start]70.9 | \[ \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 [=>]70.9 | \[ \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 [=>]70.9 | \[ \frac{\color{blue}{\left(\left(t + y\right) \cdot a + \left(x + y\right) \cdot z\right)} + \left(-y \cdot b\right)}{\left(x + t\right) + y}
\] |
associate-+l+ [=>]70.9 | \[ \frac{\color{blue}{\left(t + y\right) \cdot a + \left(\left(x + y\right) \cdot z + \left(-y \cdot b\right)\right)}}{\left(x + t\right) + y}
\] |
fma-def [=>]70.9 | \[ \frac{\color{blue}{\mathsf{fma}\left(t + y, a, \left(x + y\right) \cdot z + \left(-y \cdot b\right)\right)}}{\left(x + t\right) + y}
\] |
+-commutative [=>]70.9 | \[ \frac{\mathsf{fma}\left(\color{blue}{y + t}, a, \left(x + y\right) \cdot z + \left(-y \cdot b\right)\right)}{\left(x + t\right) + y}
\] |
*-commutative [=>]70.9 | \[ \frac{\mathsf{fma}\left(y + t, a, \color{blue}{z \cdot \left(x + y\right)} + \left(-y \cdot b\right)\right)}{\left(x + t\right) + y}
\] |
distribute-rgt-in [=>]70.9 | \[ \frac{\mathsf{fma}\left(y + t, a, \color{blue}{\left(x \cdot z + y \cdot z\right)} + \left(-y \cdot b\right)\right)}{\left(x + t\right) + y}
\] |
associate-+l+ [=>]70.9 | \[ \frac{\mathsf{fma}\left(y + t, a, \color{blue}{x \cdot z + \left(y \cdot z + \left(-y \cdot b\right)\right)}\right)}{\left(x + t\right) + y}
\] |
fma-def [=>]70.9 | \[ \frac{\mathsf{fma}\left(y + t, a, \color{blue}{\mathsf{fma}\left(x, z, y \cdot z + \left(-y \cdot b\right)\right)}\right)}{\left(x + t\right) + y}
\] |
sub-neg [<=]70.9 | \[ \frac{\mathsf{fma}\left(y + t, a, \mathsf{fma}\left(x, z, \color{blue}{y \cdot z - y \cdot b}\right)\right)}{\left(x + t\right) + y}
\] |
distribute-lft-out-- [=>]70.9 | \[ \frac{\mathsf{fma}\left(y + t, a, \mathsf{fma}\left(x, z, \color{blue}{y \cdot \left(z - b\right)}\right)\right)}{\left(x + t\right) + y}
\] |
+-commutative [=>]70.9 | \[ \frac{\mathsf{fma}\left(y + t, a, \mathsf{fma}\left(x, z, y \cdot \left(z - b\right)\right)\right)}{\color{blue}{y + \left(x + t\right)}}
\] |
Taylor expanded in a around inf 70.9%
Simplified93.1%
[Start]70.9 | \[ \frac{\left(z - b\right) \cdot y}{y + \left(t + x\right)} + \left(\frac{z \cdot x}{y + \left(t + x\right)} + \frac{a \cdot \left(y + t\right)}{y + \left(t + x\right)}\right)
\] |
|---|---|
*-commutative [<=]70.9 | \[ \frac{\color{blue}{y \cdot \left(z - b\right)}}{y + \left(t + x\right)} + \left(\frac{z \cdot x}{y + \left(t + x\right)} + \frac{a \cdot \left(y + t\right)}{y + \left(t + x\right)}\right)
\] |
+-commutative [=>]70.9 | \[ \frac{y \cdot \left(z - b\right)}{\color{blue}{\left(t + x\right) + y}} + \left(\frac{z \cdot x}{y + \left(t + x\right)} + \frac{a \cdot \left(y + t\right)}{y + \left(t + x\right)}\right)
\] |
+-commutative [=>]70.9 | \[ \frac{y \cdot \left(z - b\right)}{\color{blue}{\left(x + t\right)} + y} + \left(\frac{z \cdot x}{y + \left(t + x\right)} + \frac{a \cdot \left(y + t\right)}{y + \left(t + x\right)}\right)
\] |
associate-/l* [=>]80.1 | \[ \frac{y \cdot \left(z - b\right)}{\left(x + t\right) + y} + \left(\color{blue}{\frac{z}{\frac{y + \left(t + x\right)}{x}}} + \frac{a \cdot \left(y + t\right)}{y + \left(t + x\right)}\right)
\] |
+-commutative [=>]80.1 | \[ \frac{y \cdot \left(z - b\right)}{\left(x + t\right) + y} + \left(\frac{z}{\frac{\color{blue}{\left(t + x\right) + y}}{x}} + \frac{a \cdot \left(y + t\right)}{y + \left(t + x\right)}\right)
\] |
+-commutative [=>]80.1 | \[ \frac{y \cdot \left(z - b\right)}{\left(x + t\right) + y} + \left(\frac{z}{\frac{\color{blue}{\left(x + t\right)} + y}{x}} + \frac{a \cdot \left(y + t\right)}{y + \left(t + x\right)}\right)
\] |
associate-/l* [=>]93.1 | \[ \frac{y \cdot \left(z - b\right)}{\left(x + t\right) + y} + \left(\frac{z}{\frac{\left(x + t\right) + y}{x}} + \color{blue}{\frac{a}{\frac{y + \left(t + x\right)}{y + t}}}\right)
\] |
+-commutative [=>]93.1 | \[ \frac{y \cdot \left(z - b\right)}{\left(x + t\right) + y} + \left(\frac{z}{\frac{\left(x + t\right) + y}{x}} + \frac{a}{\frac{\color{blue}{\left(t + x\right) + y}}{y + t}}\right)
\] |
+-commutative [=>]93.1 | \[ \frac{y \cdot \left(z - b\right)}{\left(x + t\right) + y} + \left(\frac{z}{\frac{\left(x + t\right) + y}{x}} + \frac{a}{\frac{\color{blue}{\left(x + t\right)} + y}{y + t}}\right)
\] |
+-commutative [=>]93.1 | \[ \frac{y \cdot \left(z - b\right)}{\left(x + t\right) + y} + \left(\frac{z}{\frac{\left(x + t\right) + y}{x}} + \frac{a}{\frac{\left(x + t\right) + y}{\color{blue}{t + y}}}\right)
\] |
Final simplification89.9%
| Alternative 1 | |
|---|---|
| Accuracy | 88.2% |
| Cost | 4169 |
| Alternative 2 | |
|---|---|
| Accuracy | 58.5% |
| Cost | 2144 |
| Alternative 3 | |
|---|---|
| Accuracy | 58.4% |
| Cost | 2144 |
| Alternative 4 | |
|---|---|
| Accuracy | 55.2% |
| Cost | 1892 |
| Alternative 5 | |
|---|---|
| Accuracy | 57.9% |
| Cost | 1496 |
| Alternative 6 | |
|---|---|
| Accuracy | 58.2% |
| Cost | 1496 |
| Alternative 7 | |
|---|---|
| Accuracy | 51.9% |
| Cost | 1364 |
| Alternative 8 | |
|---|---|
| Accuracy | 59.0% |
| Cost | 1364 |
| Alternative 9 | |
|---|---|
| Accuracy | 59.1% |
| Cost | 1364 |
| Alternative 10 | |
|---|---|
| Accuracy | 52.4% |
| Cost | 976 |
| Alternative 11 | |
|---|---|
| Accuracy | 53.8% |
| Cost | 976 |
| Alternative 12 | |
|---|---|
| Accuracy | 52.5% |
| Cost | 848 |
| Alternative 13 | |
|---|---|
| Accuracy | 52.4% |
| Cost | 848 |
| Alternative 14 | |
|---|---|
| Accuracy | 42.8% |
| Cost | 592 |
| Alternative 15 | |
|---|---|
| Accuracy | 32.5% |
| Cost | 64 |
herbie shell --seed 2023129
(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)))