Average Error: 12.2 → 11.0
Time: 29.0s
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 -13024982361032863252480:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \left(x \cdot y - c \cdot b\right) \cdot z - t \cdot \left(a \cdot x\right)\right)\\ \mathbf{elif}\;z \le 1.386403633069261669577947562874036609287 \cdot 10^{-54}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(b, i \cdot t - c \cdot z, \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 - t \cdot \left(a \cdot x\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}\;z \le -13024982361032863252480:\\
\;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \left(x \cdot y - c \cdot b\right) \cdot z - t \cdot \left(a \cdot x\right)\right)\\

\mathbf{elif}\;z \le 1.386403633069261669577947562874036609287 \cdot 10^{-54}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(b, i \cdot t - c \cdot z, \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 - t \cdot \left(a \cdot x\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 r38555754 = x;
        double r38555755 = y;
        double r38555756 = z;
        double r38555757 = r38555755 * r38555756;
        double r38555758 = t;
        double r38555759 = a;
        double r38555760 = r38555758 * r38555759;
        double r38555761 = r38555757 - r38555760;
        double r38555762 = r38555754 * r38555761;
        double r38555763 = b;
        double r38555764 = c;
        double r38555765 = r38555764 * r38555756;
        double r38555766 = i;
        double r38555767 = r38555758 * r38555766;
        double r38555768 = r38555765 - r38555767;
        double r38555769 = r38555763 * r38555768;
        double r38555770 = r38555762 - r38555769;
        double r38555771 = j;
        double r38555772 = r38555764 * r38555759;
        double r38555773 = r38555755 * r38555766;
        double r38555774 = r38555772 - r38555773;
        double r38555775 = r38555771 * r38555774;
        double r38555776 = r38555770 + r38555775;
        return r38555776;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r38555777 = z;
        double r38555778 = -1.3024982361032863e+22;
        bool r38555779 = r38555777 <= r38555778;
        double r38555780 = a;
        double r38555781 = c;
        double r38555782 = r38555780 * r38555781;
        double r38555783 = i;
        double r38555784 = y;
        double r38555785 = r38555783 * r38555784;
        double r38555786 = r38555782 - r38555785;
        double r38555787 = j;
        double r38555788 = x;
        double r38555789 = r38555788 * r38555784;
        double r38555790 = b;
        double r38555791 = r38555781 * r38555790;
        double r38555792 = r38555789 - r38555791;
        double r38555793 = r38555792 * r38555777;
        double r38555794 = t;
        double r38555795 = r38555780 * r38555788;
        double r38555796 = r38555794 * r38555795;
        double r38555797 = r38555793 - r38555796;
        double r38555798 = fma(r38555786, r38555787, r38555797);
        double r38555799 = 1.3864036330692617e-54;
        bool r38555800 = r38555777 <= r38555799;
        double r38555801 = r38555783 * r38555794;
        double r38555802 = r38555781 * r38555777;
        double r38555803 = r38555801 - r38555802;
        double r38555804 = r38555777 * r38555784;
        double r38555805 = r38555780 * r38555794;
        double r38555806 = r38555804 - r38555805;
        double r38555807 = r38555806 * r38555788;
        double r38555808 = fma(r38555790, r38555803, r38555807);
        double r38555809 = fma(r38555786, r38555787, r38555808);
        double r38555810 = r38555800 ? r38555809 : r38555798;
        double r38555811 = r38555779 ? r38555798 : r38555810;
        return r38555811;
}

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.2
Target19.6
Herbie11.0
\[\begin{array}{l} \mathbf{if}\;x \lt -1.469694296777705016266218530347997287942 \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.21135273622268028942701600607048800714 \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 < -1.3024982361032863e+22 or 1.3864036330692617e-54 < z

    1. Initial program 16.1

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

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

      \[\leadsto \mathsf{fma}\left(a \cdot c - y \cdot i, j, \mathsf{fma}\left(b, i \cdot t - z \cdot c, \left(z \cdot y - t \cdot a\right) \cdot \color{blue}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)}\right)\right)\]
    5. Applied associate-*r*16.4

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

      \[\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)\]
    7. Simplified13.4

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

    if -1.3024982361032863e+22 < z < 1.3864036330692617e-54

    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(b, i \cdot t - z \cdot c, \left(z \cdot y - t \cdot a\right) \cdot x\right)\right)}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt9.6

      \[\leadsto \mathsf{fma}\left(a \cdot c - y \cdot i, j, \mathsf{fma}\left(b, i \cdot t - z \cdot c, \left(z \cdot y - t \cdot a\right) \cdot \color{blue}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)}\right)\right)\]
    5. Applied associate-*r*9.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -13024982361032863252480:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \left(x \cdot y - c \cdot b\right) \cdot z - t \cdot \left(a \cdot x\right)\right)\\ \mathbf{elif}\;z \le 1.386403633069261669577947562874036609287 \cdot 10^{-54}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(b, i \cdot t - c \cdot z, \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 - t \cdot \left(a \cdot x\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019179 +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.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)))))