Average Error: 11.9 → 12.4
Time: 31.5s
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 r40908071 = x;
        double r40908072 = y;
        double r40908073 = z;
        double r40908074 = r40908072 * r40908073;
        double r40908075 = t;
        double r40908076 = a;
        double r40908077 = r40908075 * r40908076;
        double r40908078 = r40908074 - r40908077;
        double r40908079 = r40908071 * r40908078;
        double r40908080 = b;
        double r40908081 = c;
        double r40908082 = r40908081 * r40908073;
        double r40908083 = i;
        double r40908084 = r40908075 * r40908083;
        double r40908085 = r40908082 - r40908084;
        double r40908086 = r40908080 * r40908085;
        double r40908087 = r40908079 - r40908086;
        double r40908088 = j;
        double r40908089 = r40908081 * r40908076;
        double r40908090 = r40908072 * r40908083;
        double r40908091 = r40908089 - r40908090;
        double r40908092 = r40908088 * r40908091;
        double r40908093 = r40908087 + r40908092;
        return r40908093;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r40908094 = i;
        double r40908095 = -9.919155923009514e+42;
        bool r40908096 = r40908094 <= r40908095;
        double r40908097 = t;
        double r40908098 = b;
        double r40908099 = r40908097 * r40908098;
        double r40908100 = y;
        double r40908101 = j;
        double r40908102 = r40908100 * r40908101;
        double r40908103 = r40908099 - r40908102;
        double r40908104 = r40908103 * r40908094;
        double r40908105 = z;
        double r40908106 = c;
        double r40908107 = r40908098 * r40908106;
        double r40908108 = r40908105 * r40908107;
        double r40908109 = r40908104 - r40908108;
        double r40908110 = 1.8115367723364077e+140;
        bool r40908111 = r40908094 <= r40908110;
        double r40908112 = a;
        double r40908113 = r40908112 * r40908106;
        double r40908114 = r40908100 * r40908094;
        double r40908115 = r40908113 - r40908114;
        double r40908116 = r40908097 * r40908094;
        double r40908117 = r40908105 * r40908106;
        double r40908118 = r40908116 - r40908117;
        double r40908119 = x;
        double r40908120 = cbrt(r40908119);
        double r40908121 = r40908120 * r40908120;
        double r40908122 = r40908105 * r40908100;
        double r40908123 = r40908097 * r40908112;
        double r40908124 = r40908122 - r40908123;
        double r40908125 = r40908121 * r40908124;
        double r40908126 = r40908120 * r40908125;
        double r40908127 = fma(r40908118, r40908098, r40908126);
        double r40908128 = fma(r40908115, r40908101, r40908127);
        double r40908129 = r40908111 ? r40908128 : r40908109;
        double r40908130 = r40908096 ? r40908109 : r40908129;
        return r40908130;
}

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