Average Error: 11.7 → 9.8
Time: 33.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}\;z \le -8.075828090768532 \cdot 10^{+82}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \left(x \cdot y - c \cdot b\right) \cdot z - \left(a \cdot x\right) \cdot t\right)\\ \mathbf{elif}\;z \le 9.741177042073514 \cdot 10^{+85}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(t \cdot i - c \cdot z, b, \left(z \cdot y - a \cdot t\right) \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \left(x \cdot y - c \cdot b\right) \cdot z - \left(a \cdot x\right) \cdot t\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}\;z \le -8.075828090768532 \cdot 10^{+82}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \left(x \cdot y - c \cdot b\right) \cdot z - \left(a \cdot x\right) \cdot t\right)\\

\mathbf{elif}\;z \le 9.741177042073514 \cdot 10^{+85}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(t \cdot i - c \cdot z, b, \left(z \cdot y - a \cdot t\right) \cdot x\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r38477703 = x;
        double r38477704 = y;
        double r38477705 = z;
        double r38477706 = r38477704 * r38477705;
        double r38477707 = t;
        double r38477708 = a;
        double r38477709 = r38477707 * r38477708;
        double r38477710 = r38477706 - r38477709;
        double r38477711 = r38477703 * r38477710;
        double r38477712 = b;
        double r38477713 = c;
        double r38477714 = r38477713 * r38477705;
        double r38477715 = i;
        double r38477716 = r38477707 * r38477715;
        double r38477717 = r38477714 - r38477716;
        double r38477718 = r38477712 * r38477717;
        double r38477719 = r38477711 - r38477718;
        double r38477720 = j;
        double r38477721 = r38477713 * r38477708;
        double r38477722 = r38477704 * r38477715;
        double r38477723 = r38477721 - r38477722;
        double r38477724 = r38477720 * r38477723;
        double r38477725 = r38477719 + r38477724;
        return r38477725;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r38477726 = z;
        double r38477727 = -8.075828090768532e+82;
        bool r38477728 = r38477726 <= r38477727;
        double r38477729 = a;
        double r38477730 = c;
        double r38477731 = r38477729 * r38477730;
        double r38477732 = i;
        double r38477733 = y;
        double r38477734 = r38477732 * r38477733;
        double r38477735 = r38477731 - r38477734;
        double r38477736 = j;
        double r38477737 = x;
        double r38477738 = r38477737 * r38477733;
        double r38477739 = b;
        double r38477740 = r38477730 * r38477739;
        double r38477741 = r38477738 - r38477740;
        double r38477742 = r38477741 * r38477726;
        double r38477743 = r38477729 * r38477737;
        double r38477744 = t;
        double r38477745 = r38477743 * r38477744;
        double r38477746 = r38477742 - r38477745;
        double r38477747 = fma(r38477735, r38477736, r38477746);
        double r38477748 = 9.741177042073514e+85;
        bool r38477749 = r38477726 <= r38477748;
        double r38477750 = r38477744 * r38477732;
        double r38477751 = r38477730 * r38477726;
        double r38477752 = r38477750 - r38477751;
        double r38477753 = r38477726 * r38477733;
        double r38477754 = r38477729 * r38477744;
        double r38477755 = r38477753 - r38477754;
        double r38477756 = r38477755 * r38477737;
        double r38477757 = fma(r38477752, r38477739, r38477756);
        double r38477758 = fma(r38477735, r38477736, r38477757);
        double r38477759 = r38477749 ? r38477758 : r38477747;
        double r38477760 = r38477728 ? r38477747 : r38477759;
        return r38477760;
}

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

Original11.7
Target18.4
Herbie9.8
\[\begin{array}{l} \mathbf{if}\;x \lt -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 \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 z < -8.075828090768532e+82 or 9.741177042073514e+85 < z

    1. Initial program 18.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. Simplified18.8

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

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

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

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

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

    if -8.075828090768532e+82 < z < 9.741177042073514e+85

    1. Initial program 9.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -8.075828090768532 \cdot 10^{+82}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \left(x \cdot y - c \cdot b\right) \cdot z - \left(a \cdot x\right) \cdot t\right)\\ \mathbf{elif}\;z \le 9.741177042073514 \cdot 10^{+85}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(t \cdot i - c \cdot z, b, \left(z \cdot y - a \cdot t\right) \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \left(x \cdot y - c \cdot b\right) \cdot z - \left(a \cdot x\right) \cdot t\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019163 +o rules:numerics
(FPCore (x y z t a b c i j)
  :name "Data.Colour.Matrix:determinant from colour-2.3.3, A"

  :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)))))