| Alternative 1 | |
|---|---|
| Error | 23.7 |
| Cost | 2780 |
(FPCore (x y z t a b c i j k) :precision binary64 (- (- (+ (- (* (* (* (* x 18.0) y) z) t) (* (* a 4.0) t)) (* b c)) (* (* x 4.0) i)) (* (* j 27.0) k)))
(FPCore (x y z t a b c i j k)
:precision binary64
(let* ((t_1
(+
(* x (- (* -4.0 i) (* y (* z (* t -18.0)))))
(- (* b c) (* j (* 27.0 k)))))
(t_2
(-
(-
(+ (- (* (* (* (* x 18.0) y) z) t) (* (* a 4.0) t)) (* b c))
(* (* x 4.0) i))
(* (* j 27.0) k))))
(if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 5e+303) t_2 t_1))))double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
return (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k);
}
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double t_1 = (x * ((-4.0 * i) - (y * (z * (t * -18.0))))) + ((b * c) - (j * (27.0 * k)));
double t_2 = (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k);
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 5e+303) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
return (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k);
}
public static double code(double x, double y, double z, double t, double a, double b, double c, double i, double j, double k) {
double t_1 = (x * ((-4.0 * i) - (y * (z * (t * -18.0))))) + ((b * c) - (j * (27.0 * k)));
double t_2 = (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k);
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= 5e+303) {
tmp = t_2;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t, a, b, c, i, j, k): return (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k)
def code(x, y, z, t, a, b, c, i, j, k): t_1 = (x * ((-4.0 * i) - (y * (z * (t * -18.0))))) + ((b * c) - (j * (27.0 * k))) t_2 = (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k) tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= 5e+303: tmp = t_2 else: tmp = t_1 return tmp
function code(x, y, z, t, a, b, c, i, j, k) return Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * 18.0) * y) * z) * t) - Float64(Float64(a * 4.0) * t)) + Float64(b * c)) - Float64(Float64(x * 4.0) * i)) - Float64(Float64(j * 27.0) * k)) end
function code(x, y, z, t, a, b, c, i, j, k) t_1 = Float64(Float64(x * Float64(Float64(-4.0 * i) - Float64(y * Float64(z * Float64(t * -18.0))))) + Float64(Float64(b * c) - Float64(j * Float64(27.0 * k)))) t_2 = Float64(Float64(Float64(Float64(Float64(Float64(Float64(Float64(x * 18.0) * y) * z) * t) - Float64(Float64(a * 4.0) * t)) + Float64(b * c)) - Float64(Float64(x * 4.0) * i)) - Float64(Float64(j * 27.0) * k)) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 5e+303) tmp = t_2; else tmp = t_1; end return tmp end
function tmp = code(x, y, z, t, a, b, c, i, j, k) tmp = (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k); end
function tmp_2 = code(x, y, z, t, a, b, c, i, j, k) t_1 = (x * ((-4.0 * i) - (y * (z * (t * -18.0))))) + ((b * c) - (j * (27.0 * k))); t_2 = (((((((x * 18.0) * y) * z) * t) - ((a * 4.0) * t)) + (b * c)) - ((x * 4.0) * i)) - ((j * 27.0) * k); tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= 5e+303) tmp = t_2; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := N[(N[(N[(N[(N[(N[(N[(N[(x * 18.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(b * c), $MachinePrecision]), $MachinePrecision] - N[(N[(x * 4.0), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision] - N[(N[(j * 27.0), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_, i_, j_, k_] := Block[{t$95$1 = N[(N[(x * N[(N[(-4.0 * i), $MachinePrecision] - N[(y * N[(z * N[(t * -18.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(b * c), $MachinePrecision] - N[(j * N[(27.0 * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(N[(N[(N[(N[(N[(x * 18.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision] - N[(N[(a * 4.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(b * c), $MachinePrecision]), $MachinePrecision] - N[(N[(x * 4.0), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision] - N[(N[(j * 27.0), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 5e+303], t$95$2, t$95$1]]]]
\left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k
\begin{array}{l}
t_1 := x \cdot \left(-4 \cdot i - y \cdot \left(z \cdot \left(t \cdot -18\right)\right)\right) + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)\\
t_2 := \left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_2 \leq 5 \cdot 10^{+303}:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
Results
| Original | 5.7 |
|---|---|
| Target | 1.7 |
| Herbie | 0.9 |
if (-.f64 (-.f64 (+.f64 (-.f64 (*.f64 (*.f64 (*.f64 (*.f64 x 18) y) z) t) (*.f64 (*.f64 a 4) t)) (*.f64 b c)) (*.f64 (*.f64 x 4) i)) (*.f64 (*.f64 j 27) k)) < -inf.0 or 4.9999999999999997e303 < (-.f64 (-.f64 (+.f64 (-.f64 (*.f64 (*.f64 (*.f64 (*.f64 x 18) y) z) t) (*.f64 (*.f64 a 4) t)) (*.f64 b c)) (*.f64 (*.f64 x 4) i)) (*.f64 (*.f64 j 27) k)) Initial program 58.2
Simplified36.0
[Start]58.2 | \[ \left(\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\right) - \left(j \cdot 27\right) \cdot k
\] |
|---|---|
rational.json-simplify-48 [=>]58.2 | \[ \color{blue}{\left(b \cdot c + \left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) - \left(x \cdot 4\right) \cdot i\right)\right)} - \left(j \cdot 27\right) \cdot k
\] |
rational.json-simplify-48 [=>]58.2 | \[ \color{blue}{\left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - \left(a \cdot 4\right) \cdot t\right) - \left(x \cdot 4\right) \cdot i\right) + \left(b \cdot c - \left(j \cdot 27\right) \cdot k\right)}
\] |
rational.json-simplify-2 [=>]58.2 | \[ \left(\left(\color{blue}{t \cdot \left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right)} - \left(a \cdot 4\right) \cdot t\right) - \left(x \cdot 4\right) \cdot i\right) + \left(b \cdot c - \left(j \cdot 27\right) \cdot k\right)
\] |
rational.json-simplify-52 [=>]58.2 | \[ \left(\color{blue}{t \cdot \left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z - a \cdot 4\right)} - \left(x \cdot 4\right) \cdot i\right) + \left(b \cdot c - \left(j \cdot 27\right) \cdot k\right)
\] |
rational.json-simplify-2 [=>]58.2 | \[ \left(t \cdot \left(\color{blue}{z \cdot \left(\left(x \cdot 18\right) \cdot y\right)} - a \cdot 4\right) - \left(x \cdot 4\right) \cdot i\right) + \left(b \cdot c - \left(j \cdot 27\right) \cdot k\right)
\] |
rational.json-simplify-43 [=>]36.8 | \[ \left(t \cdot \left(\color{blue}{\left(x \cdot 18\right) \cdot \left(y \cdot z\right)} - a \cdot 4\right) - \left(x \cdot 4\right) \cdot i\right) + \left(b \cdot c - \left(j \cdot 27\right) \cdot k\right)
\] |
rational.json-simplify-2 [=>]36.8 | \[ \left(t \cdot \left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right) - a \cdot 4\right) - \color{blue}{i \cdot \left(x \cdot 4\right)}\right) + \left(b \cdot c - \left(j \cdot 27\right) \cdot k\right)
\] |
rational.json-simplify-43 [=>]36.8 | \[ \left(t \cdot \left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right) - a \cdot 4\right) - \color{blue}{x \cdot \left(4 \cdot i\right)}\right) + \left(b \cdot c - \left(j \cdot 27\right) \cdot k\right)
\] |
rational.json-simplify-2 [=>]36.8 | \[ \left(t \cdot \left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right) - a \cdot 4\right) - x \cdot \left(4 \cdot i\right)\right) + \left(b \cdot c - \color{blue}{k \cdot \left(j \cdot 27\right)}\right)
\] |
rational.json-simplify-43 [=>]36.0 | \[ \left(t \cdot \left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right) - a \cdot 4\right) - x \cdot \left(4 \cdot i\right)\right) + \left(b \cdot c - \color{blue}{j \cdot \left(27 \cdot k\right)}\right)
\] |
Taylor expanded in x around -inf 6.8
Simplified6.8
[Start]6.8 | \[ -1 \cdot \left(\left(-18 \cdot \left(y \cdot \left(t \cdot z\right)\right) - -4 \cdot i\right) \cdot x\right) + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
|---|---|
rational.json-simplify-2 [=>]6.8 | \[ -1 \cdot \color{blue}{\left(x \cdot \left(-18 \cdot \left(y \cdot \left(t \cdot z\right)\right) - -4 \cdot i\right)\right)} + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
rational.json-simplify-43 [=>]6.8 | \[ \color{blue}{x \cdot \left(\left(-18 \cdot \left(y \cdot \left(t \cdot z\right)\right) - -4 \cdot i\right) \cdot -1\right)} + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
rational.json-simplify-9 [=>]6.8 | \[ x \cdot \color{blue}{\left(-\left(-18 \cdot \left(y \cdot \left(t \cdot z\right)\right) - -4 \cdot i\right)\right)} + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
rational.json-simplify-12 [=>]6.8 | \[ x \cdot \color{blue}{\left(0 - \left(-18 \cdot \left(y \cdot \left(t \cdot z\right)\right) - -4 \cdot i\right)\right)} + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
rational.json-simplify-2 [=>]6.8 | \[ x \cdot \left(0 - \left(-18 \cdot \left(y \cdot \left(t \cdot z\right)\right) - \color{blue}{i \cdot -4}\right)\right) + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
metadata-eval [<=]6.8 | \[ x \cdot \left(0 - \left(-18 \cdot \left(y \cdot \left(t \cdot z\right)\right) - i \cdot \color{blue}{\frac{4}{-1}}\right)\right) + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
rational.json-simplify-49 [<=]6.8 | \[ x \cdot \left(0 - \left(-18 \cdot \left(y \cdot \left(t \cdot z\right)\right) - \color{blue}{\frac{4 \cdot i}{-1}}\right)\right) + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
rational.json-simplify-45 [=>]6.8 | \[ x \cdot \color{blue}{\left(\frac{4 \cdot i}{-1} - \left(-18 \cdot \left(y \cdot \left(t \cdot z\right)\right) - 0\right)\right)} + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
rational.json-simplify-49 [=>]6.8 | \[ x \cdot \left(\color{blue}{i \cdot \frac{4}{-1}} - \left(-18 \cdot \left(y \cdot \left(t \cdot z\right)\right) - 0\right)\right) + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
metadata-eval [=>]6.8 | \[ x \cdot \left(i \cdot \color{blue}{-4} - \left(-18 \cdot \left(y \cdot \left(t \cdot z\right)\right) - 0\right)\right) + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
rational.json-simplify-2 [<=]6.8 | \[ x \cdot \left(\color{blue}{-4 \cdot i} - \left(-18 \cdot \left(y \cdot \left(t \cdot z\right)\right) - 0\right)\right) + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
rational.json-simplify-5 [=>]6.8 | \[ x \cdot \left(-4 \cdot i - \color{blue}{-18 \cdot \left(y \cdot \left(t \cdot z\right)\right)}\right) + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
rational.json-simplify-43 [=>]6.8 | \[ x \cdot \left(-4 \cdot i - \color{blue}{y \cdot \left(\left(t \cdot z\right) \cdot -18\right)}\right) + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
rational.json-simplify-2 [=>]6.8 | \[ x \cdot \left(-4 \cdot i - y \cdot \color{blue}{\left(-18 \cdot \left(t \cdot z\right)\right)}\right) + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
rational.json-simplify-2 [=>]6.8 | \[ x \cdot \left(-4 \cdot i - y \cdot \left(-18 \cdot \color{blue}{\left(z \cdot t\right)}\right)\right) + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
rational.json-simplify-43 [=>]6.8 | \[ x \cdot \left(-4 \cdot i - y \cdot \color{blue}{\left(z \cdot \left(t \cdot -18\right)\right)}\right) + \left(b \cdot c - j \cdot \left(27 \cdot k\right)\right)
\] |
if -inf.0 < (-.f64 (-.f64 (+.f64 (-.f64 (*.f64 (*.f64 (*.f64 (*.f64 x 18) y) z) t) (*.f64 (*.f64 a 4) t)) (*.f64 b c)) (*.f64 (*.f64 x 4) i)) (*.f64 (*.f64 j 27) k)) < 4.9999999999999997e303Initial program 0.3
Final simplification0.9
| Alternative 1 | |
|---|---|
| Error | 23.7 |
| Cost | 2780 |
| Alternative 2 | |
|---|---|
| Error | 19.4 |
| Cost | 2776 |
| Alternative 3 | |
|---|---|
| Error | 18.9 |
| Cost | 2256 |
| Alternative 4 | |
|---|---|
| Error | 4.9 |
| Cost | 2120 |
| Alternative 5 | |
|---|---|
| Error | 4.6 |
| Cost | 2120 |
| Alternative 6 | |
|---|---|
| Error | 4.6 |
| Cost | 2120 |
| Alternative 7 | |
|---|---|
| Error | 4.6 |
| Cost | 2120 |
| Alternative 8 | |
|---|---|
| Error | 18.3 |
| Cost | 2000 |
| Alternative 9 | |
|---|---|
| Error | 18.6 |
| Cost | 2000 |
| Alternative 10 | |
|---|---|
| Error | 8.3 |
| Cost | 1996 |
| Alternative 11 | |
|---|---|
| Error | 9.8 |
| Cost | 1868 |
| Alternative 12 | |
|---|---|
| Error | 9.8 |
| Cost | 1868 |
| Alternative 13 | |
|---|---|
| Error | 44.3 |
| Cost | 1508 |
| Alternative 14 | |
|---|---|
| Error | 44.2 |
| Cost | 1508 |
| Alternative 15 | |
|---|---|
| Error | 33.7 |
| Cost | 1500 |
| Alternative 16 | |
|---|---|
| Error | 9.5 |
| Cost | 1476 |
| Alternative 17 | |
|---|---|
| Error | 45.0 |
| Cost | 1376 |
| Alternative 18 | |
|---|---|
| Error | 30.3 |
| Cost | 1368 |
| Alternative 19 | |
|---|---|
| Error | 30.2 |
| Cost | 1368 |
| Alternative 20 | |
|---|---|
| Error | 29.5 |
| Cost | 1236 |
| Alternative 21 | |
|---|---|
| Error | 29.8 |
| Cost | 1236 |
| Alternative 22 | |
|---|---|
| Error | 33.7 |
| Cost | 840 |
| Alternative 23 | |
|---|---|
| Error | 43.1 |
| Cost | 584 |
| Alternative 24 | |
|---|---|
| Error | 48.1 |
| Cost | 192 |
herbie shell --seed 2023075
(FPCore (x y z t a b c i j k)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, E"
:precision binary64
:herbie-target
(if (< t -1.6210815397541398e-69) (- (- (* (* 18.0 t) (* (* x y) z)) (* (+ (* a t) (* i x)) 4.0)) (- (* (* k j) 27.0) (* c b))) (if (< t 165.68027943805222) (+ (- (* (* 18.0 y) (* x (* z t))) (* (+ (* a t) (* i x)) 4.0)) (- (* c b) (* 27.0 (* k j)))) (- (- (* (* 18.0 t) (* (* x y) z)) (* (+ (* a t) (* i x)) 4.0)) (- (* (* k j) 27.0) (* c b)))))
(- (- (+ (- (* (* (* (* x 18.0) y) z) t) (* (* a 4.0) t)) (* b c)) (* (* x 4.0) i)) (* (* j 27.0) k)))