Average Error: 12.2 → 6.0
Time: 12.2s
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 := j \cdot \left(a \cdot c - y \cdot i\right)\\ t_2 := c \cdot \left(z \cdot b\right) - i \cdot \left(t \cdot b\right)\\ t_3 := x \cdot \left(y \cdot z - t \cdot a\right)\\ t_4 := \left(t_3 - b \cdot \left(z \cdot c - t \cdot i\right)\right) + t_1\\ \mathbf{if}\;t_4 \leq -4.234739746971676 \cdot 10^{+304}:\\ \;\;\;\;\left(t_3 - t_2\right) + \left(c \cdot \left(a \cdot j\right) - i \cdot \left(y \cdot j\right)\right)\\ \mathbf{elif}\;t_4 \leq 2.1205633201927566 \cdot 10^{+301}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_1 + \left(\left(y \cdot \left(x \cdot z\right) - a \cdot \left(x \cdot t\right)\right) - t_2\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 := j \cdot \left(a \cdot c - y \cdot i\right)\\
t_2 := c \cdot \left(z \cdot b\right) - i \cdot \left(t \cdot b\right)\\
t_3 := x \cdot \left(y \cdot z - t \cdot a\right)\\
t_4 := \left(t_3 - b \cdot \left(z \cdot c - t \cdot i\right)\right) + t_1\\
\mathbf{if}\;t_4 \leq -4.234739746971676 \cdot 10^{+304}:\\
\;\;\;\;\left(t_3 - t_2\right) + \left(c \cdot \left(a \cdot j\right) - i \cdot \left(y \cdot j\right)\right)\\

\mathbf{elif}\;t_4 \leq 2.1205633201927566 \cdot 10^{+301}:\\
\;\;\;\;t_4\\

\mathbf{else}:\\
\;\;\;\;t_1 + \left(\left(y \cdot \left(x \cdot z\right) - a \cdot \left(x \cdot t\right)\right) - t_2\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 (* j (- (* a c) (* y i))))
        (t_2 (- (* c (* z b)) (* i (* t b))))
        (t_3 (* x (- (* y z) (* t a))))
        (t_4 (+ (- t_3 (* b (- (* z c) (* t i)))) t_1)))
   (if (<= t_4 -4.234739746971676e+304)
     (+ (- t_3 t_2) (- (* c (* a j)) (* i (* y j))))
     (if (<= t_4 2.1205633201927566e+301)
       t_4
       (+ t_1 (- (- (* y (* x z)) (* a (* x t))) t_2))))))
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 = j * ((a * c) - (y * i));
	double t_2 = (c * (z * b)) - (i * (t * b));
	double t_3 = x * ((y * z) - (t * a));
	double t_4 = (t_3 - (b * ((z * c) - (t * i)))) + t_1;
	double tmp;
	if (t_4 <= -4.234739746971676e+304) {
		tmp = (t_3 - t_2) + ((c * (a * j)) - (i * (y * j)));
	} else if (t_4 <= 2.1205633201927566e+301) {
		tmp = t_4;
	} else {
		tmp = t_1 + (((y * (x * z)) - (a * (x * t))) - t_2);
	}
	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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original12.2
Target19.2
Herbie6.0
\[\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)))) < -4.23473974697167595e304

    1. Initial program 60.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. Taylor expanded in c around 0 41.4

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

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

    if -4.23473974697167595e304 < (+.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)))) < 2.1205633201927566e301

    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. Taylor expanded in j around 0 0.9

      \[\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}{j \cdot \left(c \cdot a - i \cdot y\right)} \]

    if 2.1205633201927566e301 < (+.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 58.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 43.0

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

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

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

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

      \[\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(z \cdot b\right) - i \cdot \left(t \cdot b\right)\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification6.0

    \[\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 -4.234739746971676 \cdot 10^{+304}:\\ \;\;\;\;\left(x \cdot \left(y \cdot z - t \cdot a\right) - \left(c \cdot \left(z \cdot b\right) - i \cdot \left(t \cdot b\right)\right)\right) + \left(c \cdot \left(a \cdot j\right) - i \cdot \left(y \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 2.1205633201927566 \cdot 10^{+301}:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;j \cdot \left(a \cdot c - y \cdot i\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 2022077 
(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)))))