Average Error: 12.0 → 9.0
Time: 24.3s
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} \mathbf{if}\;b \le -4.2721703133289528 \cdot 10^{49} \lor \neg \left(b \le 6122062468061031420\right):\\ \;\;\;\;\left(y \cdot \left(z \cdot x\right) + a \cdot \left(x \cdot \left(-t\right)\right)\right) + \left(j \cdot \left(a \cdot c - y \cdot i\right) - b \cdot \left(z \cdot c - t \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot z - a \cdot t\right) + \left(j \cdot \left(a \cdot c - y \cdot i\right) - \left(c \cdot \left(b \cdot z\right) + i \cdot \left(b \cdot \left(-t\right)\right)\right)\right)\\ \end{array}\]

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.0
Target19.4
Herbie9.0
\[\begin{array}{l} \mathbf{if}\;x \lt -1.46969429677770502 \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 \lt 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 2 regimes
  2. if b < -4.2721703133289528e49 or 6122062468061031420 < b

    1. Initial program 6.8

      \[\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. Simplified6.8

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

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

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

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

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

    if -4.2721703133289528e49 < b < 6122062468061031420

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -4.2721703133289528 \cdot 10^{49} \lor \neg \left(b \le 6122062468061031420\right):\\ \;\;\;\;\left(y \cdot \left(z \cdot x\right) + a \cdot \left(x \cdot \left(-t\right)\right)\right) + \left(j \cdot \left(a \cdot c - y \cdot i\right) - b \cdot \left(z \cdot c - t \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y \cdot z - a \cdot t\right) + \left(j \cdot \left(a \cdot c - y \cdot i\right) - \left(c \cdot \left(b \cdot z\right) + i \cdot \left(b \cdot \left(-t\right)\right)\right)\right)\\ \end{array}\]

Reproduce

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