Average Error: 12.4 → 11.5
Time: 27.8s
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.515755108675819892129473490174029094849 \cdot 10^{-78} \lor \neg \left(b \le 8.867949959160817299629379804947925441887 \cdot 10^{-183}\right):\\ \;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, t \cdot i - c \cdot z, j \cdot \left(\left(\sqrt[3]{c \cdot a - y \cdot i} \cdot \sqrt[3]{c \cdot a - y \cdot i}\right) \cdot \sqrt[3]{c \cdot a - y \cdot i}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, \left(c \cdot \left(a \cdot j\right) + \left(-z \cdot b\right) \cdot c\right) - i \cdot \left(y \cdot j\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.515755108675819892129473490174029094849 \cdot 10^{-78} \lor \neg \left(b \le 8.867949959160817299629379804947925441887 \cdot 10^{-183}\right):\\
\;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, t \cdot i - c \cdot z, j \cdot \left(\left(\sqrt[3]{c \cdot a - y \cdot i} \cdot \sqrt[3]{c \cdot a - y \cdot i}\right) \cdot \sqrt[3]{c \cdot a - y \cdot i}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, \left(c \cdot \left(a \cdot j\right) + \left(-z \cdot b\right) \cdot c\right) - i \cdot \left(y \cdot j\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 r478437 = x;
        double r478438 = y;
        double r478439 = z;
        double r478440 = r478438 * r478439;
        double r478441 = t;
        double r478442 = a;
        double r478443 = r478441 * r478442;
        double r478444 = r478440 - r478443;
        double r478445 = r478437 * r478444;
        double r478446 = b;
        double r478447 = c;
        double r478448 = r478447 * r478439;
        double r478449 = i;
        double r478450 = r478441 * r478449;
        double r478451 = r478448 - r478450;
        double r478452 = r478446 * r478451;
        double r478453 = r478445 - r478452;
        double r478454 = j;
        double r478455 = r478447 * r478442;
        double r478456 = r478438 * r478449;
        double r478457 = r478455 - r478456;
        double r478458 = r478454 * r478457;
        double r478459 = r478453 + r478458;
        return r478459;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r478460 = b;
        double r478461 = -2.51575510867582e-78;
        bool r478462 = r478460 <= r478461;
        double r478463 = 8.867949959160817e-183;
        bool r478464 = r478460 <= r478463;
        double r478465 = !r478464;
        bool r478466 = r478462 || r478465;
        double r478467 = x;
        double r478468 = y;
        double r478469 = z;
        double r478470 = r478468 * r478469;
        double r478471 = t;
        double r478472 = a;
        double r478473 = r478471 * r478472;
        double r478474 = r478470 - r478473;
        double r478475 = i;
        double r478476 = r478471 * r478475;
        double r478477 = c;
        double r478478 = r478477 * r478469;
        double r478479 = r478476 - r478478;
        double r478480 = j;
        double r478481 = r478477 * r478472;
        double r478482 = r478468 * r478475;
        double r478483 = r478481 - r478482;
        double r478484 = cbrt(r478483);
        double r478485 = r478484 * r478484;
        double r478486 = r478485 * r478484;
        double r478487 = r478480 * r478486;
        double r478488 = fma(r478460, r478479, r478487);
        double r478489 = fma(r478467, r478474, r478488);
        double r478490 = r478472 * r478480;
        double r478491 = r478477 * r478490;
        double r478492 = r478469 * r478460;
        double r478493 = -r478492;
        double r478494 = r478493 * r478477;
        double r478495 = r478491 + r478494;
        double r478496 = r478468 * r478480;
        double r478497 = r478475 * r478496;
        double r478498 = r478495 - r478497;
        double r478499 = fma(r478467, r478474, r478498);
        double r478500 = r478466 ? r478489 : r478499;
        return r478500;
}

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.4
Target19.4
Herbie11.5
\[\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.51575510867582e-78 or 8.867949959160817e-183 < b

    1. Initial program 10.1

      \[\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.1

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y \cdot z - t \cdot a, \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 add-cube-cbrt10.3

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

    if -2.51575510867582e-78 < b < 8.867949959160817e-183

    1. Initial program 16.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. Simplified16.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y \cdot z - t \cdot a, \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 add-cube-cbrt17.0

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

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

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

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

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

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

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

Reproduce

herbie shell --seed 2019304 +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.46969429677770502e-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)))))