Average Error: 11.9 → 12.4
Time: 33.7s
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}\;i \le -9919155923009514491873857448900123076592000:\\ \;\;\;\;\left(t \cdot b - y \cdot j\right) \cdot i - z \cdot \left(b \cdot c\right)\\ \mathbf{elif}\;i \le 1.811536772336407698591525860849815078578 \cdot 10^{140}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - y \cdot i, j, \mathsf{fma}\left(t \cdot i - z \cdot c, b, \sqrt[3]{x} \cdot \left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(z \cdot y - t \cdot a\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t \cdot b - y \cdot j\right) \cdot i - z \cdot \left(b \cdot c\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}\;i \le -9919155923009514491873857448900123076592000:\\
\;\;\;\;\left(t \cdot b - y \cdot j\right) \cdot i - z \cdot \left(b \cdot c\right)\\

\mathbf{elif}\;i \le 1.811536772336407698591525860849815078578 \cdot 10^{140}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot c - y \cdot i, j, \mathsf{fma}\left(t \cdot i - z \cdot c, b, \sqrt[3]{x} \cdot \left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(z \cdot y - t \cdot a\right)\right)\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r34844826 = x;
        double r34844827 = y;
        double r34844828 = z;
        double r34844829 = r34844827 * r34844828;
        double r34844830 = t;
        double r34844831 = a;
        double r34844832 = r34844830 * r34844831;
        double r34844833 = r34844829 - r34844832;
        double r34844834 = r34844826 * r34844833;
        double r34844835 = b;
        double r34844836 = c;
        double r34844837 = r34844836 * r34844828;
        double r34844838 = i;
        double r34844839 = r34844830 * r34844838;
        double r34844840 = r34844837 - r34844839;
        double r34844841 = r34844835 * r34844840;
        double r34844842 = r34844834 - r34844841;
        double r34844843 = j;
        double r34844844 = r34844836 * r34844831;
        double r34844845 = r34844827 * r34844838;
        double r34844846 = r34844844 - r34844845;
        double r34844847 = r34844843 * r34844846;
        double r34844848 = r34844842 + r34844847;
        return r34844848;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r34844849 = i;
        double r34844850 = -9.919155923009514e+42;
        bool r34844851 = r34844849 <= r34844850;
        double r34844852 = t;
        double r34844853 = b;
        double r34844854 = r34844852 * r34844853;
        double r34844855 = y;
        double r34844856 = j;
        double r34844857 = r34844855 * r34844856;
        double r34844858 = r34844854 - r34844857;
        double r34844859 = r34844858 * r34844849;
        double r34844860 = z;
        double r34844861 = c;
        double r34844862 = r34844853 * r34844861;
        double r34844863 = r34844860 * r34844862;
        double r34844864 = r34844859 - r34844863;
        double r34844865 = 1.8115367723364077e+140;
        bool r34844866 = r34844849 <= r34844865;
        double r34844867 = a;
        double r34844868 = r34844867 * r34844861;
        double r34844869 = r34844855 * r34844849;
        double r34844870 = r34844868 - r34844869;
        double r34844871 = r34844852 * r34844849;
        double r34844872 = r34844860 * r34844861;
        double r34844873 = r34844871 - r34844872;
        double r34844874 = x;
        double r34844875 = cbrt(r34844874);
        double r34844876 = r34844875 * r34844875;
        double r34844877 = r34844860 * r34844855;
        double r34844878 = r34844852 * r34844867;
        double r34844879 = r34844877 - r34844878;
        double r34844880 = r34844876 * r34844879;
        double r34844881 = r34844875 * r34844880;
        double r34844882 = fma(r34844873, r34844853, r34844881);
        double r34844883 = fma(r34844870, r34844856, r34844882);
        double r34844884 = r34844866 ? r34844883 : r34844864;
        double r34844885 = r34844851 ? r34844864 : r34844884;
        return r34844885;
}

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.9
Target19.7
Herbie12.4
\[\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 i < -9.919155923009514e+42 or 1.8115367723364077e+140 < i

    1. Initial program 19.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. Simplified19.7

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

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

      \[\leadsto \color{blue}{t \cdot \left(i \cdot b\right) - \left(z \cdot \left(b \cdot c\right) + i \cdot \left(j \cdot y\right)\right)}\]
    5. Simplified20.9

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

    if -9.919155923009514e+42 < i < 1.8115367723364077e+140

    1. Initial program 9.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. Simplified9.4

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

      \[\leadsto \mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(i \cdot t - z \cdot c, b, \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.7

      \[\leadsto \mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(i \cdot t - z \cdot c, b, \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)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification12.4

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

Reproduce

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