Average Error: 17.5 → 15.8
Time: 20.4s
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 := y \cdot \left(z \cdot x - j \cdot i\right)\\ \mathbf{if}\;y \leq -8.031545841799723 \cdot 10^{+206}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_2 := i \cdot t - z \cdot c\\ \mathbf{if}\;y \leq -8.684066818048496 \cdot 10^{+95}:\\ \;\;\;\;\mathsf{fma}\left(b, t_2, y \cdot \left(z \cdot x\right) - \left(y \cdot \left(j \cdot i\right) + a \cdot \left(x \cdot t\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_3 := \mathsf{fma}\left(b, t_2, \mathsf{fma}\left(x, y \cdot z - t \cdot a, j \cdot \left(c \cdot a - y \cdot i\right)\right)\right)\\ \mathbf{if}\;y \leq -7.863566089797894 \cdot 10^{-220}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -8.209427578978356 \cdot 10^{-263}:\\ \;\;\;\;\mathsf{fma}\left(b, t_2, -i \cdot \left(y \cdot j\right)\right)\\ \mathbf{elif}\;y \leq 5.98026801756778 \cdot 10^{-307}:\\ \;\;\;\;a \cdot \left(j \cdot c - x \cdot t\right)\\ \mathbf{elif}\;y \leq 1.161862926415618 \cdot 10^{+120}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(i, b \cdot t, t_1\right)\\ \end{array}\\ \end{array}\\ \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 := y \cdot \left(z \cdot x - j \cdot i\right)\\
\mathbf{if}\;y \leq -8.031545841799723 \cdot 10^{+206}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_2 := i \cdot t - z \cdot c\\
\mathbf{if}\;y \leq -8.684066818048496 \cdot 10^{+95}:\\
\;\;\;\;\mathsf{fma}\left(b, t_2, y \cdot \left(z \cdot x\right) - \left(y \cdot \left(j \cdot i\right) + a \cdot \left(x \cdot t\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_3 := \mathsf{fma}\left(b, t_2, \mathsf{fma}\left(x, y \cdot z - t \cdot a, j \cdot \left(c \cdot a - y \cdot i\right)\right)\right)\\
\mathbf{if}\;y \leq -7.863566089797894 \cdot 10^{-220}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;y \leq -8.209427578978356 \cdot 10^{-263}:\\
\;\;\;\;\mathsf{fma}\left(b, t_2, -i \cdot \left(y \cdot j\right)\right)\\

\mathbf{elif}\;y \leq 5.98026801756778 \cdot 10^{-307}:\\
\;\;\;\;a \cdot \left(j \cdot c - x \cdot t\right)\\

\mathbf{elif}\;y \leq 1.161862926415618 \cdot 10^{+120}:\\
\;\;\;\;t_3\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, b \cdot t, t_1\right)\\


\end{array}\\


\end{array}\\


\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 (* y (- (* z x) (* j i)))))
   (if (<= y -8.031545841799723e+206)
     t_1
     (let* ((t_2 (- (* i t) (* z c))))
       (if (<= y -8.684066818048496e+95)
         (fma b t_2 (- (* y (* z x)) (+ (* y (* j i)) (* a (* x t)))))
         (let* ((t_3
                 (fma
                  b
                  t_2
                  (fma x (- (* y z) (* t a)) (* j (- (* c a) (* y i)))))))
           (if (<= y -7.863566089797894e-220)
             t_3
             (if (<= y -8.209427578978356e-263)
               (fma b t_2 (- (* i (* y j))))
               (if (<= y 5.98026801756778e-307)
                 (* a (- (* j c) (* x t)))
                 (if (<= y 1.161862926415618e+120)
                   t_3
                   (fma i (* b t) t_1)))))))))))
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 = y * ((z * x) - (j * i));
	double tmp;
	if (y <= -8.031545841799723e+206) {
		tmp = t_1;
	} else {
		double t_2 = (i * t) - (z * c);
		double tmp_1;
		if (y <= -8.684066818048496e+95) {
			tmp_1 = fma(b, t_2, ((y * (z * x)) - ((y * (j * i)) + (a * (x * t)))));
		} else {
			double t_3 = fma(b, t_2, fma(x, ((y * z) - (t * a)), (j * ((c * a) - (y * i)))));
			double tmp_2;
			if (y <= -7.863566089797894e-220) {
				tmp_2 = t_3;
			} else if (y <= -8.209427578978356e-263) {
				tmp_2 = fma(b, t_2, -(i * (y * j)));
			} else if (y <= 5.98026801756778e-307) {
				tmp_2 = a * ((j * c) - (x * t));
			} else if (y <= 1.161862926415618e+120) {
				tmp_2 = t_3;
			} else {
				tmp_2 = fma(i, (b * t), t_1);
			}
			tmp_1 = tmp_2;
		}
		tmp = tmp_1;
	}
	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

Original17.5
Target26.5
Herbie15.8
\[\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 6 regimes
  2. if y < -8.03154584179972283e206

    1. Initial program 26.5

      \[\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. Simplified22.4

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

      \[\leadsto \color{blue}{\left(i \cdot \left(t \cdot b\right) + \left(c \cdot \left(a \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. Taylor expanded in y around -inf 14.6

      \[\leadsto \color{blue}{-1 \cdot \left(\left(i \cdot j - z \cdot x\right) \cdot y\right)} \]
    5. Simplified14.6

      \[\leadsto \color{blue}{-y \cdot \left(j \cdot i - z \cdot x\right)} \]

    if -8.03154584179972283e206 < y < -8.68406681804849587e95

    1. Initial program 21.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. Simplified19.4

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

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

    if -8.68406681804849587e95 < y < -7.86356608979789409e-220 or 5.98026801756777983e-307 < y < 1.16186292641561798e120

    1. Initial program 14.4

      \[\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. Simplified13.0

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

    if -7.86356608979789409e-220 < y < -8.20942757897835569e-263

    1. Initial program 12.7

      \[\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. Simplified11.3

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

      \[\leadsto \mathsf{fma}\left(b, t \cdot i - z \cdot c, \color{blue}{-1 \cdot \left(i \cdot \left(y \cdot j\right)\right)}\right) \]
    4. Simplified30.5

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

    if -8.20942757897835569e-263 < y < 5.98026801756777983e-307

    1. Initial program 14.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. Simplified13.2

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

      \[\leadsto \color{blue}{-1 \cdot \left(\left(t \cdot x - c \cdot j\right) \cdot a\right)} \]

    if 1.16186292641561798e120 < y

    1. Initial program 24.7

      \[\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. Simplified22.1

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

      \[\leadsto \mathsf{fma}\left(b, \color{blue}{i \cdot t}, \mathsf{fma}\left(x, y \cdot z - t \cdot a, j \cdot \left(a \cdot c - y \cdot i\right)\right)\right) \]
    4. Applied add-cube-cbrt_binary6422.2

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(i, t \cdot b, y \cdot \left(z \cdot x - i \cdot j\right)\right)} \]
  3. Recombined 6 regimes into one program.
  4. Final simplification15.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -8.031545841799723 \cdot 10^{+206}:\\ \;\;\;\;y \cdot \left(z \cdot x - j \cdot i\right)\\ \mathbf{elif}\;y \leq -8.684066818048496 \cdot 10^{+95}:\\ \;\;\;\;\mathsf{fma}\left(b, i \cdot t - z \cdot c, y \cdot \left(z \cdot x\right) - \left(y \cdot \left(j \cdot i\right) + a \cdot \left(x \cdot t\right)\right)\right)\\ \mathbf{elif}\;y \leq -7.863566089797894 \cdot 10^{-220}:\\ \;\;\;\;\mathsf{fma}\left(b, i \cdot t - z \cdot c, \mathsf{fma}\left(x, y \cdot z - t \cdot a, j \cdot \left(c \cdot a - y \cdot i\right)\right)\right)\\ \mathbf{elif}\;y \leq -8.209427578978356 \cdot 10^{-263}:\\ \;\;\;\;\mathsf{fma}\left(b, i \cdot t - z \cdot c, -i \cdot \left(y \cdot j\right)\right)\\ \mathbf{elif}\;y \leq 5.98026801756778 \cdot 10^{-307}:\\ \;\;\;\;a \cdot \left(j \cdot c - x \cdot t\right)\\ \mathbf{elif}\;y \leq 1.161862926415618 \cdot 10^{+120}:\\ \;\;\;\;\mathsf{fma}\left(b, i \cdot t - z \cdot c, \mathsf{fma}\left(x, y \cdot z - t \cdot a, j \cdot \left(c \cdot a - y \cdot i\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(i, b \cdot t, y \cdot \left(z \cdot x - j \cdot i\right)\right)\\ \end{array} \]

Reproduce

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