| Alternative 1 | |
|---|---|
| Accuracy | 93.1% |
| Cost | 12425 |
(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 (- t_2 (- (* x (- (* t a) (* y z))) (* b t_1)))))
(if (or (<= t_3 (- INFINITY)) (not (<= t_3 1e+300)))
(-
(* i (* a b))
(+
(+ (* t (fma (- j) c (* c j))) (* t (- (* x a) (* c j))))
(* y (- (* i j) (* x z)))))
(fma x (- (* y z) (* t a)) (fma b t_1 t_2)))))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 = t_2 - ((x * ((t * a) - (y * z))) - (b * t_1));
double tmp;
if ((t_3 <= -((double) INFINITY)) || !(t_3 <= 1e+300)) {
tmp = (i * (a * b)) - (((t * fma(-j, c, (c * j))) + (t * ((x * a) - (c * j)))) + (y * ((i * j) - (x * z))));
} else {
tmp = fma(x, ((y * z) - (t * a)), fma(b, t_1, t_2));
}
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(t_2 - Float64(Float64(x * Float64(Float64(t * a) - Float64(y * z))) - Float64(b * t_1))) tmp = 0.0 if ((t_3 <= Float64(-Inf)) || !(t_3 <= 1e+300)) tmp = Float64(Float64(i * Float64(a * b)) - Float64(Float64(Float64(t * fma(Float64(-j), c, Float64(c * j))) + Float64(t * Float64(Float64(x * a) - Float64(c * j)))) + Float64(y * Float64(Float64(i * j) - Float64(x * z))))); else tmp = fma(x, Float64(Float64(y * z) - Float64(t * a)), fma(b, t_1, t_2)); 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[(t$95$2 - N[(N[(x * N[(N[(t * a), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(b * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$3, (-Infinity)], N[Not[LessEqual[t$95$3, 1e+300]], $MachinePrecision]], N[(N[(i * N[(a * b), $MachinePrecision]), $MachinePrecision] - N[(N[(N[(t * N[((-j) * c + N[(c * j), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t * N[(N[(x * a), $MachinePrecision] - N[(c * j), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(y * N[(N[(i * j), $MachinePrecision] - N[(x * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(y * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(b * t$95$1 + t$95$2), $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 := t_2 - \left(x \cdot \left(t \cdot a - y \cdot z\right) - b \cdot t_1\right)\\
\mathbf{if}\;t_3 \leq -\infty \lor \neg \left(t_3 \leq 10^{+300}\right):\\
\;\;\;\;i \cdot \left(a \cdot b\right) - \left(\left(t \cdot \mathsf{fma}\left(-j, c, c \cdot j\right) + t \cdot \left(x \cdot a - c \cdot j\right)\right) + y \cdot \left(i \cdot j - x \cdot z\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, t_1, t_2\right)\right)\\
\end{array}
| Original | 81.1% |
|---|---|
| Target | 75.5% |
| Herbie | 93.2% |
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.0 or 1.0000000000000001e300 < (+.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 6.4%
Simplified6.4%
[Start]6.4 | \[ \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 [=>]6.4 | \[ \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 [=>]6.4 | \[ \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 [=>]6.4 | \[ \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 [=>]6.4 | \[ \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 [=>]6.4 | \[ \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 [=>]6.4 | \[ \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 t around -inf 59.8%
Simplified59.8%
[Start]59.8 | \[ \left(-1 \cdot \left(\left(a \cdot x + -1 \cdot \left(c \cdot j\right)\right) \cdot t\right) + \left(-1 \cdot \left(y \cdot \left(i \cdot j\right)\right) + y \cdot \left(z \cdot x\right)\right)\right) - \left(c \cdot z - i \cdot a\right) \cdot b
\] |
|---|---|
cancel-sign-sub-inv [=>]59.8 | \[ \color{blue}{\left(-1 \cdot \left(\left(a \cdot x + -1 \cdot \left(c \cdot j\right)\right) \cdot t\right) + \left(-1 \cdot \left(y \cdot \left(i \cdot j\right)\right) + y \cdot \left(z \cdot x\right)\right)\right) + \left(-\left(c \cdot z - i \cdot a\right)\right) \cdot b}
\] |
+-commutative [=>]59.8 | \[ \color{blue}{\left(\left(-1 \cdot \left(y \cdot \left(i \cdot j\right)\right) + y \cdot \left(z \cdot x\right)\right) + -1 \cdot \left(\left(a \cdot x + -1 \cdot \left(c \cdot j\right)\right) \cdot t\right)\right)} + \left(-\left(c \cdot z - i \cdot a\right)\right) \cdot b
\] |
mul-1-neg [=>]59.8 | \[ \left(\left(-1 \cdot \left(y \cdot \left(i \cdot j\right)\right) + y \cdot \left(z \cdot x\right)\right) + \color{blue}{\left(-\left(a \cdot x + -1 \cdot \left(c \cdot j\right)\right) \cdot t\right)}\right) + \left(-\left(c \cdot z - i \cdot a\right)\right) \cdot b
\] |
unsub-neg [=>]59.8 | \[ \color{blue}{\left(\left(-1 \cdot \left(y \cdot \left(i \cdot j\right)\right) + y \cdot \left(z \cdot x\right)\right) - \left(a \cdot x + -1 \cdot \left(c \cdot j\right)\right) \cdot t\right)} + \left(-\left(c \cdot z - i \cdot a\right)\right) \cdot b
\] |
Applied egg-rr59.8%
[Start]59.8 | \[ \left(y \cdot \left(z \cdot x - i \cdot j\right) - t \cdot \left(a \cdot x - c \cdot j\right)\right) + b \cdot \left(a \cdot i - c \cdot z\right)
\] |
|---|---|
prod-diff [=>]59.9 | \[ \left(y \cdot \left(z \cdot x - i \cdot j\right) - t \cdot \color{blue}{\left(\mathsf{fma}\left(a, x, -j \cdot c\right) + \mathsf{fma}\left(-j, c, j \cdot c\right)\right)}\right) + b \cdot \left(a \cdot i - c \cdot z\right)
\] |
*-commutative [<=]59.9 | \[ \left(y \cdot \left(z \cdot x - i \cdot j\right) - t \cdot \left(\mathsf{fma}\left(a, x, -\color{blue}{c \cdot j}\right) + \mathsf{fma}\left(-j, c, j \cdot c\right)\right)\right) + b \cdot \left(a \cdot i - c \cdot z\right)
\] |
fma-neg [<=]59.9 | \[ \left(y \cdot \left(z \cdot x - i \cdot j\right) - t \cdot \left(\color{blue}{\left(a \cdot x - c \cdot j\right)} + \mathsf{fma}\left(-j, c, j \cdot c\right)\right)\right) + b \cdot \left(a \cdot i - c \cdot z\right)
\] |
distribute-rgt-in [=>]59.8 | \[ \left(y \cdot \left(z \cdot x - i \cdot j\right) - \color{blue}{\left(\left(a \cdot x - c \cdot j\right) \cdot t + \mathsf{fma}\left(-j, c, j \cdot c\right) \cdot t\right)}\right) + b \cdot \left(a \cdot i - c \cdot z\right)
\] |
*-commutative [<=]59.8 | \[ \left(y \cdot \left(z \cdot x - i \cdot j\right) - \left(\color{blue}{t \cdot \left(a \cdot x - c \cdot j\right)} + \mathsf{fma}\left(-j, c, j \cdot c\right) \cdot t\right)\right) + b \cdot \left(a \cdot i - c \cdot z\right)
\] |
+-commutative [=>]59.8 | \[ \left(y \cdot \left(z \cdot x - i \cdot j\right) - \color{blue}{\left(\mathsf{fma}\left(-j, c, j \cdot c\right) \cdot t + t \cdot \left(a \cdot x - c \cdot j\right)\right)}\right) + b \cdot \left(a \cdot i - c \cdot z\right)
\] |
*-commutative [<=]59.8 | \[ \left(y \cdot \left(z \cdot x - i \cdot j\right) - \left(\mathsf{fma}\left(-j, c, \color{blue}{c \cdot j}\right) \cdot t + t \cdot \left(a \cdot x - c \cdot j\right)\right)\right) + b \cdot \left(a \cdot i - c \cdot z\right)
\] |
Taylor expanded in a around inf 69.6%
Simplified69.6%
[Start]69.6 | \[ \left(y \cdot \left(z \cdot x - i \cdot j\right) - \left(\mathsf{fma}\left(-j, c, c \cdot j\right) \cdot t + t \cdot \left(a \cdot x - c \cdot j\right)\right)\right) + i \cdot \left(a \cdot b\right)
\] |
|---|---|
*-commutative [=>]69.6 | \[ \left(y \cdot \left(z \cdot x - i \cdot j\right) - \left(\mathsf{fma}\left(-j, c, c \cdot j\right) \cdot t + t \cdot \left(a \cdot x - c \cdot j\right)\right)\right) + i \cdot \color{blue}{\left(b \cdot a\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)))) < 1.0000000000000001e300Initial 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)
\] |
Final simplification93.2%
| Alternative 1 | |
|---|---|
| Accuracy | 93.1% |
| Cost | 12425 |
| Alternative 2 | |
|---|---|
| Accuracy | 90.3% |
| Cost | 11977 |
| Alternative 3 | |
|---|---|
| Accuracy | 91.2% |
| Cost | 5833 |
| Alternative 4 | |
|---|---|
| Accuracy | 90.3% |
| Cost | 5833 |
| Alternative 5 | |
|---|---|
| Accuracy | 91.2% |
| Cost | 5705 |
| Alternative 6 | |
|---|---|
| Accuracy | 59.3% |
| Cost | 3324 |
| Alternative 7 | |
|---|---|
| Accuracy | 59.2% |
| Cost | 3324 |
| Alternative 8 | |
|---|---|
| Accuracy | 59.1% |
| Cost | 2796 |
| Alternative 9 | |
|---|---|
| Accuracy | 58.9% |
| Cost | 2796 |
| Alternative 10 | |
|---|---|
| Accuracy | 71.0% |
| Cost | 2788 |
| Alternative 11 | |
|---|---|
| Accuracy | 54.1% |
| Cost | 2544 |
| Alternative 12 | |
|---|---|
| Accuracy | 56.0% |
| Cost | 2544 |
| Alternative 13 | |
|---|---|
| Accuracy | 71.7% |
| Cost | 2524 |
| Alternative 14 | |
|---|---|
| Accuracy | 39.9% |
| Cost | 2425 |
| Alternative 15 | |
|---|---|
| Accuracy | 68.7% |
| Cost | 2404 |
| Alternative 16 | |
|---|---|
| Accuracy | 48.2% |
| Cost | 2016 |
| Alternative 17 | |
|---|---|
| Accuracy | 37.6% |
| Cost | 1897 |
| Alternative 18 | |
|---|---|
| Accuracy | 40.6% |
| Cost | 1896 |
| Alternative 19 | |
|---|---|
| Accuracy | 49.4% |
| Cost | 1884 |
| Alternative 20 | |
|---|---|
| Accuracy | 65.7% |
| Cost | 1876 |
| Alternative 21 | |
|---|---|
| Accuracy | 37.8% |
| Cost | 1764 |
| Alternative 22 | |
|---|---|
| Accuracy | 36.7% |
| Cost | 1368 |
| Alternative 23 | |
|---|---|
| Accuracy | 21.7% |
| Cost | 1308 |
| Alternative 24 | |
|---|---|
| Accuracy | 21.3% |
| Cost | 1308 |
| Alternative 25 | |
|---|---|
| Accuracy | 22.6% |
| Cost | 1308 |
| Alternative 26 | |
|---|---|
| Accuracy | 41.7% |
| Cost | 1236 |
| Alternative 27 | |
|---|---|
| Accuracy | 32.4% |
| Cost | 1104 |
| Alternative 28 | |
|---|---|
| Accuracy | 21.6% |
| Cost | 1044 |
| Alternative 29 | |
|---|---|
| Accuracy | 21.1% |
| Cost | 848 |
| Alternative 30 | |
|---|---|
| Accuracy | 20.4% |
| Cost | 848 |
| Alternative 31 | |
|---|---|
| Accuracy | 22.1% |
| Cost | 585 |
| Alternative 32 | |
|---|---|
| Accuracy | 16.5% |
| Cost | 320 |
| Alternative 33 | |
|---|---|
| Accuracy | 16.9% |
| Cost | 320 |
herbie shell --seed 2023138
(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)))))