| Alternative 1 | |
|---|---|
| Error | 8.5 |
| Cost | 5840 |
(FPCore (x y z t a b) :precision binary64 (/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))
(FPCore (x y z t a b)
:precision binary64
(let* ((t_1 (+ (* x y) (* z (- t a)))) (t_2 (/ t_1 (+ y (* z (- b y))))))
(if (<= t_2 (- INFINITY))
(/ x (- 1.0 z))
(if (<= t_2 -4e-293)
t_2
(if (<= t_2 2e-243)
(+
(-
(/
(*
-1.0
(- (/ (* y x) (- b y)) (/ (* (- t a) y) (pow (- b y) 2.0))))
z))
(- (/ t (- b y)) (/ a (- b y))))
(if (<= t_2 1e+303)
(/ t_1 (- (+ y (* z b)) (* y z)))
(/ (- t a) (- b y))))))))double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x * y) + (z * (t - a));
double t_2 = t_1 / (y + (z * (b - y)));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = x / (1.0 - z);
} else if (t_2 <= -4e-293) {
tmp = t_2;
} else if (t_2 <= 2e-243) {
tmp = -((-1.0 * (((y * x) / (b - y)) - (((t - a) * y) / pow((b - y), 2.0)))) / z) + ((t / (b - y)) - (a / (b - y)));
} else if (t_2 <= 1e+303) {
tmp = t_1 / ((y + (z * b)) - (y * z));
} else {
tmp = (t - a) / (b - y);
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b) {
return ((x * y) + (z * (t - a))) / (y + (z * (b - y)));
}
public static double code(double x, double y, double z, double t, double a, double b) {
double t_1 = (x * y) + (z * (t - a));
double t_2 = t_1 / (y + (z * (b - y)));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = x / (1.0 - z);
} else if (t_2 <= -4e-293) {
tmp = t_2;
} else if (t_2 <= 2e-243) {
tmp = -((-1.0 * (((y * x) / (b - y)) - (((t - a) * y) / Math.pow((b - y), 2.0)))) / z) + ((t / (b - y)) - (a / (b - y)));
} else if (t_2 <= 1e+303) {
tmp = t_1 / ((y + (z * b)) - (y * z));
} else {
tmp = (t - a) / (b - y);
}
return tmp;
}
def code(x, y, z, t, a, b): return ((x * y) + (z * (t - a))) / (y + (z * (b - y)))
def code(x, y, z, t, a, b): t_1 = (x * y) + (z * (t - a)) t_2 = t_1 / (y + (z * (b - y))) tmp = 0 if t_2 <= -math.inf: tmp = x / (1.0 - z) elif t_2 <= -4e-293: tmp = t_2 elif t_2 <= 2e-243: tmp = -((-1.0 * (((y * x) / (b - y)) - (((t - a) * y) / math.pow((b - y), 2.0)))) / z) + ((t / (b - y)) - (a / (b - y))) elif t_2 <= 1e+303: tmp = t_1 / ((y + (z * b)) - (y * z)) else: tmp = (t - a) / (b - y) return tmp
function code(x, y, z, t, a, b) return Float64(Float64(Float64(x * y) + Float64(z * Float64(t - a))) / Float64(y + Float64(z * Float64(b - y)))) end
function code(x, y, z, t, a, b) t_1 = Float64(Float64(x * y) + Float64(z * Float64(t - a))) t_2 = Float64(t_1 / Float64(y + Float64(z * Float64(b - y)))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(x / Float64(1.0 - z)); elseif (t_2 <= -4e-293) tmp = t_2; elseif (t_2 <= 2e-243) tmp = Float64(Float64(-Float64(Float64(-1.0 * Float64(Float64(Float64(y * x) / Float64(b - y)) - Float64(Float64(Float64(t - a) * y) / (Float64(b - y) ^ 2.0)))) / z)) + Float64(Float64(t / Float64(b - y)) - Float64(a / Float64(b - y)))); elseif (t_2 <= 1e+303) tmp = Float64(t_1 / Float64(Float64(y + Float64(z * b)) - Float64(y * z))); else tmp = Float64(Float64(t - a) / Float64(b - y)); end return tmp end
function tmp = code(x, y, z, t, a, b) tmp = ((x * y) + (z * (t - a))) / (y + (z * (b - y))); end
function tmp_2 = code(x, y, z, t, a, b) t_1 = (x * y) + (z * (t - a)); t_2 = t_1 / (y + (z * (b - y))); tmp = 0.0; if (t_2 <= -Inf) tmp = x / (1.0 - z); elseif (t_2 <= -4e-293) tmp = t_2; elseif (t_2 <= 2e-243) tmp = -((-1.0 * (((y * x) / (b - y)) - (((t - a) * y) / ((b - y) ^ 2.0)))) / z) + ((t / (b - y)) - (a / (b - y))); elseif (t_2 <= 1e+303) tmp = t_1 / ((y + (z * b)) - (y * z)); else tmp = (t - a) / (b - y); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(z * N[(t - a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 / N[(y + N[(z * N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(x / N[(1.0 - z), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, -4e-293], t$95$2, If[LessEqual[t$95$2, 2e-243], N[((-N[(N[(-1.0 * N[(N[(N[(y * x), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(t - a), $MachinePrecision] * y), $MachinePrecision] / N[Power[N[(b - y), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]) + N[(N[(t / N[(b - y), $MachinePrecision]), $MachinePrecision] - N[(a / N[(b - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 1e+303], N[(t$95$1 / N[(N[(y + N[(z * b), $MachinePrecision]), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t - a), $MachinePrecision] / N[(b - y), $MachinePrecision]), $MachinePrecision]]]]]]]
\frac{x \cdot y + z \cdot \left(t - a\right)}{y + z \cdot \left(b - y\right)}
\begin{array}{l}
t_1 := x \cdot y + z \cdot \left(t - a\right)\\
t_2 := \frac{t_1}{y + z \cdot \left(b - y\right)}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\frac{x}{1 - z}\\
\mathbf{elif}\;t_2 \leq -4 \cdot 10^{-293}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{-243}:\\
\;\;\;\;\left(-\frac{-1 \cdot \left(\frac{y \cdot x}{b - y} - \frac{\left(t - a\right) \cdot y}{{\left(b - y\right)}^{2}}\right)}{z}\right) + \left(\frac{t}{b - y} - \frac{a}{b - y}\right)\\
\mathbf{elif}\;t_2 \leq 10^{+303}:\\
\;\;\;\;\frac{t_1}{\left(y + z \cdot b\right) - y \cdot z}\\
\mathbf{else}:\\
\;\;\;\;\frac{t - a}{b - y}\\
\end{array}
Results
| Original | 22.8 |
|---|---|
| Target | 17.8 |
| Herbie | 8.4 |
if (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -inf.0Initial program 64.0
Taylor expanded in y around inf 31.0
Simplified31.0
[Start]31.0 | \[ \frac{x}{-1 \cdot z + 1}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-11 [=>]31.0 | \[ \frac{x}{\color{blue}{-1 \cdot z - -1}}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]31.0 | \[ \frac{x}{\color{blue}{z \cdot -1} - -1}
\] |
rational_best_oopsla_all_46_json_45_simplify-94 [<=]31.0 | \[ \frac{x}{\color{blue}{\left(-z\right)} - -1}
\] |
rational_best_oopsla_all_46_json_45_simplify-97 [=>]31.0 | \[ \frac{x}{\color{blue}{\left(0 - z\right)} - -1}
\] |
rational_best_oopsla_all_46_json_45_simplify-105 [=>]31.0 | \[ \frac{x}{\color{blue}{\left(0 - -1\right) - z}}
\] |
metadata-eval [=>]31.0 | \[ \frac{x}{\color{blue}{1} - z}
\] |
if -inf.0 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < -4.0000000000000002e-293Initial program 0.3
if -4.0000000000000002e-293 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 1.99999999999999999e-243Initial program 40.6
Taylor expanded in z around -inf 12.2
Simplified12.2
[Start]12.2 | \[ \left(\frac{t}{b - y} + -1 \cdot \frac{-1 \cdot \frac{y \cdot x}{b - y} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(b - y\right)}^{2}}}{z}\right) - \frac{a}{b - y}
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-107 [=>]12.2 | \[ \color{blue}{-1 \cdot \frac{-1 \cdot \frac{y \cdot x}{b - y} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(b - y\right)}^{2}}}{z} + \left(\frac{t}{b - y} - \frac{a}{b - y}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]12.2 | \[ \color{blue}{\frac{-1 \cdot \frac{y \cdot x}{b - y} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(b - y\right)}^{2}}}{z} \cdot -1} + \left(\frac{t}{b - y} - \frac{a}{b - y}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]12.2 | \[ \color{blue}{\left(-\frac{-1 \cdot \frac{y \cdot x}{b - y} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(b - y\right)}^{2}}}{z}\right)} + \left(\frac{t}{b - y} - \frac{a}{b - y}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]12.2 | \[ \left(-\frac{\color{blue}{\frac{y \cdot x}{b - y} \cdot -1} - -1 \cdot \frac{\left(t - a\right) \cdot y}{{\left(b - y\right)}^{2}}}{z}\right) + \left(\frac{t}{b - y} - \frac{a}{b - y}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-102 [=>]12.2 | \[ \left(-\frac{\color{blue}{-1 \cdot \left(\frac{y \cdot x}{b - y} - \frac{\left(t - a\right) \cdot y}{{\left(b - y\right)}^{2}}\right)}}{z}\right) + \left(\frac{t}{b - y} - \frac{a}{b - y}\right)
\] |
if 1.99999999999999999e-243 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) < 1e303Initial program 0.3
Applied egg-rr0.3
if 1e303 < (/.f64 (+.f64 (*.f64 x y) (*.f64 z (-.f64 t a))) (+.f64 y (*.f64 z (-.f64 b y)))) Initial program 63.6
Taylor expanded in z around inf 21.6
Final simplification8.4
| Alternative 1 | |
|---|---|
| Error | 8.5 |
| Cost | 5840 |
| Alternative 2 | |
|---|---|
| Error | 8.5 |
| Cost | 5712 |
| Alternative 3 | |
|---|---|
| Error | 22.6 |
| Cost | 1492 |
| Alternative 4 | |
|---|---|
| Error | 22.6 |
| Cost | 1492 |
| Alternative 5 | |
|---|---|
| Error | 44.4 |
| Cost | 1312 |
| Alternative 6 | |
|---|---|
| Error | 44.2 |
| Cost | 1116 |
| Alternative 7 | |
|---|---|
| Error | 38.7 |
| Cost | 1112 |
| Alternative 8 | |
|---|---|
| Error | 21.7 |
| Cost | 976 |
| Alternative 9 | |
|---|---|
| Error | 44.8 |
| Cost | 852 |
| Alternative 10 | |
|---|---|
| Error | 36.4 |
| Cost | 848 |
| Alternative 11 | |
|---|---|
| Error | 29.8 |
| Cost | 584 |
| Alternative 12 | |
|---|---|
| Error | 41.0 |
| Cost | 456 |
| Alternative 13 | |
|---|---|
| Error | 46.5 |
| Cost | 64 |
herbie shell --seed 2023090
(FPCore (x y z t a b)
:name "Development.Shake.Progress:decay from shake-0.15.5"
:precision binary64
:herbie-target
(- (/ (+ (* z t) (* y x)) (+ y (* z (- b y)))) (/ a (+ (- b y) (/ y z))))
(/ (+ (* x y) (* z (- t a))) (+ y (* z (- b y)))))