| Alternative 1 | |
|---|---|
| Error | 7.7 |
| Cost | 11976 |
(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 (* j (- (* t c) (* y i))))
(t_2 (- t_1 (+ (* b (- (* z c) (* a i))) (* x (- (* t a) (* y z)))))))
(if (<= t_2 (- INFINITY))
(* i (- (* a b) (* y j)))
(if (<= t_2 2e+305)
(+
t_1
(+
(+ (* x (- (* y z) (* t a))) (* x (fma (- a) t (* t a))))
(* b (- (* a i) (* z c)))))
(+ t_1 (- (* z (- (* x y) (* b c))) (* t (* x a))))))))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 = j * ((t * c) - (y * i));
double t_2 = t_1 - ((b * ((z * c) - (a * i))) + (x * ((t * a) - (y * z))));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = i * ((a * b) - (y * j));
} else if (t_2 <= 2e+305) {
tmp = t_1 + (((x * ((y * z) - (t * a))) + (x * fma(-a, t, (t * a)))) + (b * ((a * i) - (z * c))));
} else {
tmp = t_1 + ((z * ((x * y) - (b * c))) - (t * (x * a)));
}
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(j * Float64(Float64(t * c) - Float64(y * i))) t_2 = Float64(t_1 - Float64(Float64(b * Float64(Float64(z * c) - Float64(a * i))) + Float64(x * Float64(Float64(t * a) - Float64(y * z))))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(i * Float64(Float64(a * b) - Float64(y * j))); elseif (t_2 <= 2e+305) tmp = Float64(t_1 + Float64(Float64(Float64(x * Float64(Float64(y * z) - Float64(t * a))) + Float64(x * fma(Float64(-a), t, Float64(t * a)))) + Float64(b * Float64(Float64(a * i) - Float64(z * c))))); else tmp = Float64(t_1 + Float64(Float64(z * Float64(Float64(x * y) - Float64(b * c))) - Float64(t * Float64(x * a)))); 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[(j * N[(N[(t * c), $MachinePrecision] - N[(y * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - N[(N[(b * N[(N[(z * c), $MachinePrecision] - N[(a * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(N[(t * a), $MachinePrecision] - N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(i * N[(N[(a * b), $MachinePrecision] - N[(y * j), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+305], N[(t$95$1 + N[(N[(N[(x * N[(N[(y * z), $MachinePrecision] - N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[((-a) * t + N[(t * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(b * N[(N[(a * i), $MachinePrecision] - N[(z * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(N[(z * N[(N[(x * y), $MachinePrecision] - N[(b * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(t * N[(x * a), $MachinePrecision]), $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 := j \cdot \left(t \cdot c - y \cdot i\right)\\
t_2 := t_1 - \left(b \cdot \left(z \cdot c - a \cdot i\right) + x \cdot \left(t \cdot a - y \cdot z\right)\right)\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;i \cdot \left(a \cdot b - y \cdot j\right)\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+305}:\\
\;\;\;\;t_1 + \left(\left(x \cdot \left(y \cdot z - t \cdot a\right) + x \cdot \mathsf{fma}\left(-a, t, t \cdot a\right)\right) + b \cdot \left(a \cdot i - z \cdot c\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t_1 + \left(z \cdot \left(x \cdot y - b \cdot c\right) - t \cdot \left(x \cdot a\right)\right)\\
\end{array}
| Original | 12.1 |
|---|---|
| Target | 15.7 |
| Herbie | 7.7 |
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 64.0
Simplified64.0
[Start]64.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 [=>]64.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 [=>]64.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 [=>]64.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 [=>]64.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 [=>]64.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 [=>]64.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 i around inf 43.3
Simplified43.3
[Start]43.3 | \[ \left(-1 \cdot \left(y \cdot j\right) - -1 \cdot \left(a \cdot b\right)\right) \cdot i
\] |
|---|---|
*-commutative [=>]43.3 | \[ \color{blue}{i \cdot \left(-1 \cdot \left(y \cdot j\right) - -1 \cdot \left(a \cdot b\right)\right)}
\] |
associate-*r* [=>]43.3 | \[ i \cdot \left(\color{blue}{\left(-1 \cdot y\right) \cdot j} - -1 \cdot \left(a \cdot b\right)\right)
\] |
fma-neg [=>]43.3 | \[ i \cdot \color{blue}{\mathsf{fma}\left(-1 \cdot y, j, --1 \cdot \left(a \cdot b\right)\right)}
\] |
mul-1-neg [=>]43.3 | \[ i \cdot \mathsf{fma}\left(-1 \cdot y, j, -\color{blue}{\left(-a \cdot b\right)}\right)
\] |
remove-double-neg [=>]43.3 | \[ i \cdot \mathsf{fma}\left(-1 \cdot y, j, \color{blue}{a \cdot b}\right)
\] |
mul-1-neg [=>]43.3 | \[ i \cdot \mathsf{fma}\left(\color{blue}{-y}, j, a \cdot b\right)
\] |
*-commutative [=>]43.3 | \[ i \cdot \mathsf{fma}\left(-y, j, \color{blue}{b \cdot a}\right)
\] |
Applied egg-rr43.3
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.9999999999999999e305Initial program 0.8
Applied egg-rr0.8
if 1.9999999999999999e305 < (+.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 61.8
Taylor expanded in i around 0 50.2
Simplified35.3
[Start]50.2 | \[ \left(\left(y \cdot z - a \cdot t\right) \cdot x - c \cdot \left(z \cdot b\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
|---|---|
sub-neg [=>]50.2 | \[ \color{blue}{\left(\left(y \cdot z - a \cdot t\right) \cdot x + \left(-c \cdot \left(z \cdot b\right)\right)\right)} + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
mul-1-neg [<=]50.2 | \[ \left(\left(y \cdot z - a \cdot t\right) \cdot x + \color{blue}{-1 \cdot \left(c \cdot \left(z \cdot b\right)\right)}\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
+-commutative [=>]50.2 | \[ \color{blue}{\left(-1 \cdot \left(c \cdot \left(z \cdot b\right)\right) + \left(y \cdot z - a \cdot t\right) \cdot x\right)} + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
*-commutative [=>]50.2 | \[ \left(-1 \cdot \left(c \cdot \left(z \cdot b\right)\right) + \color{blue}{x \cdot \left(y \cdot z - a \cdot t\right)}\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
cancel-sign-sub-inv [=>]50.2 | \[ \left(-1 \cdot \left(c \cdot \left(z \cdot b\right)\right) + x \cdot \color{blue}{\left(y \cdot z + \left(-a\right) \cdot t\right)}\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
*-commutative [<=]50.2 | \[ \left(-1 \cdot \left(c \cdot \left(z \cdot b\right)\right) + x \cdot \left(y \cdot z + \color{blue}{t \cdot \left(-a\right)}\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
distribute-lft-out [<=]50.2 | \[ \left(-1 \cdot \left(c \cdot \left(z \cdot b\right)\right) + \color{blue}{\left(x \cdot \left(y \cdot z\right) + x \cdot \left(t \cdot \left(-a\right)\right)\right)}\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
associate-*r* [=>]44.8 | \[ \left(-1 \cdot \left(c \cdot \left(z \cdot b\right)\right) + \left(x \cdot \left(y \cdot z\right) + \color{blue}{\left(x \cdot t\right) \cdot \left(-a\right)}\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
*-commutative [<=]44.8 | \[ \left(-1 \cdot \left(c \cdot \left(z \cdot b\right)\right) + \left(x \cdot \left(y \cdot z\right) + \color{blue}{\left(t \cdot x\right)} \cdot \left(-a\right)\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
*-commutative [=>]44.8 | \[ \left(-1 \cdot \left(c \cdot \left(z \cdot b\right)\right) + \left(x \cdot \left(y \cdot z\right) + \color{blue}{\left(-a\right) \cdot \left(t \cdot x\right)}\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
neg-mul-1 [=>]44.8 | \[ \left(-1 \cdot \left(c \cdot \left(z \cdot b\right)\right) + \left(x \cdot \left(y \cdot z\right) + \color{blue}{\left(-1 \cdot a\right)} \cdot \left(t \cdot x\right)\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
associate-*r* [<=]44.8 | \[ \left(-1 \cdot \left(c \cdot \left(z \cdot b\right)\right) + \left(x \cdot \left(y \cdot z\right) + \color{blue}{-1 \cdot \left(a \cdot \left(t \cdot x\right)\right)}\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
*-commutative [<=]44.8 | \[ \left(-1 \cdot \left(c \cdot \left(z \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z\right) \cdot x} + -1 \cdot \left(a \cdot \left(t \cdot x\right)\right)\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
associate-*r* [<=]37.2 | \[ \left(-1 \cdot \left(c \cdot \left(z \cdot b\right)\right) + \left(\color{blue}{y \cdot \left(z \cdot x\right)} + -1 \cdot \left(a \cdot \left(t \cdot x\right)\right)\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
mul-1-neg [=>]37.2 | \[ \left(-1 \cdot \left(c \cdot \left(z \cdot b\right)\right) + \left(y \cdot \left(z \cdot x\right) + \color{blue}{\left(-a \cdot \left(t \cdot x\right)\right)}\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
unsub-neg [=>]37.2 | \[ \left(-1 \cdot \left(c \cdot \left(z \cdot b\right)\right) + \color{blue}{\left(y \cdot \left(z \cdot x\right) - a \cdot \left(t \cdot x\right)\right)}\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\] |
Final simplification7.7
| Alternative 1 | |
|---|---|
| Error | 7.7 |
| Cost | 11976 |
| Alternative 2 | |
|---|---|
| Error | 7.7 |
| Cost | 5704 |
| Alternative 3 | |
|---|---|
| Error | 29.3 |
| Cost | 3196 |
| Alternative 4 | |
|---|---|
| Error | 37.7 |
| Cost | 2941 |
| Alternative 5 | |
|---|---|
| Error | 20.2 |
| Cost | 2788 |
| Alternative 6 | |
|---|---|
| Error | 36.7 |
| Cost | 2676 |
| Alternative 7 | |
|---|---|
| Error | 43.2 |
| Cost | 2557 |
| Alternative 8 | |
|---|---|
| Error | 43.1 |
| Cost | 2557 |
| Alternative 9 | |
|---|---|
| Error | 38.6 |
| Cost | 2544 |
| Alternative 10 | |
|---|---|
| Error | 28.0 |
| Cost | 2536 |
| Alternative 11 | |
|---|---|
| Error | 26.1 |
| Cost | 2401 |
| Alternative 12 | |
|---|---|
| Error | 33.2 |
| Cost | 2148 |
| Alternative 13 | |
|---|---|
| Error | 33.4 |
| Cost | 2148 |
| Alternative 14 | |
|---|---|
| Error | 33.1 |
| Cost | 2148 |
| Alternative 15 | |
|---|---|
| Error | 32.2 |
| Cost | 1884 |
| Alternative 16 | |
|---|---|
| Error | 50.1 |
| Cost | 1837 |
| Alternative 17 | |
|---|---|
| Error | 41.4 |
| Cost | 1764 |
| Alternative 18 | |
|---|---|
| Error | 37.6 |
| Cost | 1764 |
| Alternative 19 | |
|---|---|
| Error | 36.9 |
| Cost | 1632 |
| Alternative 20 | |
|---|---|
| Error | 50.9 |
| Cost | 1572 |
| Alternative 21 | |
|---|---|
| Error | 51.0 |
| Cost | 1572 |
| Alternative 22 | |
|---|---|
| Error | 49.8 |
| Cost | 1572 |
| Alternative 23 | |
|---|---|
| Error | 48.0 |
| Cost | 1440 |
| Alternative 24 | |
|---|---|
| Error | 50.1 |
| Cost | 1309 |
| Alternative 25 | |
|---|---|
| Error | 36.8 |
| Cost | 1236 |
| Alternative 26 | |
|---|---|
| Error | 49.7 |
| Cost | 980 |
| Alternative 27 | |
|---|---|
| Error | 49.4 |
| Cost | 848 |
| Alternative 28 | |
|---|---|
| Error | 37.1 |
| Cost | 841 |
| Alternative 29 | |
|---|---|
| Error | 49.3 |
| Cost | 585 |
| Alternative 30 | |
|---|---|
| Error | 49.6 |
| Cost | 585 |
| Alternative 31 | |
|---|---|
| Error | 53.5 |
| Cost | 320 |
| Alternative 32 | |
|---|---|
| Error | 53.4 |
| Cost | 320 |
herbie shell --seed 2023039
(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)))))