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

\mathbf{elif}\;t_4 \leq 4.831771083036463 \cdot 10^{+304}:\\
\;\;\;\;t_3 + \left(\left(x \cdot \mathsf{fma}\left(y, z, -t \cdot a\right) + x \cdot \mathsf{fma}\left(-a, t, t \cdot a\right)\right) - t_1\right)\\

\mathbf{else}:\\
\;\;\;\;t_2 + \left(t_5 - \left(c \cdot \left(z \cdot b\right) - i \cdot \left(t \cdot b\right)\right)\right)\\


\end{array}
(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 (* b (- (* z c) (* t i))))
        (t_2 (- (* c (* a j)) (* y (* i j))))
        (t_3 (* j (- (* a c) (* y i))))
        (t_4 (+ (- (* x (- (* y z) (* t a))) t_1) t_3))
        (t_5 (- (* y (* x z)) (* a (* x t)))))
   (if (<= t_4 (- INFINITY))
     (+ (- t_5 t_1) t_2)
     (if (<= t_4 4.831771083036463e+304)
       (+
        t_3
        (- (+ (* x (fma y z (- (* t a)))) (* x (fma (- a) t (* t a)))) t_1))
       (+ t_2 (- t_5 (- (* c (* z b)) (* i (* t 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) - (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 = b * ((z * c) - (t * i));
	double t_2 = (c * (a * j)) - (y * (i * j));
	double t_3 = j * ((a * c) - (y * i));
	double t_4 = ((x * ((y * z) - (t * a))) - t_1) + t_3;
	double t_5 = (y * (x * z)) - (a * (x * t));
	double tmp;
	if (t_4 <= -((double) INFINITY)) {
		tmp = (t_5 - t_1) + t_2;
	} else if (t_4 <= 4.831771083036463e+304) {
		tmp = t_3 + (((x * fma(y, z, -(t * a))) + (x * fma(-a, t, (t * a)))) - t_1);
	} else {
		tmp = t_2 + (t_5 - ((c * (z * b)) - (i * (t * b))));
	}
	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.4
Target20.0
Herbie4.1
\[\begin{array}{l} \mathbf{if}\;x < -1.469694296777705 \cdot 10^{-64}:\\ \;\;\;\;\left(x \cdot \left(y \cdot z - t \cdot a\right) - \frac{b \cdot \left({\left(c \cdot z\right)}^{2} - {\left(t \cdot i\right)}^{2}\right)}{c \cdot z + t \cdot i}\right) + j \cdot \left(c \cdot a - y \cdot i\right)\\ \mathbf{elif}\;x < 3.2113527362226803 \cdot 10^{-147}:\\ \;\;\;\;\left(b \cdot i - x \cdot a\right) \cdot t - \left(z \cdot \left(c \cdot b\right) - j \cdot \left(c \cdot a - y \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \left(y \cdot z - t \cdot a\right) - \frac{b \cdot \left({\left(c \cdot z\right)}^{2} - {\left(t \cdot i\right)}^{2}\right)}{c \cdot z + t \cdot i}\right) + j \cdot \left(c \cdot a - y \cdot i\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 t i)))) (*.f64 j (-.f64 (*.f64 c a) (*.f64 y i)))) < -inf.0

    1. Initial program 64.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) \]
    2. Taylor expanded in c around 0 44.1

      \[\leadsto \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(c \cdot \left(a \cdot j\right) - y \cdot \left(i \cdot j\right)\right)} \]
    3. Applied sub-neg_binary6444.1

      \[\leadsto \left(x \cdot \color{blue}{\left(y \cdot z + \left(-t \cdot a\right)\right)} - b \cdot \left(c \cdot z - t \cdot i\right)\right) + \left(c \cdot \left(a \cdot j\right) - y \cdot \left(i \cdot j\right)\right) \]
    4. Applied distribute-rgt-in_binary6444.1

      \[\leadsto \left(\color{blue}{\left(\left(y \cdot z\right) \cdot x + \left(-t \cdot a\right) \cdot x\right)} - b \cdot \left(c \cdot z - t \cdot i\right)\right) + \left(c \cdot \left(a \cdot j\right) - y \cdot \left(i \cdot j\right)\right) \]
    5. Simplified34.6

      \[\leadsto \left(\left(\color{blue}{y \cdot \left(z \cdot x\right)} + \left(-t \cdot a\right) \cdot x\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right) + \left(c \cdot \left(a \cdot j\right) - y \cdot \left(i \cdot j\right)\right) \]
    6. Simplified25.3

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

    1. Initial program 0.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) \]
    2. Applied prod-diff_binary640.9

      \[\leadsto \left(x \cdot \color{blue}{\left(\mathsf{fma}\left(y, z, -a \cdot t\right) + \mathsf{fma}\left(-a, t, a \cdot t\right)\right)} - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right) \]
    3. Applied distribute-rgt-in_binary640.9

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

    if 4.83177108303646326e304 < (+.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. Initial program 61.6

      \[\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) \]
    2. Taylor expanded in c around 0 45.4

      \[\leadsto \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(c \cdot \left(a \cdot j\right) - y \cdot \left(i \cdot j\right)\right)} \]
    3. Taylor expanded in t around 0 28.3

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

      \[\leadsto \left(x \cdot \color{blue}{\left(y \cdot z + \left(-t \cdot a\right)\right)} - \left(c \cdot \left(b \cdot z\right) - i \cdot \left(t \cdot b\right)\right)\right) + \left(c \cdot \left(a \cdot j\right) - y \cdot \left(i \cdot j\right)\right) \]
    5. Applied distribute-rgt-in_binary6428.3

      \[\leadsto \left(\color{blue}{\left(\left(y \cdot z\right) \cdot x + \left(-t \cdot a\right) \cdot x\right)} - \left(c \cdot \left(b \cdot z\right) - i \cdot \left(t \cdot b\right)\right)\right) + \left(c \cdot \left(a \cdot j\right) - y \cdot \left(i \cdot j\right)\right) \]
    6. Simplified19.7

      \[\leadsto \left(\left(\color{blue}{y \cdot \left(z \cdot x\right)} + \left(-t \cdot a\right) \cdot x\right) - \left(c \cdot \left(b \cdot z\right) - i \cdot \left(t \cdot b\right)\right)\right) + \left(c \cdot \left(a \cdot j\right) - y \cdot \left(i \cdot j\right)\right) \]
    7. Simplified12.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\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) \leq -\infty:\\ \;\;\;\;\left(\left(y \cdot \left(x \cdot z\right) - a \cdot \left(x \cdot t\right)\right) - b \cdot \left(z \cdot c - t \cdot i\right)\right) + \left(c \cdot \left(a \cdot j\right) - y \cdot \left(i \cdot j\right)\right)\\ \mathbf{elif}\;\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) \leq 4.831771083036463 \cdot 10^{+304}:\\ \;\;\;\;j \cdot \left(a \cdot c - y \cdot i\right) + \left(\left(x \cdot \mathsf{fma}\left(y, z, -t \cdot a\right) + x \cdot \mathsf{fma}\left(-a, t, t \cdot a\right)\right) - b \cdot \left(z \cdot c - t \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(c \cdot \left(a \cdot j\right) - y \cdot \left(i \cdot j\right)\right) + \left(\left(y \cdot \left(x \cdot z\right) - a \cdot \left(x \cdot t\right)\right) - \left(c \cdot \left(z \cdot b\right) - i \cdot \left(t \cdot b\right)\right)\right)\\ \end{array} \]

Reproduce

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