Average Error: 12.3 → 11.3
Time: 36.9s
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}\;b \le -2.672582041748256909997153343211822102454 \cdot 10^{-203}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot z - t \cdot a, x, \mathsf{fma}\left(b, t \cdot i - c \cdot z, \left(\mathsf{fma}\left(c, a, -i \cdot y\right) \cdot \left(\sqrt[3]{j} \cdot \sqrt[3]{j}\right)\right) \cdot \sqrt[3]{j} + j \cdot \mathsf{fma}\left(i, -y, i \cdot y\right)\right)\right)\\ \mathbf{elif}\;b \le 3.983997507038959873599105924463899118892 \cdot 10^{-138}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot z - t \cdot a, x, c \cdot \left(a \cdot j - z \cdot b\right) - i \cdot \left(j \cdot y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot z - t \cdot a, x, \mathsf{fma}\left(b, t \cdot i - c \cdot z, \left(\mathsf{fma}\left(c, a, -i \cdot y\right) \cdot \left(\sqrt[3]{j} \cdot \sqrt[3]{j}\right)\right) \cdot \sqrt[3]{j} + j \cdot \mathsf{fma}\left(i, -y, i \cdot y\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}\;b \le -2.672582041748256909997153343211822102454 \cdot 10^{-203}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z - t \cdot a, x, \mathsf{fma}\left(b, t \cdot i - c \cdot z, \left(\mathsf{fma}\left(c, a, -i \cdot y\right) \cdot \left(\sqrt[3]{j} \cdot \sqrt[3]{j}\right)\right) \cdot \sqrt[3]{j} + j \cdot \mathsf{fma}\left(i, -y, i \cdot y\right)\right)\right)\\

\mathbf{elif}\;b \le 3.983997507038959873599105924463899118892 \cdot 10^{-138}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z - t \cdot a, x, c \cdot \left(a \cdot j - z \cdot b\right) - i \cdot \left(j \cdot y\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot z - t \cdot a, x, \mathsf{fma}\left(b, t \cdot i - c \cdot z, \left(\mathsf{fma}\left(c, a, -i \cdot y\right) \cdot \left(\sqrt[3]{j} \cdot \sqrt[3]{j}\right)\right) \cdot \sqrt[3]{j} + j \cdot \mathsf{fma}\left(i, -y, i \cdot y\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 r56057058 = x;
        double r56057059 = y;
        double r56057060 = z;
        double r56057061 = r56057059 * r56057060;
        double r56057062 = t;
        double r56057063 = a;
        double r56057064 = r56057062 * r56057063;
        double r56057065 = r56057061 - r56057064;
        double r56057066 = r56057058 * r56057065;
        double r56057067 = b;
        double r56057068 = c;
        double r56057069 = r56057068 * r56057060;
        double r56057070 = i;
        double r56057071 = r56057062 * r56057070;
        double r56057072 = r56057069 - r56057071;
        double r56057073 = r56057067 * r56057072;
        double r56057074 = r56057066 - r56057073;
        double r56057075 = j;
        double r56057076 = r56057068 * r56057063;
        double r56057077 = r56057059 * r56057070;
        double r56057078 = r56057076 - r56057077;
        double r56057079 = r56057075 * r56057078;
        double r56057080 = r56057074 + r56057079;
        return r56057080;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r56057081 = b;
        double r56057082 = -2.672582041748257e-203;
        bool r56057083 = r56057081 <= r56057082;
        double r56057084 = y;
        double r56057085 = z;
        double r56057086 = r56057084 * r56057085;
        double r56057087 = t;
        double r56057088 = a;
        double r56057089 = r56057087 * r56057088;
        double r56057090 = r56057086 - r56057089;
        double r56057091 = x;
        double r56057092 = i;
        double r56057093 = r56057087 * r56057092;
        double r56057094 = c;
        double r56057095 = r56057094 * r56057085;
        double r56057096 = r56057093 - r56057095;
        double r56057097 = r56057092 * r56057084;
        double r56057098 = -r56057097;
        double r56057099 = fma(r56057094, r56057088, r56057098);
        double r56057100 = j;
        double r56057101 = cbrt(r56057100);
        double r56057102 = r56057101 * r56057101;
        double r56057103 = r56057099 * r56057102;
        double r56057104 = r56057103 * r56057101;
        double r56057105 = -r56057084;
        double r56057106 = fma(r56057092, r56057105, r56057097);
        double r56057107 = r56057100 * r56057106;
        double r56057108 = r56057104 + r56057107;
        double r56057109 = fma(r56057081, r56057096, r56057108);
        double r56057110 = fma(r56057090, r56057091, r56057109);
        double r56057111 = 3.98399750703896e-138;
        bool r56057112 = r56057081 <= r56057111;
        double r56057113 = r56057088 * r56057100;
        double r56057114 = r56057085 * r56057081;
        double r56057115 = r56057113 - r56057114;
        double r56057116 = r56057094 * r56057115;
        double r56057117 = r56057100 * r56057084;
        double r56057118 = r56057092 * r56057117;
        double r56057119 = r56057116 - r56057118;
        double r56057120 = fma(r56057090, r56057091, r56057119);
        double r56057121 = r56057112 ? r56057120 : r56057110;
        double r56057122 = r56057083 ? r56057110 : r56057121;
        return r56057122;
}

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.3
Target20.2
Herbie11.3
\[\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 b < -2.672582041748257e-203 or 3.98399750703896e-138 < b

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y \cdot z - t \cdot a, x, \mathsf{fma}\left(b, t \cdot i - c \cdot z, \color{blue}{\left(\mathsf{fma}\left(c, a, -i \cdot y\right) \cdot \left(\sqrt[3]{j} \cdot \sqrt[3]{j}\right)\right) \cdot \sqrt[3]{j}} + j \cdot \left(\left(-i \cdot y\right) + i \cdot y\right)\right)\right)\]
    10. Using strategy rm
    11. Applied distribute-rgt-neg-in10.5

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

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

    if -2.672582041748257e-203 < b < 3.98399750703896e-138

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

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

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

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

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

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

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

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

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

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

Reproduce

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