| Alternative 1 | |
|---|---|
| Accuracy | 97.5% |
| Cost | 5320 |
(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 18.0) y) z) t) (* t (* a 4.0))) (* b c))
(* (* x 4.0) i))))
(if (<= t_1 (- INFINITY))
(-
(+ (* b c) (+ (* (* 18.0 (* y t)) (* x z)) (* -27.0 (* k j))))
(* 4.0 (* x i)))
(if (<= t_1 2e+307)
(- t_1 (* k (* j 27.0)))
(* x (fma (* y t) (* 18.0 z) (* i -4.0)))))))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 * 18.0) * y) * z) * t) - (t * (a * 4.0))) + (b * c)) - ((x * 4.0) * i);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = ((b * c) + (((18.0 * (y * t)) * (x * z)) + (-27.0 * (k * j)))) - (4.0 * (x * i));
} else if (t_1 <= 2e+307) {
tmp = t_1 - (k * (j * 27.0));
} else {
tmp = x * fma((y * t), (18.0 * z), (i * -4.0));
}
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(Float64(Float64(Float64(Float64(Float64(x * 18.0) * y) * z) * t) - Float64(t * Float64(a * 4.0))) + Float64(b * c)) - Float64(Float64(x * 4.0) * i)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(Float64(Float64(b * c) + Float64(Float64(Float64(18.0 * Float64(y * t)) * Float64(x * z)) + Float64(-27.0 * Float64(k * j)))) - Float64(4.0 * Float64(x * i))); elseif (t_1 <= 2e+307) tmp = Float64(t_1 - Float64(k * Float64(j * 27.0))); else tmp = Float64(x * fma(Float64(y * t), Float64(18.0 * z), Float64(i * -4.0))); end return 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[(N[(N[(N[(N[(N[(x * 18.0), $MachinePrecision] * y), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision] - N[(t * N[(a * 4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * c), $MachinePrecision]), $MachinePrecision] - N[(N[(x * 4.0), $MachinePrecision] * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(N[(N[(b * c), $MachinePrecision] + N[(N[(N[(18.0 * N[(y * t), $MachinePrecision]), $MachinePrecision] * N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(-27.0 * N[(k * j), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(4.0 * N[(x * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+307], N[(t$95$1 - N[(k * N[(j * 27.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(y * t), $MachinePrecision] * N[(18.0 * z), $MachinePrecision] + N[(i * -4.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\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 := \left(\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t - t \cdot \left(a \cdot 4\right)\right) + b \cdot c\right) - \left(x \cdot 4\right) \cdot i\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;\left(b \cdot c + \left(\left(18 \cdot \left(y \cdot t\right)\right) \cdot \left(x \cdot z\right) + -27 \cdot \left(k \cdot j\right)\right)\right) - 4 \cdot \left(x \cdot i\right)\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{+307}:\\
\;\;\;\;t_1 - k \cdot \left(j \cdot 27\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \mathsf{fma}\left(y \cdot t, 18 \cdot z, i \cdot -4\right)\\
\end{array}
| Original | 91.3% |
|---|---|
| Target | 97.4% |
| Herbie | 96.9% |
if (-.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)) < -inf.0Initial program 0.0%
Simplified34.0%
[Start]0.0 | \[ \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
\] |
|---|---|
sub-neg [=>]0.0 | \[ \color{blue}{\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(-\left(j \cdot 27\right) \cdot k\right)}
\] |
associate-+l- [=>]0.0 | \[ \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) + b \cdot c\right) - \left(\left(x \cdot 4\right) \cdot i - \left(-\left(j \cdot 27\right) \cdot k\right)\right)}
\] |
sub-neg [=>]0.0 | \[ \left(\color{blue}{\left(\left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z\right) \cdot t + \left(-\left(a \cdot 4\right) \cdot t\right)\right)} + b \cdot c\right) - \left(\left(x \cdot 4\right) \cdot i - \left(-\left(j \cdot 27\right) \cdot k\right)\right)
\] |
sub-neg [<=]0.0 | \[ \left(\color{blue}{\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(\left(x \cdot 4\right) \cdot i - \left(-\left(j \cdot 27\right) \cdot k\right)\right)
\] |
distribute-rgt-out-- [=>]0.0 | \[ \left(\color{blue}{t \cdot \left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z - a \cdot 4\right)} + b \cdot c\right) - \left(\left(x \cdot 4\right) \cdot i - \left(-\left(j \cdot 27\right) \cdot k\right)\right)
\] |
associate-*l* [=>]34.0 | \[ \left(t \cdot \left(\color{blue}{\left(x \cdot 18\right) \cdot \left(y \cdot z\right)} - a \cdot 4\right) + b \cdot c\right) - \left(\left(x \cdot 4\right) \cdot i - \left(-\left(j \cdot 27\right) \cdot k\right)\right)
\] |
distribute-lft-neg-in [=>]34.0 | \[ \left(t \cdot \left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right) - a \cdot 4\right) + b \cdot c\right) - \left(\left(x \cdot 4\right) \cdot i - \color{blue}{\left(-j \cdot 27\right) \cdot k}\right)
\] |
cancel-sign-sub [=>]34.0 | \[ \left(t \cdot \left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right) - a \cdot 4\right) + b \cdot c\right) - \color{blue}{\left(\left(x \cdot 4\right) \cdot i + \left(j \cdot 27\right) \cdot k\right)}
\] |
associate-*l* [=>]34.0 | \[ \left(t \cdot \left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right) - a \cdot 4\right) + b \cdot c\right) - \left(\color{blue}{x \cdot \left(4 \cdot i\right)} + \left(j \cdot 27\right) \cdot k\right)
\] |
associate-*l* [=>]34.0 | \[ \left(t \cdot \left(\left(x \cdot 18\right) \cdot \left(y \cdot z\right) - a \cdot 4\right) + b \cdot c\right) - \left(x \cdot \left(4 \cdot i\right) + \color{blue}{j \cdot \left(27 \cdot k\right)}\right)
\] |
Taylor expanded in j around 0 34.9%
Taylor expanded in y around inf 79.0%
Simplified76.4%
[Start]79.0 | \[ \left(c \cdot b + \left(18 \cdot \left(y \cdot \left(t \cdot \left(z \cdot x\right)\right)\right) + -27 \cdot \left(k \cdot j\right)\right)\right) - 4 \cdot \left(i \cdot x\right)
\] |
|---|---|
*-commutative [=>]79.0 | \[ \left(c \cdot b + \left(\color{blue}{\left(y \cdot \left(t \cdot \left(z \cdot x\right)\right)\right) \cdot 18} + -27 \cdot \left(k \cdot j\right)\right)\right) - 4 \cdot \left(i \cdot x\right)
\] |
associate-*r* [=>]76.4 | \[ \left(c \cdot b + \left(\color{blue}{\left(\left(y \cdot t\right) \cdot \left(z \cdot x\right)\right)} \cdot 18 + -27 \cdot \left(k \cdot j\right)\right)\right) - 4 \cdot \left(i \cdot x\right)
\] |
*-commutative [=>]76.4 | \[ \left(c \cdot b + \left(\left(\color{blue}{\left(t \cdot y\right)} \cdot \left(z \cdot x\right)\right) \cdot 18 + -27 \cdot \left(k \cdot j\right)\right)\right) - 4 \cdot \left(i \cdot x\right)
\] |
associate-*r* [<=]76.4 | \[ \left(c \cdot b + \left(\color{blue}{\left(t \cdot y\right) \cdot \left(\left(z \cdot x\right) \cdot 18\right)} + -27 \cdot \left(k \cdot j\right)\right)\right) - 4 \cdot \left(i \cdot x\right)
\] |
*-commutative [=>]76.4 | \[ \left(c \cdot b + \left(\left(t \cdot y\right) \cdot \color{blue}{\left(18 \cdot \left(z \cdot x\right)\right)} + -27 \cdot \left(k \cdot j\right)\right)\right) - 4 \cdot \left(i \cdot x\right)
\] |
associate-*r* [=>]76.4 | \[ \left(c \cdot b + \left(\color{blue}{\left(\left(t \cdot y\right) \cdot 18\right) \cdot \left(z \cdot x\right)} + -27 \cdot \left(k \cdot j\right)\right)\right) - 4 \cdot \left(i \cdot x\right)
\] |
if -inf.0 < (-.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)) < 1.99999999999999997e307Initial program 99.4%
if 1.99999999999999997e307 < (-.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)) Initial program 2.5%
Simplified39.1%
[Start]2.5 | \[ \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
\] |
|---|---|
associate--l- [=>]2.5 | \[ \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) + b \cdot c\right) - \left(\left(x \cdot 4\right) \cdot i + \left(j \cdot 27\right) \cdot k\right)}
\] |
associate--l+ [=>]2.5 | \[ \color{blue}{\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(b \cdot c - \left(\left(x \cdot 4\right) \cdot i + \left(j \cdot 27\right) \cdot k\right)\right)}
\] |
distribute-rgt-out-- [=>]2.5 | \[ \color{blue}{t \cdot \left(\left(\left(x \cdot 18\right) \cdot y\right) \cdot z - a \cdot 4\right)} + \left(b \cdot c - \left(\left(x \cdot 4\right) \cdot i + \left(j \cdot 27\right) \cdot k\right)\right)
\] |
fma-def [=>]2.5 | \[ \color{blue}{\mathsf{fma}\left(t, \left(\left(x \cdot 18\right) \cdot y\right) \cdot z - a \cdot 4, b \cdot c - \left(\left(x \cdot 4\right) \cdot i + \left(j \cdot 27\right) \cdot k\right)\right)}
\] |
associate-*l* [=>]37.9 | \[ \mathsf{fma}\left(t, \color{blue}{\left(x \cdot 18\right) \cdot \left(y \cdot z\right)} - a \cdot 4, b \cdot c - \left(\left(x \cdot 4\right) \cdot i + \left(j \cdot 27\right) \cdot k\right)\right)
\] |
associate-*l* [=>]39.1 | \[ \mathsf{fma}\left(t, \color{blue}{x \cdot \left(18 \cdot \left(y \cdot z\right)\right)} - a \cdot 4, b \cdot c - \left(\left(x \cdot 4\right) \cdot i + \left(j \cdot 27\right) \cdot k\right)\right)
\] |
fma-neg [=>]39.1 | \[ \mathsf{fma}\left(t, \color{blue}{\mathsf{fma}\left(x, 18 \cdot \left(y \cdot z\right), -a \cdot 4\right)}, b \cdot c - \left(\left(x \cdot 4\right) \cdot i + \left(j \cdot 27\right) \cdot k\right)\right)
\] |
distribute-rgt-neg-in [=>]39.1 | \[ \mathsf{fma}\left(t, \mathsf{fma}\left(x, 18 \cdot \left(y \cdot z\right), \color{blue}{a \cdot \left(-4\right)}\right), b \cdot c - \left(\left(x \cdot 4\right) \cdot i + \left(j \cdot 27\right) \cdot k\right)\right)
\] |
metadata-eval [=>]39.1 | \[ \mathsf{fma}\left(t, \mathsf{fma}\left(x, 18 \cdot \left(y \cdot z\right), a \cdot \color{blue}{-4}\right), b \cdot c - \left(\left(x \cdot 4\right) \cdot i + \left(j \cdot 27\right) \cdot k\right)\right)
\] |
fma-neg [=>]39.1 | \[ \mathsf{fma}\left(t, \mathsf{fma}\left(x, 18 \cdot \left(y \cdot z\right), a \cdot -4\right), \color{blue}{\mathsf{fma}\left(b, c, -\left(\left(x \cdot 4\right) \cdot i + \left(j \cdot 27\right) \cdot k\right)\right)}\right)
\] |
distribute-neg-in [=>]39.1 | \[ \mathsf{fma}\left(t, \mathsf{fma}\left(x, 18 \cdot \left(y \cdot z\right), a \cdot -4\right), \mathsf{fma}\left(b, c, \color{blue}{\left(-\left(x \cdot 4\right) \cdot i\right) + \left(-\left(j \cdot 27\right) \cdot k\right)}\right)\right)
\] |
associate-*l* [=>]39.1 | \[ \mathsf{fma}\left(t, \mathsf{fma}\left(x, 18 \cdot \left(y \cdot z\right), a \cdot -4\right), \mathsf{fma}\left(b, c, \left(-\color{blue}{x \cdot \left(4 \cdot i\right)}\right) + \left(-\left(j \cdot 27\right) \cdot k\right)\right)\right)
\] |
distribute-rgt-neg-in [=>]39.1 | \[ \mathsf{fma}\left(t, \mathsf{fma}\left(x, 18 \cdot \left(y \cdot z\right), a \cdot -4\right), \mathsf{fma}\left(b, c, \color{blue}{x \cdot \left(-4 \cdot i\right)} + \left(-\left(j \cdot 27\right) \cdot k\right)\right)\right)
\] |
fma-def [=>]39.1 | \[ \mathsf{fma}\left(t, \mathsf{fma}\left(x, 18 \cdot \left(y \cdot z\right), a \cdot -4\right), \mathsf{fma}\left(b, c, \color{blue}{\mathsf{fma}\left(x, -4 \cdot i, -\left(j \cdot 27\right) \cdot k\right)}\right)\right)
\] |
Taylor expanded in x around inf 64.0%
Simplified62.7%
[Start]64.0 | \[ \left(18 \cdot \left(y \cdot \left(t \cdot z\right)\right) + -4 \cdot i\right) \cdot x
\] |
|---|---|
*-commutative [=>]64.0 | \[ \color{blue}{x \cdot \left(18 \cdot \left(y \cdot \left(t \cdot z\right)\right) + -4 \cdot i\right)}
\] |
*-commutative [=>]64.0 | \[ x \cdot \left(\color{blue}{\left(y \cdot \left(t \cdot z\right)\right) \cdot 18} + -4 \cdot i\right)
\] |
associate-*r* [=>]62.8 | \[ x \cdot \left(\color{blue}{\left(\left(y \cdot t\right) \cdot z\right)} \cdot 18 + -4 \cdot i\right)
\] |
associate-*l* [=>]62.7 | \[ x \cdot \left(\color{blue}{\left(y \cdot t\right) \cdot \left(z \cdot 18\right)} + -4 \cdot i\right)
\] |
fma-def [=>]62.7 | \[ x \cdot \color{blue}{\mathsf{fma}\left(y \cdot t, z \cdot 18, -4 \cdot i\right)}
\] |
*-commutative [=>]62.7 | \[ x \cdot \mathsf{fma}\left(y \cdot t, \color{blue}{18 \cdot z}, -4 \cdot i\right)
\] |
Final simplification96.9%
| Alternative 1 | |
|---|---|
| Accuracy | 97.5% |
| Cost | 5320 |
| Alternative 2 | |
|---|---|
| Accuracy | 47.6% |
| Cost | 2552 |
| Alternative 3 | |
|---|---|
| Accuracy | 29.1% |
| Cost | 2293 |
| Alternative 4 | |
|---|---|
| Accuracy | 29.2% |
| Cost | 2293 |
| Alternative 5 | |
|---|---|
| Accuracy | 29.5% |
| Cost | 2293 |
| Alternative 6 | |
|---|---|
| Accuracy | 93.7% |
| Cost | 2121 |
| Alternative 7 | |
|---|---|
| Accuracy | 45.8% |
| Cost | 1896 |
| Alternative 8 | |
|---|---|
| Accuracy | 60.1% |
| Cost | 1885 |
| Alternative 9 | |
|---|---|
| Accuracy | 59.9% |
| Cost | 1885 |
| Alternative 10 | |
|---|---|
| Accuracy | 70.6% |
| Cost | 1885 |
| Alternative 11 | |
|---|---|
| Accuracy | 69.2% |
| Cost | 1884 |
| Alternative 12 | |
|---|---|
| Accuracy | 87.2% |
| Cost | 1864 |
| Alternative 13 | |
|---|---|
| Accuracy | 29.7% |
| Cost | 1772 |
| Alternative 14 | |
|---|---|
| Accuracy | 85.7% |
| Cost | 1736 |
| Alternative 15 | |
|---|---|
| Accuracy | 49.4% |
| Cost | 1628 |
| Alternative 16 | |
|---|---|
| Accuracy | 85.0% |
| Cost | 1609 |
| Alternative 17 | |
|---|---|
| Accuracy | 70.7% |
| Cost | 1488 |
| Alternative 18 | |
|---|---|
| Accuracy | 52.0% |
| Cost | 1364 |
| Alternative 19 | |
|---|---|
| Accuracy | 51.9% |
| Cost | 1364 |
| Alternative 20 | |
|---|---|
| Accuracy | 41.5% |
| Cost | 1236 |
| Alternative 21 | |
|---|---|
| Accuracy | 52.1% |
| Cost | 1233 |
| Alternative 22 | |
|---|---|
| Accuracy | 33.1% |
| Cost | 585 |
| Alternative 23 | |
|---|---|
| Accuracy | 33.1% |
| Cost | 584 |
| Alternative 24 | |
|---|---|
| Accuracy | 24.8% |
| Cost | 192 |
herbie shell --seed 2023147
(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)))