| Alternative 1 | |
|---|---|
| Accuracy | 91.3% |
| Cost | 5832 |
(FPCore (x y z t a b c i j) :precision binary64 (+ (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* i a)))) (* j (- (* c t) (* i y)))))
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (- (* a i) (* z c)))
(t_2 (* j (- (* t c) (* y i))))
(t_3 (- (* y z) (* t a)))
(t_4 (+ (+ (* x t_3) (* b t_1)) t_2)))
(if (<= t_4 (- INFINITY))
(+ (* t (- (* c j) (* x a))) (- (* y (- (* x z) (* i j))) (* z (* b c))))
(if (<= t_4 5e+307)
(fma x t_3 (fma b t_1 t_2))
(-
(+ t_2 (+ (* y (* x z)) (* a (- (* b i) (* x t)))))
(* c (* z b)))))))double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
return ((x * ((y * z) - (t * a))) - (b * ((c * z) - (i * a)))) + (j * ((c * t) - (i * y)));
}
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = (a * i) - (z * c);
double t_2 = j * ((t * c) - (y * i));
double t_3 = (y * z) - (t * a);
double t_4 = ((x * t_3) + (b * t_1)) + t_2;
double tmp;
if (t_4 <= -((double) INFINITY)) {
tmp = (t * ((c * j) - (x * a))) + ((y * ((x * z) - (i * j))) - (z * (b * c)));
} else if (t_4 <= 5e+307) {
tmp = fma(x, t_3, fma(b, t_1, t_2));
} else {
tmp = (t_2 + ((y * (x * z)) + (a * ((b * i) - (x * t))))) - (c * (z * b));
}
return tmp;
}
function code(x, y, z, t, a, b, c, i, j) return Float64(Float64(Float64(x * Float64(Float64(y * z) - Float64(t * a))) - Float64(b * Float64(Float64(c * z) - Float64(i * a)))) + Float64(j * Float64(Float64(c * t) - Float64(i * y)))) end
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(Float64(a * i) - Float64(z * c)) t_2 = Float64(j * Float64(Float64(t * c) - Float64(y * i))) t_3 = Float64(Float64(y * z) - Float64(t * a)) t_4 = Float64(Float64(Float64(x * t_3) + Float64(b * t_1)) + t_2) tmp = 0.0 if (t_4 <= Float64(-Inf)) tmp = Float64(Float64(t * Float64(Float64(c * j) - Float64(x * a))) + Float64(Float64(y * Float64(Float64(x * z) - Float64(i * j))) - Float64(z * Float64(b * c)))); elseif (t_4 <= 5e+307) tmp = fma(x, t_3, fma(b, t_1, t_2)); else tmp = Float64(Float64(t_2 + Float64(Float64(y * Float64(x * z)) + Float64(a * Float64(Float64(b * i) - Float64(x * t))))) - Float64(c * Float64(z * b))); end return tmp end
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := N[(N[(N[(x * N[(N[(y * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b * N[(N[(c * z), $MachinePrecision] - N[(i * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(j * N[(N[(c * t), $MachinePrecision] - N[(i * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(N[(a * i), $MachinePrecision] - N[(z * c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(j * N[(N[(t * c), $MachinePrecision] - N[(y * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(y * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[(x * t$95$3), $MachinePrecision] + N[(b * t$95$1), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]}, If[LessEqual[t$95$4, (-Infinity)], N[(N[(t * N[(N[(c * j), $MachinePrecision] - N[(x * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(y * N[(N[(x * z), $MachinePrecision] - N[(i * j), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z * N[(b * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 5e+307], N[(x * t$95$3 + N[(b * t$95$1 + t$95$2), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$2 + N[(N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(b * i), $MachinePrecision] - N[(x * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(c * N[(z * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\begin{array}{l}
t_1 := a \cdot i - z \cdot c\\
t_2 := j \cdot \left(t \cdot c - y \cdot i\right)\\
t_3 := y \cdot z - t \cdot a\\
t_4 := \left(x \cdot t_3 + b \cdot t_1\right) + t_2\\
\mathbf{if}\;t_4 \leq -\infty:\\
\;\;\;\;t \cdot \left(c \cdot j - x \cdot a\right) + \left(y \cdot \left(x \cdot z - i \cdot j\right) - z \cdot \left(b \cdot c\right)\right)\\
\mathbf{elif}\;t_4 \leq 5 \cdot 10^{+307}:\\
\;\;\;\;\mathsf{fma}\left(x, t_3, \mathsf{fma}\left(b, t_1, t_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(t_2 + \left(y \cdot \left(x \cdot z\right) + a \cdot \left(b \cdot i - x \cdot t\right)\right)\right) - c \cdot \left(z \cdot b\right)\\
\end{array}
| Original | 81.2% |
|---|---|
| Target | 75.2% |
| Herbie | 92.1% |
if (+.f64 (-.f64 (*.f64 x (-.f64 (*.f64 y z) (*.f64 t a))) (*.f64 b (-.f64 (*.f64 c z) (*.f64 i a)))) (*.f64 j (-.f64 (*.f64 c t) (*.f64 i y)))) < -inf.0Initial program 0.0%
Simplified0.0%
[Start]0.0 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
|---|---|
+-commutative [=>]0.0 | \[ \color{blue}{j \cdot \left(c \cdot t - i \cdot y\right) + \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right)}
\] |
fma-def [=>]0.0 | \[ \color{blue}{\mathsf{fma}\left(j, c \cdot t - i \cdot y, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right)}
\] |
*-commutative [=>]0.0 | \[ \mathsf{fma}\left(j, \color{blue}{t \cdot c} - i \cdot y, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right)
\] |
*-commutative [=>]0.0 | \[ \mathsf{fma}\left(j, t \cdot c - \color{blue}{y \cdot i}, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right)
\] |
*-commutative [=>]0.0 | \[ \mathsf{fma}\left(j, t \cdot c - y \cdot i, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(\color{blue}{z \cdot c} - i \cdot a\right)\right)
\] |
*-commutative [=>]0.0 | \[ \mathsf{fma}\left(j, t \cdot c - y \cdot i, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(z \cdot c - \color{blue}{a \cdot i}\right)\right)
\] |
Taylor expanded in y around -inf 56.2%
Simplified63.6%
[Start]56.2 | \[ \left(c \cdot \left(t \cdot j\right) + \left(-1 \cdot \left(a \cdot \left(t \cdot x\right)\right) + -1 \cdot \left(y \cdot \left(i \cdot j + -1 \cdot \left(z \cdot x\right)\right)\right)\right)\right) - \left(c \cdot z - i \cdot a\right) \cdot b
\] |
|---|---|
cancel-sign-sub-inv [=>]56.2 | \[ \color{blue}{\left(c \cdot \left(t \cdot j\right) + \left(-1 \cdot \left(a \cdot \left(t \cdot x\right)\right) + -1 \cdot \left(y \cdot \left(i \cdot j + -1 \cdot \left(z \cdot x\right)\right)\right)\right)\right) + \left(-\left(c \cdot z - i \cdot a\right)\right) \cdot b}
\] |
*-commutative [<=]56.2 | \[ \left(c \cdot \left(t \cdot j\right) + \left(-1 \cdot \left(a \cdot \left(t \cdot x\right)\right) + -1 \cdot \left(y \cdot \left(i \cdot j + -1 \cdot \left(z \cdot x\right)\right)\right)\right)\right) + \left(-\left(\color{blue}{z \cdot c} - i \cdot a\right)\right) \cdot b
\] |
*-commutative [=>]56.2 | \[ \left(c \cdot \left(t \cdot j\right) + \left(-1 \cdot \left(a \cdot \left(t \cdot x\right)\right) + -1 \cdot \left(y \cdot \left(i \cdot j + -1 \cdot \left(z \cdot x\right)\right)\right)\right)\right) + \left(-\left(z \cdot c - \color{blue}{a \cdot i}\right)\right) \cdot b
\] |
cancel-sign-sub-inv [<=]56.2 | \[ \color{blue}{\left(c \cdot \left(t \cdot j\right) + \left(-1 \cdot \left(a \cdot \left(t \cdot x\right)\right) + -1 \cdot \left(y \cdot \left(i \cdot j + -1 \cdot \left(z \cdot x\right)\right)\right)\right)\right) - \left(z \cdot c - a \cdot i\right) \cdot b}
\] |
*-commutative [<=]56.2 | \[ \left(c \cdot \left(t \cdot j\right) + \left(-1 \cdot \left(a \cdot \left(t \cdot x\right)\right) + -1 \cdot \left(y \cdot \left(i \cdot j + -1 \cdot \left(z \cdot x\right)\right)\right)\right)\right) - \color{blue}{b \cdot \left(z \cdot c - a \cdot i\right)}
\] |
Taylor expanded in c around inf 70.6%
Simplified70.9%
[Start]70.6 | \[ t \cdot \left(c \cdot j - a \cdot x\right) - \left(y \cdot \left(i \cdot j - z \cdot x\right) + c \cdot \left(z \cdot b\right)\right)
\] |
|---|---|
associate-*r* [=>]61.0 | \[ t \cdot \left(c \cdot j - a \cdot x\right) - \left(y \cdot \left(i \cdot j - z \cdot x\right) + \color{blue}{\left(c \cdot z\right) \cdot b}\right)
\] |
*-commutative [=>]61.0 | \[ t \cdot \left(c \cdot j - a \cdot x\right) - \left(y \cdot \left(i \cdot j - z \cdot x\right) + \color{blue}{\left(z \cdot c\right)} \cdot b\right)
\] |
associate-*l* [=>]70.9 | \[ t \cdot \left(c \cdot j - a \cdot x\right) - \left(y \cdot \left(i \cdot j - z \cdot x\right) + \color{blue}{z \cdot \left(c \cdot b\right)}\right)
\] |
if -inf.0 < (+.f64 (-.f64 (*.f64 x (-.f64 (*.f64 y z) (*.f64 t a))) (*.f64 b (-.f64 (*.f64 c z) (*.f64 i a)))) (*.f64 j (-.f64 (*.f64 c t) (*.f64 i y)))) < 5e307Initial program 98.7%
Simplified98.7%
[Start]98.7 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
|---|---|
associate-+l- [=>]98.7 | \[ \color{blue}{x \cdot \left(y \cdot z - t \cdot a\right) - \left(b \cdot \left(c \cdot z - i \cdot a\right) - j \cdot \left(c \cdot t - i \cdot y\right)\right)}
\] |
fma-neg [=>]98.7 | \[ \color{blue}{\mathsf{fma}\left(x, y \cdot z - t \cdot a, -\left(b \cdot \left(c \cdot z - i \cdot a\right) - j \cdot \left(c \cdot t - i \cdot y\right)\right)\right)}
\] |
neg-sub0 [=>]98.7 | \[ \mathsf{fma}\left(x, y \cdot z - t \cdot a, \color{blue}{0 - \left(b \cdot \left(c \cdot z - i \cdot a\right) - j \cdot \left(c \cdot t - i \cdot y\right)\right)}\right)
\] |
associate-+l- [<=]98.7 | \[ \mathsf{fma}\left(x, y \cdot z - t \cdot a, \color{blue}{\left(0 - b \cdot \left(c \cdot z - i \cdot a\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)}\right)
\] |
neg-sub0 [<=]98.7 | \[ \mathsf{fma}\left(x, y \cdot z - t \cdot a, \color{blue}{\left(-b \cdot \left(c \cdot z - i \cdot a\right)\right)} + j \cdot \left(c \cdot t - i \cdot y\right)\right)
\] |
distribute-rgt-neg-in [=>]98.7 | \[ \mathsf{fma}\left(x, y \cdot z - t \cdot a, \color{blue}{b \cdot \left(-\left(c \cdot z - i \cdot a\right)\right)} + j \cdot \left(c \cdot t - i \cdot y\right)\right)
\] |
fma-def [=>]98.7 | \[ \mathsf{fma}\left(x, y \cdot z - t \cdot a, \color{blue}{\mathsf{fma}\left(b, -\left(c \cdot z - i \cdot a\right), j \cdot \left(c \cdot t - i \cdot y\right)\right)}\right)
\] |
sub-neg [=>]98.7 | \[ \mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, -\color{blue}{\left(c \cdot z + \left(-i \cdot a\right)\right)}, j \cdot \left(c \cdot t - i \cdot y\right)\right)\right)
\] |
distribute-neg-in [=>]98.7 | \[ \mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, \color{blue}{\left(-c \cdot z\right) + \left(-\left(-i \cdot a\right)\right)}, j \cdot \left(c \cdot t - i \cdot y\right)\right)\right)
\] |
+-commutative [=>]98.7 | \[ \mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, \color{blue}{\left(-\left(-i \cdot a\right)\right) + \left(-c \cdot z\right)}, j \cdot \left(c \cdot t - i \cdot y\right)\right)\right)
\] |
remove-double-neg [=>]98.7 | \[ \mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, \color{blue}{i \cdot a} + \left(-c \cdot z\right), j \cdot \left(c \cdot t - i \cdot y\right)\right)\right)
\] |
sub-neg [<=]98.7 | \[ \mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, \color{blue}{i \cdot a - c \cdot z}, j \cdot \left(c \cdot t - i \cdot y\right)\right)\right)
\] |
*-commutative [=>]98.7 | \[ \mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, \color{blue}{a \cdot i} - c \cdot z, j \cdot \left(c \cdot t - i \cdot y\right)\right)\right)
\] |
*-commutative [=>]98.7 | \[ \mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, a \cdot i - \color{blue}{z \cdot c}, j \cdot \left(c \cdot t - i \cdot y\right)\right)\right)
\] |
if 5e307 < (+.f64 (-.f64 (*.f64 x (-.f64 (*.f64 y z) (*.f64 t a))) (*.f64 b (-.f64 (*.f64 c z) (*.f64 i a)))) (*.f64 j (-.f64 (*.f64 c t) (*.f64 i y)))) Initial program 0.5%
Simplified0.5%
[Start]0.5 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
|---|---|
+-commutative [=>]0.5 | \[ \color{blue}{j \cdot \left(c \cdot t - i \cdot y\right) + \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right)}
\] |
fma-def [=>]0.5 | \[ \color{blue}{\mathsf{fma}\left(j, c \cdot t - i \cdot y, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right)}
\] |
*-commutative [=>]0.5 | \[ \mathsf{fma}\left(j, \color{blue}{t \cdot c} - i \cdot y, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right)
\] |
*-commutative [=>]0.5 | \[ \mathsf{fma}\left(j, t \cdot c - \color{blue}{y \cdot i}, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right)
\] |
*-commutative [=>]0.5 | \[ \mathsf{fma}\left(j, t \cdot c - y \cdot i, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(\color{blue}{z \cdot c} - i \cdot a\right)\right)
\] |
*-commutative [=>]0.5 | \[ \mathsf{fma}\left(j, t \cdot c - y \cdot i, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(z \cdot c - \color{blue}{a \cdot i}\right)\right)
\] |
Taylor expanded in a around -inf 53.6%
Final simplification92.1%
| Alternative 1 | |
|---|---|
| Accuracy | 91.3% |
| Cost | 5832 |
| Alternative 2 | |
|---|---|
| Accuracy | 92.0% |
| Cost | 5832 |
| Alternative 3 | |
|---|---|
| Accuracy | 91.3% |
| Cost | 5704 |
| Alternative 4 | |
|---|---|
| Accuracy | 65.9% |
| Cost | 3184 |
| Alternative 5 | |
|---|---|
| Accuracy | 71.0% |
| Cost | 2920 |
| Alternative 6 | |
|---|---|
| Accuracy | 60.8% |
| Cost | 2668 |
| Alternative 7 | |
|---|---|
| Accuracy | 39.6% |
| Cost | 2557 |
| Alternative 8 | |
|---|---|
| Accuracy | 57.5% |
| Cost | 2536 |
| Alternative 9 | |
|---|---|
| Accuracy | 58.2% |
| Cost | 2536 |
| Alternative 10 | |
|---|---|
| Accuracy | 41.6% |
| Cost | 2424 |
| Alternative 11 | |
|---|---|
| Accuracy | 41.7% |
| Cost | 2424 |
| Alternative 12 | |
|---|---|
| Accuracy | 41.8% |
| Cost | 2424 |
| Alternative 13 | |
|---|---|
| Accuracy | 63.7% |
| Cost | 2401 |
| Alternative 14 | |
|---|---|
| Accuracy | 71.2% |
| Cost | 2392 |
| Alternative 15 | |
|---|---|
| Accuracy | 33.3% |
| Cost | 2292 |
| Alternative 16 | |
|---|---|
| Accuracy | 21.7% |
| Cost | 2100 |
| Alternative 17 | |
|---|---|
| Accuracy | 49.7% |
| Cost | 2016 |
| Alternative 18 | |
|---|---|
| Accuracy | 36.3% |
| Cost | 1896 |
| Alternative 19 | |
|---|---|
| Accuracy | 36.9% |
| Cost | 1896 |
| Alternative 20 | |
|---|---|
| Accuracy | 67.9% |
| Cost | 1876 |
| Alternative 21 | |
|---|---|
| Accuracy | 21.5% |
| Cost | 1640 |
| Alternative 22 | |
|---|---|
| Accuracy | 42.0% |
| Cost | 1501 |
| Alternative 23 | |
|---|---|
| Accuracy | 49.8% |
| Cost | 1488 |
| Alternative 24 | |
|---|---|
| Accuracy | 21.2% |
| Cost | 1376 |
| Alternative 25 | |
|---|---|
| Accuracy | 34.8% |
| Cost | 1236 |
| Alternative 26 | |
|---|---|
| Accuracy | 34.3% |
| Cost | 1104 |
| Alternative 27 | |
|---|---|
| Accuracy | 22.5% |
| Cost | 980 |
| Alternative 28 | |
|---|---|
| Accuracy | 22.4% |
| Cost | 980 |
| Alternative 29 | |
|---|---|
| Accuracy | 22.9% |
| Cost | 585 |
| Alternative 30 | |
|---|---|
| Accuracy | 22.9% |
| Cost | 585 |
| Alternative 31 | |
|---|---|
| Accuracy | 16.9% |
| Cost | 320 |
herbie shell --seed 2023133
(FPCore (x y z t a b c i j)
:name "Linear.Matrix:det33 from linear-1.19.1.3"
:precision binary64
:herbie-target
(if (< t -8.120978919195912e-33) (- (* x (- (* z y) (* a t))) (- (* b (- (* z c) (* a i))) (* (- (* c t) (* y i)) j))) (if (< t -4.712553818218485e-169) (+ (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* i a)))) (/ (* j (- (pow (* c t) 2.0) (pow (* i y) 2.0))) (+ (* c t) (* i y)))) (if (< t -7.633533346031584e-308) (- (* x (- (* z y) (* a t))) (- (* b (- (* z c) (* a i))) (* (- (* c t) (* y i)) j))) (if (< t 1.0535888557455487e-139) (+ (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* i a)))) (/ (* j (- (pow (* c t) 2.0) (pow (* i y) 2.0))) (+ (* c t) (* i y)))) (- (* x (- (* z y) (* a t))) (- (* b (- (* z c) (* a i))) (* (- (* c t) (* y i)) j)))))))
(+ (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* i a)))) (* j (- (* c t) (* i y)))))