Average Error: 12.4 → 9.2
Time: 12.9s
Precision: 64
\[\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}\;x \le -1082719539.63382983 \lor \neg \left(x \le 1.1169727630375101 \cdot 10^{-22}\right):\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \left(y \cdot z\right) + x \cdot \left(-t \cdot a\right)\right) - \left(\left(b \cdot \left(c \cdot z\right) + b \cdot \left(-t \cdot i\right)\right) + b \cdot \mathsf{fma}\left(-i, t, i \cdot t\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(\left(x \cdot y\right) \cdot z + -1 \cdot \left(a \cdot \left(x \cdot t\right)\right)\right) - \left(b \cdot \left(c \cdot z - t \cdot i\right) + b \cdot \mathsf{fma}\left(-i, t, i \cdot t\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}
\mathbf{if}\;x \le -1082719539.63382983 \lor \neg \left(x \le 1.1169727630375101 \cdot 10^{-22}\right):\\
\;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \left(y \cdot z\right) + x \cdot \left(-t \cdot a\right)\right) - \left(\left(b \cdot \left(c \cdot z\right) + b \cdot \left(-t \cdot i\right)\right) + b \cdot \mathsf{fma}\left(-i, t, i \cdot t\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(\left(x \cdot y\right) \cdot z + -1 \cdot \left(a \cdot \left(x \cdot t\right)\right)\right) - \left(b \cdot \left(c \cdot z - t \cdot i\right) + b \cdot \mathsf{fma}\left(-i, t, i \cdot t\right)\right)\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r820576 = x;
        double r820577 = y;
        double r820578 = z;
        double r820579 = r820577 * r820578;
        double r820580 = t;
        double r820581 = a;
        double r820582 = r820580 * r820581;
        double r820583 = r820579 - r820582;
        double r820584 = r820576 * r820583;
        double r820585 = b;
        double r820586 = c;
        double r820587 = r820586 * r820578;
        double r820588 = i;
        double r820589 = r820580 * r820588;
        double r820590 = r820587 - r820589;
        double r820591 = r820585 * r820590;
        double r820592 = r820584 - r820591;
        double r820593 = j;
        double r820594 = r820586 * r820581;
        double r820595 = r820577 * r820588;
        double r820596 = r820594 - r820595;
        double r820597 = r820593 * r820596;
        double r820598 = r820592 + r820597;
        return r820598;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r820599 = x;
        double r820600 = -1082719539.6338298;
        bool r820601 = r820599 <= r820600;
        double r820602 = 1.1169727630375101e-22;
        bool r820603 = r820599 <= r820602;
        double r820604 = !r820603;
        bool r820605 = r820601 || r820604;
        double r820606 = c;
        double r820607 = a;
        double r820608 = r820606 * r820607;
        double r820609 = y;
        double r820610 = i;
        double r820611 = r820609 * r820610;
        double r820612 = r820608 - r820611;
        double r820613 = j;
        double r820614 = z;
        double r820615 = r820609 * r820614;
        double r820616 = r820599 * r820615;
        double r820617 = t;
        double r820618 = r820617 * r820607;
        double r820619 = -r820618;
        double r820620 = r820599 * r820619;
        double r820621 = r820616 + r820620;
        double r820622 = b;
        double r820623 = r820606 * r820614;
        double r820624 = r820622 * r820623;
        double r820625 = r820617 * r820610;
        double r820626 = -r820625;
        double r820627 = r820622 * r820626;
        double r820628 = r820624 + r820627;
        double r820629 = -r820610;
        double r820630 = r820610 * r820617;
        double r820631 = fma(r820629, r820617, r820630);
        double r820632 = r820622 * r820631;
        double r820633 = r820628 + r820632;
        double r820634 = r820621 - r820633;
        double r820635 = fma(r820612, r820613, r820634);
        double r820636 = r820599 * r820609;
        double r820637 = r820636 * r820614;
        double r820638 = -1.0;
        double r820639 = r820599 * r820617;
        double r820640 = r820607 * r820639;
        double r820641 = r820638 * r820640;
        double r820642 = r820637 + r820641;
        double r820643 = r820623 - r820625;
        double r820644 = r820622 * r820643;
        double r820645 = r820644 + r820632;
        double r820646 = r820642 - r820645;
        double r820647 = fma(r820612, r820613, r820646);
        double r820648 = r820605 ? r820635 : r820647;
        return r820648;
}

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.1
Herbie9.2
\[\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 x < -1082719539.6338298 or 1.1169727630375101e-22 < x

    1. Initial program 8.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. Simplified8.6

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

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

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

      \[\leadsto \mathsf{fma}\left(c \cdot a - y \cdot i, j, x \cdot \left(y \cdot z - t \cdot a\right) - \left(\color{blue}{b \cdot \left(c \cdot z - t \cdot i\right)} + b \cdot \mathsf{fma}\left(-i, t, i \cdot t\right)\right)\right)\]
    7. Using strategy rm
    8. Applied sub-neg8.6

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

      \[\leadsto \mathsf{fma}\left(c \cdot a - y \cdot i, j, \color{blue}{\left(x \cdot \left(y \cdot z\right) + x \cdot \left(-t \cdot a\right)\right)} - \left(b \cdot \left(c \cdot z - t \cdot i\right) + b \cdot \mathsf{fma}\left(-i, t, i \cdot t\right)\right)\right)\]
    10. Using strategy rm
    11. Applied sub-neg8.6

      \[\leadsto \mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \left(y \cdot z\right) + x \cdot \left(-t \cdot a\right)\right) - \left(b \cdot \color{blue}{\left(c \cdot z + \left(-t \cdot i\right)\right)} + b \cdot \mathsf{fma}\left(-i, t, i \cdot t\right)\right)\right)\]
    12. Applied distribute-lft-in8.6

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

    if -1082719539.6338298 < x < 1.1169727630375101e-22

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(c \cdot a - y \cdot i, j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right)}\]
    3. Using strategy rm
    4. Applied prod-diff14.8

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \left(y \cdot z\right) + \color{blue}{-1 \cdot \left(a \cdot \left(x \cdot t\right)\right)}\right) - \left(b \cdot \left(c \cdot z - t \cdot i\right) + b \cdot \mathsf{fma}\left(-i, t, i \cdot t\right)\right)\right)\]
    11. Using strategy rm
    12. Applied associate-*r*9.6

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1082719539.63382983 \lor \neg \left(x \le 1.1169727630375101 \cdot 10^{-22}\right):\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \left(y \cdot z\right) + x \cdot \left(-t \cdot a\right)\right) - \left(\left(b \cdot \left(c \cdot z\right) + b \cdot \left(-t \cdot i\right)\right) + b \cdot \mathsf{fma}\left(-i, t, i \cdot t\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(\left(x \cdot y\right) \cdot z + -1 \cdot \left(a \cdot \left(x \cdot t\right)\right)\right) - \left(b \cdot \left(c \cdot z - t \cdot i\right) + b \cdot \mathsf{fma}\left(-i, t, i \cdot t\right)\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020089 +o rules:numerics
(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) (pow (* t i) 2))) (+ (* 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) (pow (* t i) 2))) (+ (* c z) (* t i)))) (* j (- (* c a) (* y i))))))

  (+ (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* t i)))) (* j (- (* c a) (* y i)))))