Average Error: 12.0 → 10.8
Time: 24.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}\;c \le -2.314090246376279271128893343679862236911 \cdot 10^{173}:\\ \;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, c \cdot \left(a \cdot j - z \cdot b\right)\right)\\ \mathbf{elif}\;c \le 3.23880717934864300401777024633213551127 \cdot 10^{-25}:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, c \cdot \left(a \cdot j - z \cdot b\right) - \left(\sqrt[3]{i} \cdot \sqrt[3]{i}\right) \cdot \left(\left(\sqrt[3]{i} \cdot y\right) \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}\;c \le -2.314090246376279271128893343679862236911 \cdot 10^{173}:\\
\;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, c \cdot \left(a \cdot j - z \cdot b\right)\right)\\

\mathbf{elif}\;c \le 3.23880717934864300401777024633213551127 \cdot 10^{-25}:\\
\;\;\;\;\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)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, c \cdot \left(a \cdot j - z \cdot b\right) - \left(\sqrt[3]{i} \cdot \sqrt[3]{i}\right) \cdot \left(\left(\sqrt[3]{i} \cdot y\right) \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 r587514 = x;
        double r587515 = y;
        double r587516 = z;
        double r587517 = r587515 * r587516;
        double r587518 = t;
        double r587519 = a;
        double r587520 = r587518 * r587519;
        double r587521 = r587517 - r587520;
        double r587522 = r587514 * r587521;
        double r587523 = b;
        double r587524 = c;
        double r587525 = r587524 * r587516;
        double r587526 = i;
        double r587527 = r587518 * r587526;
        double r587528 = r587525 - r587527;
        double r587529 = r587523 * r587528;
        double r587530 = r587522 - r587529;
        double r587531 = j;
        double r587532 = r587524 * r587519;
        double r587533 = r587515 * r587526;
        double r587534 = r587532 - r587533;
        double r587535 = r587531 * r587534;
        double r587536 = r587530 + r587535;
        return r587536;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r587537 = c;
        double r587538 = -2.3140902463762793e+173;
        bool r587539 = r587537 <= r587538;
        double r587540 = x;
        double r587541 = y;
        double r587542 = z;
        double r587543 = r587541 * r587542;
        double r587544 = t;
        double r587545 = a;
        double r587546 = r587544 * r587545;
        double r587547 = r587543 - r587546;
        double r587548 = j;
        double r587549 = r587545 * r587548;
        double r587550 = b;
        double r587551 = r587542 * r587550;
        double r587552 = r587549 - r587551;
        double r587553 = r587537 * r587552;
        double r587554 = fma(r587540, r587547, r587553);
        double r587555 = 3.238807179348643e-25;
        bool r587556 = r587537 <= r587555;
        double r587557 = i;
        double r587558 = r587544 * r587557;
        double r587559 = r587537 * r587542;
        double r587560 = r587558 - r587559;
        double r587561 = r587537 * r587545;
        double r587562 = r587541 * r587557;
        double r587563 = r587561 - r587562;
        double r587564 = r587548 * r587563;
        double r587565 = fma(r587550, r587560, r587564);
        double r587566 = fma(r587540, r587547, r587565);
        double r587567 = cbrt(r587557);
        double r587568 = r587567 * r587567;
        double r587569 = r587567 * r587541;
        double r587570 = r587569 * r587548;
        double r587571 = r587568 * r587570;
        double r587572 = r587553 - r587571;
        double r587573 = fma(r587540, r587547, r587572);
        double r587574 = r587556 ? r587566 : r587573;
        double r587575 = r587539 ? r587554 : r587574;
        return r587575;
}

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.0
Target19.0
Herbie10.8
\[\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 3 regimes
  2. if c < -2.3140902463762793e+173

    1. Initial program 24.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. Simplified24.4

      \[\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. Taylor expanded around inf 26.7

      \[\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)\]
    4. Simplified11.1

      \[\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)\]
    5. Taylor expanded around 0 15.0

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

    if -2.3140902463762793e+173 < c < 3.238807179348643e-25

    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(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)}\]

    if 3.238807179348643e-25 < c

    1. Initial program 14.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. Simplified14.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. Taylor expanded around inf 20.3

      \[\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)\]
    4. Simplified12.1

      \[\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)\]
    5. Using strategy rm
    6. Applied add-cube-cbrt12.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \le -2.314090246376279271128893343679862236911 \cdot 10^{173}:\\ \;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, c \cdot \left(a \cdot j - z \cdot b\right)\right)\\ \mathbf{elif}\;c \le 3.23880717934864300401777024633213551127 \cdot 10^{-25}:\\ \;\;\;\;\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)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, c \cdot \left(a \cdot j - z \cdot b\right) - \left(\sqrt[3]{i} \cdot \sqrt[3]{i}\right) \cdot \left(\left(\sqrt[3]{i} \cdot y\right) \cdot j\right)\right)\\ \end{array}\]

Reproduce

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