Average Error: 11.8 → 10.7
Time: 19.8s
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 -1.8321120423840733 \cdot 10^{137} \lor \neg \left(x \le 1.0618402412527282 \cdot 10^{89}\right):\\ \;\;\;\;\mathsf{fma}\left(\left(\sqrt[3]{t \cdot i - c \cdot z} \cdot \sqrt[3]{t \cdot i - c \cdot z}\right) \cdot \sqrt[3]{t \cdot i - c \cdot z}, b, \mathsf{fma}\left(j, c \cdot a - y \cdot i, x \cdot \left(y \cdot z - t \cdot a\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t \cdot i - c \cdot z, b, \mathsf{fma}\left(j, c \cdot a - y \cdot i, x \cdot \left(z \cdot y\right) + \left(-a \cdot \left(x \cdot t\right)\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 -1.8321120423840733 \cdot 10^{137} \lor \neg \left(x \le 1.0618402412527282 \cdot 10^{89}\right):\\
\;\;\;\;\mathsf{fma}\left(\left(\sqrt[3]{t \cdot i - c \cdot z} \cdot \sqrt[3]{t \cdot i - c \cdot z}\right) \cdot \sqrt[3]{t \cdot i - c \cdot z}, b, \mathsf{fma}\left(j, c \cdot a - y \cdot i, x \cdot \left(y \cdot z - t \cdot a\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot i - c \cdot z, b, \mathsf{fma}\left(j, c \cdot a - y \cdot i, x \cdot \left(z \cdot y\right) + \left(-a \cdot \left(x \cdot t\right)\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 r536862 = x;
        double r536863 = y;
        double r536864 = z;
        double r536865 = r536863 * r536864;
        double r536866 = t;
        double r536867 = a;
        double r536868 = r536866 * r536867;
        double r536869 = r536865 - r536868;
        double r536870 = r536862 * r536869;
        double r536871 = b;
        double r536872 = c;
        double r536873 = r536872 * r536864;
        double r536874 = i;
        double r536875 = r536866 * r536874;
        double r536876 = r536873 - r536875;
        double r536877 = r536871 * r536876;
        double r536878 = r536870 - r536877;
        double r536879 = j;
        double r536880 = r536872 * r536867;
        double r536881 = r536863 * r536874;
        double r536882 = r536880 - r536881;
        double r536883 = r536879 * r536882;
        double r536884 = r536878 + r536883;
        return r536884;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r536885 = x;
        double r536886 = -1.8321120423840733e+137;
        bool r536887 = r536885 <= r536886;
        double r536888 = 1.0618402412527282e+89;
        bool r536889 = r536885 <= r536888;
        double r536890 = !r536889;
        bool r536891 = r536887 || r536890;
        double r536892 = t;
        double r536893 = i;
        double r536894 = r536892 * r536893;
        double r536895 = c;
        double r536896 = z;
        double r536897 = r536895 * r536896;
        double r536898 = r536894 - r536897;
        double r536899 = cbrt(r536898);
        double r536900 = r536899 * r536899;
        double r536901 = r536900 * r536899;
        double r536902 = b;
        double r536903 = j;
        double r536904 = a;
        double r536905 = r536895 * r536904;
        double r536906 = y;
        double r536907 = r536906 * r536893;
        double r536908 = r536905 - r536907;
        double r536909 = r536906 * r536896;
        double r536910 = r536892 * r536904;
        double r536911 = r536909 - r536910;
        double r536912 = r536885 * r536911;
        double r536913 = fma(r536903, r536908, r536912);
        double r536914 = fma(r536901, r536902, r536913);
        double r536915 = r536896 * r536906;
        double r536916 = r536885 * r536915;
        double r536917 = r536885 * r536892;
        double r536918 = r536904 * r536917;
        double r536919 = -r536918;
        double r536920 = r536916 + r536919;
        double r536921 = fma(r536903, r536908, r536920);
        double r536922 = fma(r536898, r536902, r536921);
        double r536923 = r536891 ? r536914 : r536922;
        return r536923;
}

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.8
Target19.8
Herbie10.7
\[\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 < -1.8321120423840733e+137 or 1.0618402412527282e+89 < x

    1. Initial program 6.4

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

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

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

    if -1.8321120423840733e+137 < x < 1.0618402412527282e+89

    1. Initial program 13.2

      \[\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. Simplified13.2

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.8321120423840733 \cdot 10^{137} \lor \neg \left(x \le 1.0618402412527282 \cdot 10^{89}\right):\\ \;\;\;\;\mathsf{fma}\left(\left(\sqrt[3]{t \cdot i - c \cdot z} \cdot \sqrt[3]{t \cdot i - c \cdot z}\right) \cdot \sqrt[3]{t \cdot i - c \cdot z}, b, \mathsf{fma}\left(j, c \cdot a - y \cdot i, x \cdot \left(y \cdot z - t \cdot a\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t \cdot i - c \cdot z, b, \mathsf{fma}\left(j, c \cdot a - y \cdot i, x \cdot \left(z \cdot y\right) + \left(-a \cdot \left(x \cdot t\right)\right)\right)\right)\\ \end{array}\]

Reproduce

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