Average Error: 12.1 → 9.7
Time: 27.1s
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}\;j \le -1.303098831762134774021732738153237904474 \cdot 10^{-76} \lor \neg \left(j \le 1.092190329886576907216225913468931561763 \cdot 10^{-126}\right):\\ \;\;\;\;\left(x \cdot \left(z \cdot y\right) - a \cdot \left(x \cdot t\right)\right) + \mathsf{fma}\left(b, t \cdot i - c \cdot z, j \cdot \left(c \cdot a - y \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\left(z \cdot y\right) \cdot \sqrt[3]{x} + \left(-t\right) \cdot \left(a \cdot \sqrt[3]{x}\right)\right) + \mathsf{fma}\left(b, t \cdot i - c \cdot z, a \cdot \left(j \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}\;j \le -1.303098831762134774021732738153237904474 \cdot 10^{-76} \lor \neg \left(j \le 1.092190329886576907216225913468931561763 \cdot 10^{-126}\right):\\
\;\;\;\;\left(x \cdot \left(z \cdot y\right) - a \cdot \left(x \cdot t\right)\right) + \mathsf{fma}\left(b, t \cdot i - c \cdot z, j \cdot \left(c \cdot a - y \cdot i\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\left(z \cdot y\right) \cdot \sqrt[3]{x} + \left(-t\right) \cdot \left(a \cdot \sqrt[3]{x}\right)\right) + \mathsf{fma}\left(b, t \cdot i - c \cdot z, a \cdot \left(j \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 r628481 = x;
        double r628482 = y;
        double r628483 = z;
        double r628484 = r628482 * r628483;
        double r628485 = t;
        double r628486 = a;
        double r628487 = r628485 * r628486;
        double r628488 = r628484 - r628487;
        double r628489 = r628481 * r628488;
        double r628490 = b;
        double r628491 = c;
        double r628492 = r628491 * r628483;
        double r628493 = i;
        double r628494 = r628485 * r628493;
        double r628495 = r628492 - r628494;
        double r628496 = r628490 * r628495;
        double r628497 = r628489 - r628496;
        double r628498 = j;
        double r628499 = r628491 * r628486;
        double r628500 = r628482 * r628493;
        double r628501 = r628499 - r628500;
        double r628502 = r628498 * r628501;
        double r628503 = r628497 + r628502;
        return r628503;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r628504 = j;
        double r628505 = -1.3030988317621348e-76;
        bool r628506 = r628504 <= r628505;
        double r628507 = 1.0921903298865769e-126;
        bool r628508 = r628504 <= r628507;
        double r628509 = !r628508;
        bool r628510 = r628506 || r628509;
        double r628511 = x;
        double r628512 = z;
        double r628513 = y;
        double r628514 = r628512 * r628513;
        double r628515 = r628511 * r628514;
        double r628516 = a;
        double r628517 = t;
        double r628518 = r628511 * r628517;
        double r628519 = r628516 * r628518;
        double r628520 = r628515 - r628519;
        double r628521 = b;
        double r628522 = i;
        double r628523 = r628517 * r628522;
        double r628524 = c;
        double r628525 = r628524 * r628512;
        double r628526 = r628523 - r628525;
        double r628527 = r628524 * r628516;
        double r628528 = r628513 * r628522;
        double r628529 = r628527 - r628528;
        double r628530 = r628504 * r628529;
        double r628531 = fma(r628521, r628526, r628530);
        double r628532 = r628520 + r628531;
        double r628533 = cbrt(r628511);
        double r628534 = r628533 * r628533;
        double r628535 = r628514 * r628533;
        double r628536 = -r628517;
        double r628537 = r628516 * r628533;
        double r628538 = r628536 * r628537;
        double r628539 = r628535 + r628538;
        double r628540 = r628534 * r628539;
        double r628541 = r628504 * r628524;
        double r628542 = r628516 * r628541;
        double r628543 = r628513 * r628504;
        double r628544 = r628522 * r628543;
        double r628545 = r628542 - r628544;
        double r628546 = fma(r628521, r628526, r628545);
        double r628547 = r628540 + r628546;
        double r628548 = r628510 ? r628532 : r628547;
        return r628548;
}

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
Target20.2
Herbie9.7
\[\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 j < -1.3030988317621348e-76 or 1.0921903298865769e-126 < j

    1. Initial program 8.5

      \[\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. Simplified8.5

      \[\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 fma-udef8.5

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

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

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

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

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

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

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

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

    if -1.3030988317621348e-76 < j < 1.0921903298865769e-126

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

      \[\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 fma-udef17.2

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

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

      \[\leadsto \color{blue}{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \left(\sqrt[3]{x} \cdot \left(y \cdot z - t \cdot a\right)\right)} + \mathsf{fma}\left(b, t \cdot i - c \cdot z, j \cdot \left(c \cdot a - y \cdot i\right)\right)\]
    8. Using strategy rm
    9. Applied sub-neg17.5

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

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

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

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

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

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

Reproduce

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