| Alternative 1 | |
|---|---|
| Error | 4.5 |
| Cost | 1864 |
(FPCore (x y z t) :precision binary64 (/ (* x (- y z)) (- t z)))
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ (* x (- y z)) (- t z))))
(if (<= t_1 (- INFINITY))
(+ x (* x (- (/ (- y t) z))))
(if (<= t_1 2e+246)
(/ (- (* x y) (* x z)) (- t z))
(+ x (* x (- (/ y z))))))))double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
double code(double x, double y, double z, double t) {
double t_1 = (x * (y - z)) / (t - z);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = x + (x * -((y - t) / z));
} else if (t_1 <= 2e+246) {
tmp = ((x * y) - (x * z)) / (t - z);
} else {
tmp = x + (x * -(y / z));
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
return (x * (y - z)) / (t - z);
}
public static double code(double x, double y, double z, double t) {
double t_1 = (x * (y - z)) / (t - z);
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = x + (x * -((y - t) / z));
} else if (t_1 <= 2e+246) {
tmp = ((x * y) - (x * z)) / (t - z);
} else {
tmp = x + (x * -(y / z));
}
return tmp;
}
def code(x, y, z, t): return (x * (y - z)) / (t - z)
def code(x, y, z, t): t_1 = (x * (y - z)) / (t - z) tmp = 0 if t_1 <= -math.inf: tmp = x + (x * -((y - t) / z)) elif t_1 <= 2e+246: tmp = ((x * y) - (x * z)) / (t - z) else: tmp = x + (x * -(y / z)) return tmp
function code(x, y, z, t) return Float64(Float64(x * Float64(y - z)) / Float64(t - z)) end
function code(x, y, z, t) t_1 = Float64(Float64(x * Float64(y - z)) / Float64(t - z)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(x + Float64(x * Float64(-Float64(Float64(y - t) / z)))); elseif (t_1 <= 2e+246) tmp = Float64(Float64(Float64(x * y) - Float64(x * z)) / Float64(t - z)); else tmp = Float64(x + Float64(x * Float64(-Float64(y / z)))); end return tmp end
function tmp = code(x, y, z, t) tmp = (x * (y - z)) / (t - z); end
function tmp_2 = code(x, y, z, t) t_1 = (x * (y - z)) / (t - z); tmp = 0.0; if (t_1 <= -Inf) tmp = x + (x * -((y - t) / z)); elseif (t_1 <= 2e+246) tmp = ((x * y) - (x * z)) / (t - z); else tmp = x + (x * -(y / z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(x * N[(y - z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(x + N[(x * (-N[(N[(y - t), $MachinePrecision] / z), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+246], N[(N[(N[(x * y), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision] / N[(t - z), $MachinePrecision]), $MachinePrecision], N[(x + N[(x * (-N[(y / z), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]]]]
\frac{x \cdot \left(y - z\right)}{t - z}
\begin{array}{l}
t_1 := \frac{x \cdot \left(y - z\right)}{t - z}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;x + x \cdot \left(-\frac{y - t}{z}\right)\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+246}:\\
\;\;\;\;\frac{x \cdot y - x \cdot z}{t - z}\\
\mathbf{else}:\\
\;\;\;\;x + x \cdot \left(-\frac{y}{z}\right)\\
\end{array}
Results
| Original | 11.6 |
|---|---|
| Target | 2.2 |
| Herbie | 4.5 |
if (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) < -inf.0Initial program 64.0
Taylor expanded in z around -inf 38.9
Simplified38.9
[Start]38.9 | \[ -1 \cdot \frac{y \cdot x - t \cdot x}{z} + x
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]38.9 | \[ \color{blue}{x + -1 \cdot \frac{y \cdot x - t \cdot x}{z}}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]38.9 | \[ x + \color{blue}{\frac{y \cdot x - t \cdot x}{z} \cdot -1}
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]38.9 | \[ x + \color{blue}{\left(-\frac{y \cdot x - t \cdot x}{z}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]38.9 | \[ x + \left(-\frac{y \cdot x - \color{blue}{x \cdot t}}{z}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-102 [=>]38.9 | \[ x + \left(-\frac{\color{blue}{x \cdot \left(y - t\right)}}{z}\right)
\] |
Taylor expanded in x around -inf 17.5
Simplified17.5
[Start]17.5 | \[ \left(1 + -1 \cdot \frac{y - t}{z}\right) \cdot x
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]17.5 | \[ \color{blue}{x \cdot \left(1 + -1 \cdot \frac{y - t}{z}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-37 [=>]17.5 | \[ \color{blue}{1 \cdot x + x \cdot \left(-1 \cdot \frac{y - t}{z}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]17.5 | \[ \color{blue}{x \cdot 1} + x \cdot \left(-1 \cdot \frac{y - t}{z}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [=>]17.5 | \[ \color{blue}{x} + x \cdot \left(-1 \cdot \frac{y - t}{z}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]17.5 | \[ x + x \cdot \color{blue}{\left(\frac{y - t}{z} \cdot -1\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]17.5 | \[ x + x \cdot \color{blue}{\left(-\frac{y - t}{z}\right)}
\] |
if -inf.0 < (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) < 2.00000000000000014e246Initial program 1.2
Applied egg-rr1.2
if 2.00000000000000014e246 < (/.f64 (*.f64 x (-.f64 y z)) (-.f64 t z)) Initial program 55.1
Taylor expanded in z around -inf 37.4
Simplified37.4
[Start]37.4 | \[ -1 \cdot \frac{y \cdot x - t \cdot x}{z} + x
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-35 [=>]37.4 | \[ \color{blue}{x + -1 \cdot \frac{y \cdot x - t \cdot x}{z}}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]37.4 | \[ x + \color{blue}{\frac{y \cdot x - t \cdot x}{z} \cdot -1}
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]37.4 | \[ x + \color{blue}{\left(-\frac{y \cdot x - t \cdot x}{z}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]37.4 | \[ x + \left(-\frac{y \cdot x - \color{blue}{x \cdot t}}{z}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-102 [=>]37.4 | \[ x + \left(-\frac{\color{blue}{x \cdot \left(y - t\right)}}{z}\right)
\] |
Taylor expanded in x around -inf 21.2
Simplified21.2
[Start]21.2 | \[ \left(1 + -1 \cdot \frac{y - t}{z}\right) \cdot x
\] |
|---|---|
rational_best_oopsla_all_46_json_45_simplify-74 [=>]21.2 | \[ \color{blue}{x \cdot \left(1 + -1 \cdot \frac{y - t}{z}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-37 [=>]21.2 | \[ \color{blue}{1 \cdot x + x \cdot \left(-1 \cdot \frac{y - t}{z}\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [<=]21.2 | \[ \color{blue}{x \cdot 1} + x \cdot \left(-1 \cdot \frac{y - t}{z}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-52 [=>]21.2 | \[ \color{blue}{x} + x \cdot \left(-1 \cdot \frac{y - t}{z}\right)
\] |
rational_best_oopsla_all_46_json_45_simplify-74 [=>]21.2 | \[ x + x \cdot \color{blue}{\left(\frac{y - t}{z} \cdot -1\right)}
\] |
rational_best_oopsla_all_46_json_45_simplify-92 [=>]21.2 | \[ x + x \cdot \color{blue}{\left(-\frac{y - t}{z}\right)}
\] |
Taylor expanded in y around inf 21.2
Final simplification4.5
| Alternative 1 | |
|---|---|
| Error | 4.5 |
| Cost | 1864 |
| Alternative 2 | |
|---|---|
| Error | 4.5 |
| Cost | 1864 |
| Alternative 3 | |
|---|---|
| Error | 21.0 |
| Cost | 1436 |
| Alternative 4 | |
|---|---|
| Error | 25.7 |
| Cost | 844 |
| Alternative 5 | |
|---|---|
| Error | 17.0 |
| Cost | 776 |
| Alternative 6 | |
|---|---|
| Error | 25.6 |
| Cost | 716 |
| Alternative 7 | |
|---|---|
| Error | 22.2 |
| Cost | 712 |
| Alternative 8 | |
|---|---|
| Error | 19.0 |
| Cost | 712 |
| Alternative 9 | |
|---|---|
| Error | 19.4 |
| Cost | 712 |
| Alternative 10 | |
|---|---|
| Error | 25.4 |
| Cost | 584 |
| Alternative 11 | |
|---|---|
| Error | 39.6 |
| Cost | 64 |
herbie shell --seed 2023090
(FPCore (x y z t)
:name "Graphics.Rendering.Chart.Plot.AreaSpots:renderAreaSpots4D from Chart-1.5.3"
:precision binary64
:herbie-target
(/ x (/ (- t z) (- y z)))
(/ (* x (- y z)) (- t z)))