Average Error: 12.0 → 13.7
Time: 1.2m
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}\;j \le -5.804223743897768589296254303936316719646 \cdot 10^{-190}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(t \cdot i - z \cdot c, b, \left(z \cdot y - a \cdot t\right) \cdot x\right)\right)\\ \mathbf{elif}\;j \le 1.189265720085326010143100313739170225725 \cdot 10^{-261}:\\ \;\;\;\;\left(y \cdot x - c \cdot b\right) \cdot z - a \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(t \cdot i - z \cdot c, b, \left(z \cdot y - a \cdot t\right) \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}\;j \le -5.804223743897768589296254303936316719646 \cdot 10^{-190}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(t \cdot i - z \cdot c, b, \left(z \cdot y - a \cdot t\right) \cdot x\right)\right)\\

\mathbf{elif}\;j \le 1.189265720085326010143100313739170225725 \cdot 10^{-261}:\\
\;\;\;\;\left(y \cdot x - c \cdot b\right) \cdot z - a \cdot \left(x \cdot t\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(t \cdot i - z \cdot c, b, \left(z \cdot y - a \cdot t\right) \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 r38220882 = x;
        double r38220883 = y;
        double r38220884 = z;
        double r38220885 = r38220883 * r38220884;
        double r38220886 = t;
        double r38220887 = a;
        double r38220888 = r38220886 * r38220887;
        double r38220889 = r38220885 - r38220888;
        double r38220890 = r38220882 * r38220889;
        double r38220891 = b;
        double r38220892 = c;
        double r38220893 = r38220892 * r38220884;
        double r38220894 = i;
        double r38220895 = r38220886 * r38220894;
        double r38220896 = r38220893 - r38220895;
        double r38220897 = r38220891 * r38220896;
        double r38220898 = r38220890 - r38220897;
        double r38220899 = j;
        double r38220900 = r38220892 * r38220887;
        double r38220901 = r38220883 * r38220894;
        double r38220902 = r38220900 - r38220901;
        double r38220903 = r38220899 * r38220902;
        double r38220904 = r38220898 + r38220903;
        return r38220904;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r38220905 = j;
        double r38220906 = -5.804223743897769e-190;
        bool r38220907 = r38220905 <= r38220906;
        double r38220908 = a;
        double r38220909 = c;
        double r38220910 = r38220908 * r38220909;
        double r38220911 = i;
        double r38220912 = y;
        double r38220913 = r38220911 * r38220912;
        double r38220914 = r38220910 - r38220913;
        double r38220915 = t;
        double r38220916 = r38220915 * r38220911;
        double r38220917 = z;
        double r38220918 = r38220917 * r38220909;
        double r38220919 = r38220916 - r38220918;
        double r38220920 = b;
        double r38220921 = r38220917 * r38220912;
        double r38220922 = r38220908 * r38220915;
        double r38220923 = r38220921 - r38220922;
        double r38220924 = x;
        double r38220925 = r38220923 * r38220924;
        double r38220926 = fma(r38220919, r38220920, r38220925);
        double r38220927 = fma(r38220914, r38220905, r38220926);
        double r38220928 = 1.189265720085326e-261;
        bool r38220929 = r38220905 <= r38220928;
        double r38220930 = r38220912 * r38220924;
        double r38220931 = r38220909 * r38220920;
        double r38220932 = r38220930 - r38220931;
        double r38220933 = r38220932 * r38220917;
        double r38220934 = r38220924 * r38220915;
        double r38220935 = r38220908 * r38220934;
        double r38220936 = r38220933 - r38220935;
        double r38220937 = r38220929 ? r38220936 : r38220927;
        double r38220938 = r38220907 ? r38220927 : r38220937;
        return r38220938;
}

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.1
Herbie13.7
\[\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 j < -5.804223743897769e-190 or 1.189265720085326e-261 < j

    1. Initial program 10.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. Simplified10.8

      \[\leadsto \color{blue}{\mathsf{fma}\left(c \cdot a - 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)}\]

    if -5.804223743897769e-190 < j < 1.189265720085326e-261

    1. Initial program 17.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. Simplified17.4

      \[\leadsto \color{blue}{\mathsf{fma}\left(c \cdot a - 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. Using strategy rm
    4. Applied add-cube-cbrt17.8

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

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

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

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

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

Reproduce

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