| Alternative 1 | |
|---|---|
| Accuracy | 87.9% |
| Cost | 5833 |
(FPCore (x y z t a b c i j) :precision binary64 (+ (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* t i)))) (* j (- (* c a) (* y i)))))
(FPCore (x y z t a b c i j)
:precision binary64
(let* ((t_1 (* c (* a j)))
(t_2 (+ (* x (- (* y z) (* t a))) (* b (- (* t i) (* z c)))))
(t_3 (+ t_2 (* j (- (* a c) (* y i)))))
(t_4 (* c (* z b))))
(if (<= t_3 -1e+302)
(- (+ (- t_1 (* x (- (* t a) (* y z)))) (* i (- (* t b) (* y j)))) t_4)
(if (<= t_3 INFINITY)
(+ (- (* j (* a c)) (* j (* y i))) t_2)
(-
(-
(+ (* y (* x z)) t_1)
(+ (* i (- (* y j) (* t b))) (* i (fma (- b) t (* t b)))))
t_4)))))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) - (t * i)))) + (j * ((c * a) - (y * i)));
}
double code(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
double t_1 = c * (a * j);
double t_2 = (x * ((y * z) - (t * a))) + (b * ((t * i) - (z * c)));
double t_3 = t_2 + (j * ((a * c) - (y * i)));
double t_4 = c * (z * b);
double tmp;
if (t_3 <= -1e+302) {
tmp = ((t_1 - (x * ((t * a) - (y * z)))) + (i * ((t * b) - (y * j)))) - t_4;
} else if (t_3 <= ((double) INFINITY)) {
tmp = ((j * (a * c)) - (j * (y * i))) + t_2;
} else {
tmp = (((y * (x * z)) + t_1) - ((i * ((y * j) - (t * b))) + (i * fma(-b, t, (t * b))))) - t_4;
}
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(t * i)))) + Float64(j * Float64(Float64(c * a) - Float64(y * i)))) end
function code(x, y, z, t, a, b, c, i, j) t_1 = Float64(c * Float64(a * j)) t_2 = Float64(Float64(x * Float64(Float64(y * z) - Float64(t * a))) + Float64(b * Float64(Float64(t * i) - Float64(z * c)))) t_3 = Float64(t_2 + Float64(j * Float64(Float64(a * c) - Float64(y * i)))) t_4 = Float64(c * Float64(z * b)) tmp = 0.0 if (t_3 <= -1e+302) tmp = Float64(Float64(Float64(t_1 - Float64(x * Float64(Float64(t * a) - Float64(y * z)))) + Float64(i * Float64(Float64(t * b) - Float64(y * j)))) - t_4); elseif (t_3 <= Inf) tmp = Float64(Float64(Float64(j * Float64(a * c)) - Float64(j * Float64(y * i))) + t_2); else tmp = Float64(Float64(Float64(Float64(y * Float64(x * z)) + t_1) - Float64(Float64(i * Float64(Float64(y * j) - Float64(t * b))) + Float64(i * fma(Float64(-b), t, Float64(t * b))))) - t_4); 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[(t * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(j * N[(N[(c * a), $MachinePrecision] - N[(y * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_, c_, i_, j_] := Block[{t$95$1 = N[(c * N[(a * j), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(x * N[(N[(y * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * N[(N[(t * i), $MachinePrecision] - N[(z * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 + N[(j * N[(N[(a * c), $MachinePrecision] - N[(y * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(c * N[(z * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -1e+302], N[(N[(N[(t$95$1 - N[(x * N[(N[(t * a), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(i * N[(N[(t * b), $MachinePrecision] - N[(y * j), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$4), $MachinePrecision], If[LessEqual[t$95$3, Infinity], N[(N[(N[(j * N[(a * c), $MachinePrecision]), $MachinePrecision] - N[(j * N[(y * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision], N[(N[(N[(N[(y * N[(x * z), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision] - N[(N[(i * N[(N[(y * j), $MachinePrecision] - N[(t * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(i * N[((-b) * t + N[(t * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$4), $MachinePrecision]]]]]]]
\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right)
\begin{array}{l}
t_1 := c \cdot \left(a \cdot j\right)\\
t_2 := x \cdot \left(y \cdot z - t \cdot a\right) + b \cdot \left(t \cdot i - z \cdot c\right)\\
t_3 := t_2 + j \cdot \left(a \cdot c - y \cdot i\right)\\
t_4 := c \cdot \left(z \cdot b\right)\\
\mathbf{if}\;t_3 \leq -1 \cdot 10^{+302}:\\
\;\;\;\;\left(\left(t_1 - x \cdot \left(t \cdot a - y \cdot z\right)\right) + i \cdot \left(t \cdot b - y \cdot j\right)\right) - t_4\\
\mathbf{elif}\;t_3 \leq \infty:\\
\;\;\;\;\left(j \cdot \left(a \cdot c\right) - j \cdot \left(y \cdot i\right)\right) + t_2\\
\mathbf{else}:\\
\;\;\;\;\left(\left(y \cdot \left(x \cdot z\right) + t_1\right) - \left(i \cdot \left(y \cdot j - t \cdot b\right) + i \cdot \mathsf{fma}\left(-b, t, t \cdot b\right)\right)\right) - t_4\\
\end{array}
| Original | 80.9% |
|---|---|
| Target | 69.0% |
| Herbie | 87.2% |
if (+.f64 (-.f64 (*.f64 x (-.f64 (*.f64 y z) (*.f64 t a))) (*.f64 b (-.f64 (*.f64 c z) (*.f64 t i)))) (*.f64 j (-.f64 (*.f64 c a) (*.f64 y i)))) < -1.0000000000000001e302Initial program 7.9%
Simplified7.9%
[Start]7.9 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right)
\] |
|---|---|
+-commutative [=>]7.9 | \[ \color{blue}{j \cdot \left(c \cdot a - y \cdot i\right) + \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right)}
\] |
fma-def [=>]7.9 | \[ \color{blue}{\mathsf{fma}\left(j, c \cdot a - y \cdot i, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right)}
\] |
*-commutative [=>]7.9 | \[ \mathsf{fma}\left(j, \color{blue}{a \cdot c} - y \cdot i, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right)
\] |
*-commutative [=>]7.9 | \[ \mathsf{fma}\left(j, a \cdot c - y \cdot i, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(\color{blue}{z \cdot c} - t \cdot i\right)\right)
\] |
Taylor expanded in i around -inf 64.0%
if -1.0000000000000001e302 < (+.f64 (-.f64 (*.f64 x (-.f64 (*.f64 y z) (*.f64 t a))) (*.f64 b (-.f64 (*.f64 c z) (*.f64 t i)))) (*.f64 j (-.f64 (*.f64 c a) (*.f64 y i)))) < +inf.0Initial program 89.9%
Simplified89.9%
[Start]89.9 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right)
\] |
|---|---|
sub-neg [=>]89.9 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \color{blue}{\left(c \cdot a + \left(-y \cdot i\right)\right)}
\] |
distribute-rgt-in [=>]89.9 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + \color{blue}{\left(\left(c \cdot a\right) \cdot j + \left(-y \cdot i\right) \cdot j\right)}
\] |
associate-+r+ [=>]89.9 | \[ \color{blue}{\left(\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + \left(c \cdot a\right) \cdot j\right) + \left(-y \cdot i\right) \cdot j}
\] |
*-commutative [=>]89.9 | \[ \left(\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + \left(c \cdot a\right) \cdot j\right) + \color{blue}{j \cdot \left(-y \cdot i\right)}
\] |
cancel-sign-sub [<=]89.9 | \[ \color{blue}{\left(\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + \left(c \cdot a\right) \cdot j\right) - \left(-j\right) \cdot \left(-y \cdot i\right)}
\] |
associate-+r- [<=]89.9 | \[ \color{blue}{\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + \left(\left(c \cdot a\right) \cdot j - \left(-j\right) \cdot \left(-y \cdot i\right)\right)}
\] |
*-commutative [=>]89.9 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(\color{blue}{z \cdot c} - t \cdot i\right)\right) + \left(\left(c \cdot a\right) \cdot j - \left(-j\right) \cdot \left(-y \cdot i\right)\right)
\] |
cancel-sign-sub [=>]89.9 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(z \cdot c - t \cdot i\right)\right) + \color{blue}{\left(\left(c \cdot a\right) \cdot j + j \cdot \left(-y \cdot i\right)\right)}
\] |
*-commutative [<=]89.9 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(z \cdot c - t \cdot i\right)\right) + \left(\left(c \cdot a\right) \cdot j + \color{blue}{\left(-y \cdot i\right) \cdot j}\right)
\] |
distribute-rgt-in [<=]89.9 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(z \cdot c - t \cdot i\right)\right) + \color{blue}{j \cdot \left(c \cdot a + \left(-y \cdot i\right)\right)}
\] |
Applied egg-rr89.9%
[Start]89.9 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(z \cdot c - t \cdot i\right)\right) + j \cdot \left(a \cdot c - y \cdot i\right)
\] |
|---|---|
sub-neg [=>]89.9 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(z \cdot c - t \cdot i\right)\right) + j \cdot \color{blue}{\left(a \cdot c + \left(-y \cdot i\right)\right)}
\] |
distribute-rgt-in [=>]89.9 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(z \cdot c - t \cdot i\right)\right) + \color{blue}{\left(\left(a \cdot c\right) \cdot j + \left(-y \cdot i\right) \cdot j\right)}
\] |
+-commutative [=>]89.9 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(z \cdot c - t \cdot i\right)\right) + \color{blue}{\left(\left(-y \cdot i\right) \cdot j + \left(a \cdot c\right) \cdot j\right)}
\] |
distribute-rgt-neg-in [=>]89.9 | \[ \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(z \cdot c - t \cdot i\right)\right) + \left(\color{blue}{\left(y \cdot \left(-i\right)\right)} \cdot j + \left(a \cdot c\right) \cdot j\right)
\] |
if +inf.0 < (+.f64 (-.f64 (*.f64 x (-.f64 (*.f64 y z) (*.f64 t a))) (*.f64 b (-.f64 (*.f64 c z) (*.f64 t i)))) (*.f64 j (-.f64 (*.f64 c a) (*.f64 y i)))) Initial 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 - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right)
\] |
|---|---|
+-commutative [=>]0.0 | \[ \color{blue}{j \cdot \left(c \cdot a - y \cdot i\right) + \left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right)}
\] |
fma-def [=>]0.0 | \[ \color{blue}{\mathsf{fma}\left(j, c \cdot a - y \cdot i, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right)}
\] |
*-commutative [=>]0.0 | \[ \mathsf{fma}\left(j, \color{blue}{a \cdot c} - y \cdot i, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right)
\] |
*-commutative [=>]0.0 | \[ \mathsf{fma}\left(j, a \cdot c - y \cdot i, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(\color{blue}{z \cdot c} - t \cdot i\right)\right)
\] |
Taylor expanded in i around -inf 33.4%
Taylor expanded in y around inf 69.9%
Applied egg-rr70.0%
[Start]69.9 | \[ \left(-1 \cdot \left(i \cdot \left(y \cdot j - t \cdot b\right)\right) + \left(y \cdot \left(z \cdot x\right) + c \cdot \left(a \cdot j\right)\right)\right) - c \cdot \left(b \cdot z\right)
\] |
|---|---|
prod-diff [=>]70.0 | \[ \left(-1 \cdot \left(i \cdot \color{blue}{\left(\mathsf{fma}\left(y, j, -b \cdot t\right) + \mathsf{fma}\left(-b, t, b \cdot t\right)\right)}\right) + \left(y \cdot \left(z \cdot x\right) + c \cdot \left(a \cdot j\right)\right)\right) - c \cdot \left(b \cdot z\right)
\] |
*-commutative [<=]70.0 | \[ \left(-1 \cdot \left(i \cdot \left(\mathsf{fma}\left(y, j, -\color{blue}{t \cdot b}\right) + \mathsf{fma}\left(-b, t, b \cdot t\right)\right)\right) + \left(y \cdot \left(z \cdot x\right) + c \cdot \left(a \cdot j\right)\right)\right) - c \cdot \left(b \cdot z\right)
\] |
fma-neg [<=]69.9 | \[ \left(-1 \cdot \left(i \cdot \left(\color{blue}{\left(y \cdot j - t \cdot b\right)} + \mathsf{fma}\left(-b, t, b \cdot t\right)\right)\right) + \left(y \cdot \left(z \cdot x\right) + c \cdot \left(a \cdot j\right)\right)\right) - c \cdot \left(b \cdot z\right)
\] |
distribute-rgt-in [=>]70.0 | \[ \left(-1 \cdot \color{blue}{\left(\left(y \cdot j - t \cdot b\right) \cdot i + \mathsf{fma}\left(-b, t, b \cdot t\right) \cdot i\right)} + \left(y \cdot \left(z \cdot x\right) + c \cdot \left(a \cdot j\right)\right)\right) - c \cdot \left(b \cdot z\right)
\] |
*-commutative [<=]70.0 | \[ \left(-1 \cdot \left(\color{blue}{i \cdot \left(y \cdot j - t \cdot b\right)} + \mathsf{fma}\left(-b, t, b \cdot t\right) \cdot i\right) + \left(y \cdot \left(z \cdot x\right) + c \cdot \left(a \cdot j\right)\right)\right) - c \cdot \left(b \cdot z\right)
\] |
+-commutative [=>]70.0 | \[ \left(-1 \cdot \color{blue}{\left(\mathsf{fma}\left(-b, t, b \cdot t\right) \cdot i + i \cdot \left(y \cdot j - t \cdot b\right)\right)} + \left(y \cdot \left(z \cdot x\right) + c \cdot \left(a \cdot j\right)\right)\right) - c \cdot \left(b \cdot z\right)
\] |
*-commutative [<=]70.0 | \[ \left(-1 \cdot \left(\mathsf{fma}\left(-b, t, \color{blue}{t \cdot b}\right) \cdot i + i \cdot \left(y \cdot j - t \cdot b\right)\right) + \left(y \cdot \left(z \cdot x\right) + c \cdot \left(a \cdot j\right)\right)\right) - c \cdot \left(b \cdot z\right)
\] |
Final simplification87.2%
| Alternative 1 | |
|---|---|
| Accuracy | 87.9% |
| Cost | 5833 |
| Alternative 2 | |
|---|---|
| Accuracy | 87.2% |
| Cost | 5832 |
| Alternative 3 | |
|---|---|
| Accuracy | 86.5% |
| Cost | 5705 |
| Alternative 4 | |
|---|---|
| Accuracy | 87.9% |
| Cost | 5705 |
| Alternative 5 | |
|---|---|
| Accuracy | 47.9% |
| Cost | 2809 |
| Alternative 6 | |
|---|---|
| Accuracy | 68.5% |
| Cost | 2652 |
| Alternative 7 | |
|---|---|
| Accuracy | 64.1% |
| Cost | 2404 |
| Alternative 8 | |
|---|---|
| Accuracy | 52.8% |
| Cost | 2272 |
| Alternative 9 | |
|---|---|
| Accuracy | 65.1% |
| Cost | 2272 |
| Alternative 10 | |
|---|---|
| Accuracy | 39.6% |
| Cost | 2160 |
| Alternative 11 | |
|---|---|
| Accuracy | 41.1% |
| Cost | 2160 |
| Alternative 12 | |
|---|---|
| Accuracy | 41.1% |
| Cost | 2160 |
| Alternative 13 | |
|---|---|
| Accuracy | 44.4% |
| Cost | 2148 |
| Alternative 14 | |
|---|---|
| Accuracy | 63.3% |
| Cost | 2140 |
| Alternative 15 | |
|---|---|
| Accuracy | 63.5% |
| Cost | 2140 |
| Alternative 16 | |
|---|---|
| Accuracy | 61.7% |
| Cost | 2008 |
| Alternative 17 | |
|---|---|
| Accuracy | 41.3% |
| Cost | 1764 |
| Alternative 18 | |
|---|---|
| Accuracy | 41.9% |
| Cost | 1764 |
| Alternative 19 | |
|---|---|
| Accuracy | 41.5% |
| Cost | 1764 |
| Alternative 20 | |
|---|---|
| Accuracy | 30.0% |
| Cost | 1500 |
| Alternative 21 | |
|---|---|
| Accuracy | 39.7% |
| Cost | 1500 |
| Alternative 22 | |
|---|---|
| Accuracy | 20.6% |
| Cost | 1308 |
| Alternative 23 | |
|---|---|
| Accuracy | 38.1% |
| Cost | 1236 |
| Alternative 24 | |
|---|---|
| Accuracy | 36.0% |
| Cost | 1104 |
| Alternative 25 | |
|---|---|
| Accuracy | 21.2% |
| Cost | 1044 |
| Alternative 26 | |
|---|---|
| Accuracy | 21.4% |
| Cost | 1044 |
| Alternative 27 | |
|---|---|
| Accuracy | 21.8% |
| Cost | 912 |
| Alternative 28 | |
|---|---|
| Accuracy | 19.8% |
| Cost | 649 |
| Alternative 29 | |
|---|---|
| Accuracy | 16.8% |
| Cost | 585 |
| Alternative 30 | |
|---|---|
| Accuracy | 17.1% |
| Cost | 452 |
| Alternative 31 | |
|---|---|
| Accuracy | 16.2% |
| Cost | 320 |
herbie shell --seed 2023130
(FPCore (x y z t a b c i j)
:name "Data.Colour.Matrix:determinant from colour-2.3.3, A"
:precision binary64
:herbie-target
(if (< x -1.469694296777705e-64) (+ (- (* x (- (* y z) (* t a))) (/ (* b (- (pow (* c z) 2.0) (pow (* t i) 2.0))) (+ (* c z) (* t i)))) (* j (- (* c a) (* y i)))) (if (< x 3.2113527362226803e-147) (- (* (- (* b i) (* x a)) t) (- (* z (* c b)) (* j (- (* c a) (* y i))))) (+ (- (* x (- (* y z) (* t a))) (/ (* b (- (pow (* c z) 2.0) (pow (* t i) 2.0))) (+ (* c z) (* t i)))) (* j (- (* c a) (* y i))))))
(+ (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* t i)))) (* j (- (* c a) (* y i)))))