Average Error: 12.5 → 2.9
Time: 14.6s
Precision: binary64
\[\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 := c \cdot \left(z \cdot b\right) + a \cdot \left(x \cdot t\right)\\ t_3 := y \cdot z - t \cdot a\\ t_4 := \left(x \cdot t_3 - b \cdot \left(z \cdot c - a \cdot i\right)\right) + t_1\\ t_5 := c \cdot \left(t \cdot j\right) + y \cdot \left(x \cdot z\right)\\ \mathbf{if}\;t_4 \leq -\infty:\\ \;\;\;\;\left(i \cdot \left(a \cdot b\right) + t_5\right) - \left(y \cdot \left(i \cdot j\right) + t_2\right)\\ \mathbf{elif}\;t_4 \leq 1.137453164215366 \cdot 10^{+307}:\\ \;\;\;\;\mathsf{fma}\left(b, a \cdot i - z \cdot c, \mathsf{fma}\left(x, t_3, t_1\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t_5 + a \cdot \left(b \cdot i\right)\right) - \left(t_2 + i \cdot \left(y \cdot j\right)\right)\\ \end{array} \]
\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 := c \cdot \left(z \cdot b\right) + a \cdot \left(x \cdot t\right)\\
t_3 := y \cdot z - t \cdot a\\
t_4 := \left(x \cdot t_3 - b \cdot \left(z \cdot c - a \cdot i\right)\right) + t_1\\
t_5 := c \cdot \left(t \cdot j\right) + y \cdot \left(x \cdot z\right)\\
\mathbf{if}\;t_4 \leq -\infty:\\
\;\;\;\;\left(i \cdot \left(a \cdot b\right) + t_5\right) - \left(y \cdot \left(i \cdot j\right) + t_2\right)\\

\mathbf{elif}\;t_4 \leq 1.137453164215366 \cdot 10^{+307}:\\
\;\;\;\;\mathsf{fma}\left(b, a \cdot i - z \cdot c, \mathsf{fma}\left(x, t_3, t_1\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(t_5 + a \cdot \left(b \cdot i\right)\right) - \left(t_2 + i \cdot \left(y \cdot j\right)\right)\\


\end{array}
(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 (+ (* c (* z b)) (* a (* x t))))
        (t_3 (- (* y z) (* t a)))
        (t_4 (+ (- (* x t_3) (* b (- (* z c) (* a i)))) t_1))
        (t_5 (+ (* c (* t j)) (* y (* x z)))))
   (if (<= t_4 (- INFINITY))
     (- (+ (* i (* a b)) t_5) (+ (* y (* i j)) t_2))
     (if (<= t_4 1.137453164215366e+307)
       (fma b (- (* a i) (* z c)) (fma x t_3 t_1))
       (- (+ t_5 (* a (* b i))) (+ t_2 (* i (* y j))))))))
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 = (c * (z * b)) + (a * (x * t));
	double t_3 = (y * z) - (t * a);
	double t_4 = ((x * t_3) - (b * ((z * c) - (a * i)))) + t_1;
	double t_5 = (c * (t * j)) + (y * (x * z));
	double tmp;
	if (t_4 <= -((double) INFINITY)) {
		tmp = ((i * (a * b)) + t_5) - ((y * (i * j)) + t_2);
	} else if (t_4 <= 1.137453164215366e+307) {
		tmp = fma(b, ((a * i) - (z * c)), fma(x, t_3, t_1));
	} else {
		tmp = (t_5 + (a * (b * i))) - (t_2 + (i * (y * j)));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Bits error versus b

Bits error versus c

Bits error versus i

Bits error versus j

Target

Original12.5
Target16.4
Herbie2.9
\[\begin{array}{l} \mathbf{if}\;t < -8.120978919195912 \cdot 10^{-33}:\\ \;\;\;\;x \cdot \left(z \cdot y - a \cdot t\right) - \left(b \cdot \left(z \cdot c - a \cdot i\right) - \left(c \cdot t - y \cdot i\right) \cdot j\right)\\ \mathbf{elif}\;t < -4.712553818218485 \cdot 10^{-169}:\\ \;\;\;\;\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right) + \frac{j \cdot \left({\left(c \cdot t\right)}^{2} - {\left(i \cdot y\right)}^{2}\right)}{c \cdot t + i \cdot y}\\ \mathbf{elif}\;t < -7.633533346031584 \cdot 10^{-308}:\\ \;\;\;\;x \cdot \left(z \cdot y - a \cdot t\right) - \left(b \cdot \left(z \cdot c - a \cdot i\right) - \left(c \cdot t - y \cdot i\right) \cdot j\right)\\ \mathbf{elif}\;t < 1.0535888557455487 \cdot 10^{-139}:\\ \;\;\;\;\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right) + \frac{j \cdot \left({\left(c \cdot t\right)}^{2} - {\left(i \cdot y\right)}^{2}\right)}{c \cdot t + i \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot y - a \cdot t\right) - \left(b \cdot \left(z \cdot c - a \cdot i\right) - \left(c \cdot t - y \cdot i\right) \cdot j\right)\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  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

    1. Initial program 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) \]
    2. Simplified64.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, a \cdot i - z \cdot c, \mathsf{fma}\left(x, y \cdot z - t \cdot a, j \cdot \left(t \cdot c - y \cdot i\right)\right)\right)} \]
    3. Taylor expanded in b around 0 12.8

      \[\leadsto \color{blue}{\left(i \cdot \left(a \cdot b\right) + \left(c \cdot \left(t \cdot j\right) + y \cdot \left(z \cdot x\right)\right)\right) - \left(y \cdot \left(i \cdot j\right) + \left(c \cdot \left(z \cdot b\right) + a \cdot \left(t \cdot x\right)\right)\right)} \]
    4. Applied *-commutative_binary6412.8

      \[\leadsto \left(i \cdot \left(a \cdot b\right) + \left(\color{blue}{\left(t \cdot j\right) \cdot c} + y \cdot \left(z \cdot x\right)\right)\right) - \left(y \cdot \left(i \cdot j\right) + \left(c \cdot \left(z \cdot b\right) + a \cdot \left(t \cdot x\right)\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)))) < 1.1374531642153661e307

    1. Initial program 0.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) \]
    2. Simplified0.7

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, a \cdot i - z \cdot c, \mathsf{fma}\left(x, y \cdot z - t \cdot a, j \cdot \left(t \cdot c - y \cdot i\right)\right)\right)} \]
    3. Applied prod-diff_binary640.7

      \[\leadsto \mathsf{fma}\left(b, a \cdot i - z \cdot c, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(y, z, -a \cdot t\right) + \mathsf{fma}\left(-a, t, a \cdot t\right)}, j \cdot \left(t \cdot c - y \cdot i\right)\right)\right) \]
    4. Simplified0.7

      \[\leadsto \mathsf{fma}\left(b, a \cdot i - z \cdot c, \mathsf{fma}\left(x, \color{blue}{\left(y \cdot z - t \cdot a\right)} + \mathsf{fma}\left(-a, t, a \cdot t\right), j \cdot \left(t \cdot c - y \cdot i\right)\right)\right) \]
    5. Simplified0.7

      \[\leadsto \mathsf{fma}\left(b, a \cdot i - z \cdot c, \mathsf{fma}\left(x, \left(y \cdot z - t \cdot a\right) + \color{blue}{0}, j \cdot \left(t \cdot c - y \cdot i\right)\right)\right) \]

    if 1.1374531642153661e307 < (+.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. Initial program 63.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) \]
    2. Simplified63.5

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, a \cdot i - z \cdot c, \mathsf{fma}\left(x, y \cdot z - t \cdot a, j \cdot \left(t \cdot c - y \cdot i\right)\right)\right)} \]
    3. Taylor expanded in a around 0 12.4

      \[\leadsto \color{blue}{\left(a \cdot \left(i \cdot b\right) + \left(c \cdot \left(t \cdot j\right) + y \cdot \left(z \cdot x\right)\right)\right) - \left(i \cdot \left(y \cdot j\right) + \left(a \cdot \left(t \cdot x\right) + c \cdot \left(z \cdot b\right)\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(z \cdot c - a \cdot i\right)\right) + j \cdot \left(t \cdot c - y \cdot i\right) \leq -\infty:\\ \;\;\;\;\left(i \cdot \left(a \cdot b\right) + \left(c \cdot \left(t \cdot j\right) + y \cdot \left(x \cdot z\right)\right)\right) - \left(y \cdot \left(i \cdot j\right) + \left(c \cdot \left(z \cdot b\right) + a \cdot \left(x \cdot t\right)\right)\right)\\ \mathbf{elif}\;\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(z \cdot c - a \cdot i\right)\right) + j \cdot \left(t \cdot c - y \cdot i\right) \leq 1.137453164215366 \cdot 10^{+307}:\\ \;\;\;\;\mathsf{fma}\left(b, a \cdot i - z \cdot c, \mathsf{fma}\left(x, y \cdot z - t \cdot a, j \cdot \left(t \cdot c - y \cdot i\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(c \cdot \left(t \cdot j\right) + y \cdot \left(x \cdot z\right)\right) + a \cdot \left(b \cdot i\right)\right) - \left(\left(c \cdot \left(z \cdot b\right) + a \cdot \left(x \cdot t\right)\right) + i \cdot \left(y \cdot j\right)\right)\\ \end{array} \]

Reproduce

herbie shell --seed 2022068 
(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)))))