| Alternative 1 | |
|---|---|
| Error | 4.2 |
| Cost | 3792 |
(FPCore (x y z t a b c i) :precision binary64 (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))
(FPCore (x y z t a b c i)
:precision binary64
(let* ((t_1 (+ a (* b c))) (t_2 (* (* t_1 c) i)))
(if (<= t_2 (- INFINITY))
(* 2.0 (+ (* x y) (- (* z t) (* c (* t_1 i)))))
(if (<= t_2 5e+299)
(* 2.0 (- (+ (* x y) (* z t)) t_2))
(* 2.0 (+ (* x y) (- (* z t) (/ c (/ 1.0 (* b (* c i)))))))))))double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = a + (b * c);
double t_2 = (t_1 * c) * i;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = 2.0 * ((x * y) + ((z * t) - (c * (t_1 * i))));
} else if (t_2 <= 5e+299) {
tmp = 2.0 * (((x * y) + (z * t)) - t_2);
} else {
tmp = 2.0 * ((x * y) + ((z * t) - (c / (1.0 / (b * (c * i))))));
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i));
}
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
double t_1 = a + (b * c);
double t_2 = (t_1 * c) * i;
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = 2.0 * ((x * y) + ((z * t) - (c * (t_1 * i))));
} else if (t_2 <= 5e+299) {
tmp = 2.0 * (((x * y) + (z * t)) - t_2);
} else {
tmp = 2.0 * ((x * y) + ((z * t) - (c / (1.0 / (b * (c * i))))));
}
return tmp;
}
def code(x, y, z, t, a, b, c, i): return 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i))
def code(x, y, z, t, a, b, c, i): t_1 = a + (b * c) t_2 = (t_1 * c) * i tmp = 0 if t_2 <= -math.inf: tmp = 2.0 * ((x * y) + ((z * t) - (c * (t_1 * i)))) elif t_2 <= 5e+299: tmp = 2.0 * (((x * y) + (z * t)) - t_2) else: tmp = 2.0 * ((x * y) + ((z * t) - (c / (1.0 / (b * (c * i)))))) return tmp
function code(x, y, z, t, a, b, c, i) return Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - Float64(Float64(Float64(a + Float64(b * c)) * c) * i))) end
function code(x, y, z, t, a, b, c, i) t_1 = Float64(a + Float64(b * c)) t_2 = Float64(Float64(t_1 * c) * i) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(2.0 * Float64(Float64(x * y) + Float64(Float64(z * t) - Float64(c * Float64(t_1 * i))))); elseif (t_2 <= 5e+299) tmp = Float64(2.0 * Float64(Float64(Float64(x * y) + Float64(z * t)) - t_2)); else tmp = Float64(2.0 * Float64(Float64(x * y) + Float64(Float64(z * t) - Float64(c / Float64(1.0 / Float64(b * Float64(c * i))))))); end return tmp end
function tmp = code(x, y, z, t, a, b, c, i) tmp = 2.0 * (((x * y) + (z * t)) - (((a + (b * c)) * c) * i)); end
function tmp_2 = code(x, y, z, t, a, b, c, i) t_1 = a + (b * c); t_2 = (t_1 * c) * i; tmp = 0.0; if (t_2 <= -Inf) tmp = 2.0 * ((x * y) + ((z * t) - (c * (t_1 * i)))); elseif (t_2 <= 5e+299) tmp = 2.0 * (((x * y) + (z * t)) - t_2); else tmp = 2.0 * ((x * y) + ((z * t) - (c / (1.0 / (b * (c * i)))))); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision] * c), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(a + N[(b * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$1 * c), $MachinePrecision] * i), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(2.0 * N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] - N[(c * N[(t$95$1 * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e+299], N[(2.0 * N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]), $MachinePrecision], N[(2.0 * N[(N[(x * y), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] - N[(c / N[(1.0 / N[(b * N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\begin{array}{l}
t_1 := a + b \cdot c\\
t_2 := \left(t_1 \cdot c\right) \cdot i\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;2 \cdot \left(x \cdot y + \left(z \cdot t - c \cdot \left(t_1 \cdot i\right)\right)\right)\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+299}:\\
\;\;\;\;2 \cdot \left(\left(x \cdot y + z \cdot t\right) - t_2\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(x \cdot y + \left(z \cdot t - \frac{c}{\frac{1}{b \cdot \left(c \cdot i\right)}}\right)\right)\\
\end{array}
Results
| Original | 6.3 |
|---|---|
| Target | 1.8 |
| Herbie | 1.6 |
if (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < -inf.0Initial program 64.0
Simplified10.0
[Start]64.0 | \[ 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\] |
|---|---|
rational.json-simplify-1 [=>]64.0 | \[ 2 \cdot \left(\color{blue}{\left(z \cdot t + x \cdot y\right)} - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\] |
rational.json-simplify-48 [=>]64.0 | \[ 2 \cdot \color{blue}{\left(x \cdot y + \left(z \cdot t - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\right)}
\] |
rational.json-simplify-2 [=>]64.0 | \[ 2 \cdot \left(x \cdot y + \left(z \cdot t - \color{blue}{i \cdot \left(\left(a + b \cdot c\right) \cdot c\right)}\right)\right)
\] |
rational.json-simplify-2 [=>]64.0 | \[ 2 \cdot \left(x \cdot y + \left(z \cdot t - i \cdot \color{blue}{\left(c \cdot \left(a + b \cdot c\right)\right)}\right)\right)
\] |
rational.json-simplify-43 [=>]10.0 | \[ 2 \cdot \left(x \cdot y + \left(z \cdot t - \color{blue}{c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)}\right)\right)
\] |
if -inf.0 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) < 5.0000000000000003e299Initial program 0.3
if 5.0000000000000003e299 < (*.f64 (*.f64 (+.f64 a (*.f64 b c)) c) i) Initial program 59.4
Simplified11.9
[Start]59.4 | \[ 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\] |
|---|---|
rational.json-simplify-1 [=>]59.4 | \[ 2 \cdot \left(\color{blue}{\left(z \cdot t + x \cdot y\right)} - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\] |
rational.json-simplify-48 [=>]59.4 | \[ 2 \cdot \color{blue}{\left(x \cdot y + \left(z \cdot t - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\right)}
\] |
rational.json-simplify-2 [=>]59.4 | \[ 2 \cdot \left(x \cdot y + \left(z \cdot t - \color{blue}{i \cdot \left(\left(a + b \cdot c\right) \cdot c\right)}\right)\right)
\] |
rational.json-simplify-2 [=>]59.4 | \[ 2 \cdot \left(x \cdot y + \left(z \cdot t - i \cdot \color{blue}{\left(c \cdot \left(a + b \cdot c\right)\right)}\right)\right)
\] |
rational.json-simplify-43 [=>]11.9 | \[ 2 \cdot \left(x \cdot y + \left(z \cdot t - \color{blue}{c \cdot \left(\left(a + b \cdot c\right) \cdot i\right)}\right)\right)
\] |
Taylor expanded in a around 0 20.9
Applied egg-rr41.6
Simplified21.2
[Start]41.6 | \[ 2 \cdot \left(x \cdot y + \left(z \cdot t - \frac{i \cdot b}{\frac{1}{c \cdot c}}\right)\right)
\] |
|---|---|
rational.json-simplify-61 [=>]41.6 | \[ 2 \cdot \left(x \cdot y + \left(z \cdot t - \color{blue}{\frac{c \cdot c}{\frac{1}{i \cdot b}}}\right)\right)
\] |
rational.json-simplify-49 [=>]21.2 | \[ 2 \cdot \left(x \cdot y + \left(z \cdot t - \color{blue}{c \cdot \frac{c}{\frac{1}{i \cdot b}}}\right)\right)
\] |
rational.json-simplify-46 [=>]21.2 | \[ 2 \cdot \left(x \cdot y + \left(z \cdot t - c \cdot \frac{c}{\color{blue}{\frac{\frac{1}{i}}{b}}}\right)\right)
\] |
Applied egg-rr20.9
Applied egg-rr20.9
Simplified18.2
[Start]20.9 | \[ 2 \cdot \left(x \cdot y + \left(z \cdot t - \frac{c}{\frac{1}{c \cdot \left(i \cdot b\right)} + 0}\right)\right)
\] |
|---|---|
rational.json-simplify-4 [=>]20.9 | \[ 2 \cdot \left(x \cdot y + \left(z \cdot t - \frac{c}{\color{blue}{\frac{1}{c \cdot \left(i \cdot b\right)}}}\right)\right)
\] |
rational.json-simplify-43 [<=]18.2 | \[ 2 \cdot \left(x \cdot y + \left(z \cdot t - \frac{c}{\frac{1}{\color{blue}{b \cdot \left(c \cdot i\right)}}}\right)\right)
\] |
Final simplification1.6
| Alternative 1 | |
|---|---|
| Error | 4.2 |
| Cost | 3792 |
| Alternative 2 | |
|---|---|
| Error | 9.7 |
| Cost | 3536 |
| Alternative 3 | |
|---|---|
| Error | 4.3 |
| Cost | 3148 |
| Alternative 4 | |
|---|---|
| Error | 11.9 |
| Cost | 2892 |
| Alternative 5 | |
|---|---|
| Error | 20.6 |
| Cost | 2264 |
| Alternative 6 | |
|---|---|
| Error | 20.7 |
| Cost | 2264 |
| Alternative 7 | |
|---|---|
| Error | 23.1 |
| Cost | 2220 |
| Alternative 8 | |
|---|---|
| Error | 12.0 |
| Cost | 1480 |
| Alternative 9 | |
|---|---|
| Error | 20.6 |
| Cost | 1232 |
| Alternative 10 | |
|---|---|
| Error | 36.7 |
| Cost | 1112 |
| Alternative 11 | |
|---|---|
| Error | 36.8 |
| Cost | 1112 |
| Alternative 12 | |
|---|---|
| Error | 24.9 |
| Cost | 1104 |
| Alternative 13 | |
|---|---|
| Error | 22.3 |
| Cost | 1104 |
| Alternative 14 | |
|---|---|
| Error | 36.0 |
| Cost | 848 |
| Alternative 15 | |
|---|---|
| Error | 21.5 |
| Cost | 840 |
| Alternative 16 | |
|---|---|
| Error | 42.5 |
| Cost | 320 |
herbie shell --seed 2023075
(FPCore (x y z t a b c i)
:name "Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, A"
:precision binary64
:herbie-target
(* 2.0 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i))))
(* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))