Average Error: 12.1 → 12.0
Time: 13.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}\;t \le -4.46443690225848144 \cdot 10^{111} \lor \neg \left(t \le 2.8850197795509696 \cdot 10^{190}\right):\\ \;\;\;\;\mathsf{fma}\left(t, i \cdot b, -\mathsf{fma}\left(z, b \cdot c, t \cdot \left(x \cdot a\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \left(y \cdot z - t \cdot a\right) - \left(\sqrt[3]{\mathsf{fma}\left(c, z, -i \cdot t\right)} \cdot \sqrt[3]{\mathsf{fma}\left(c, z, -i \cdot t\right)}\right) \cdot \left(\sqrt[3]{\mathsf{fma}\left(c, z, -i \cdot t\right)} \cdot b\right)\right) - \mathsf{fma}\left(-i, t, i \cdot t\right) \cdot b\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}\;t \le -4.46443690225848144 \cdot 10^{111} \lor \neg \left(t \le 2.8850197795509696 \cdot 10^{190}\right):\\
\;\;\;\;\mathsf{fma}\left(t, i \cdot b, -\mathsf{fma}\left(z, b \cdot c, t \cdot \left(x \cdot a\right)\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r1015395 = x;
        double r1015396 = y;
        double r1015397 = z;
        double r1015398 = r1015396 * r1015397;
        double r1015399 = t;
        double r1015400 = a;
        double r1015401 = r1015399 * r1015400;
        double r1015402 = r1015398 - r1015401;
        double r1015403 = r1015395 * r1015402;
        double r1015404 = b;
        double r1015405 = c;
        double r1015406 = r1015405 * r1015397;
        double r1015407 = i;
        double r1015408 = r1015399 * r1015407;
        double r1015409 = r1015406 - r1015408;
        double r1015410 = r1015404 * r1015409;
        double r1015411 = r1015403 - r1015410;
        double r1015412 = j;
        double r1015413 = r1015405 * r1015400;
        double r1015414 = r1015396 * r1015407;
        double r1015415 = r1015413 - r1015414;
        double r1015416 = r1015412 * r1015415;
        double r1015417 = r1015411 + r1015416;
        return r1015417;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r1015418 = t;
        double r1015419 = -4.4644369022584814e+111;
        bool r1015420 = r1015418 <= r1015419;
        double r1015421 = 2.8850197795509696e+190;
        bool r1015422 = r1015418 <= r1015421;
        double r1015423 = !r1015422;
        bool r1015424 = r1015420 || r1015423;
        double r1015425 = i;
        double r1015426 = b;
        double r1015427 = r1015425 * r1015426;
        double r1015428 = z;
        double r1015429 = c;
        double r1015430 = r1015426 * r1015429;
        double r1015431 = x;
        double r1015432 = a;
        double r1015433 = r1015431 * r1015432;
        double r1015434 = r1015418 * r1015433;
        double r1015435 = fma(r1015428, r1015430, r1015434);
        double r1015436 = -r1015435;
        double r1015437 = fma(r1015418, r1015427, r1015436);
        double r1015438 = r1015429 * r1015432;
        double r1015439 = y;
        double r1015440 = r1015439 * r1015425;
        double r1015441 = r1015438 - r1015440;
        double r1015442 = j;
        double r1015443 = r1015439 * r1015428;
        double r1015444 = r1015418 * r1015432;
        double r1015445 = r1015443 - r1015444;
        double r1015446 = r1015431 * r1015445;
        double r1015447 = r1015425 * r1015418;
        double r1015448 = -r1015447;
        double r1015449 = fma(r1015429, r1015428, r1015448);
        double r1015450 = cbrt(r1015449);
        double r1015451 = r1015450 * r1015450;
        double r1015452 = r1015450 * r1015426;
        double r1015453 = r1015451 * r1015452;
        double r1015454 = r1015446 - r1015453;
        double r1015455 = -r1015425;
        double r1015456 = fma(r1015455, r1015418, r1015447);
        double r1015457 = r1015456 * r1015426;
        double r1015458 = r1015454 - r1015457;
        double r1015459 = fma(r1015441, r1015442, r1015458);
        double r1015460 = r1015424 ? r1015437 : r1015459;
        return r1015460;
}

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.1
Target19.6
Herbie12.0
\[\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 t < -4.4644369022584814e+111 or 2.8850197795509696e+190 < t

    1. Initial program 22.6

      \[\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. Simplified22.6

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

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

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

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

      \[\leadsto \color{blue}{t \cdot \left(i \cdot b\right) - \left(z \cdot \left(b \cdot c\right) + t \cdot \left(x \cdot a\right)\right)}\]
    8. Simplified20.1

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

    if -4.4644369022584814e+111 < t < 2.8850197795509696e+190

    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(c \cdot a - y \cdot i, j, x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right)}\]
    3. Using strategy rm
    4. Applied prod-diff10.2

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

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

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

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

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

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

Reproduce

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