Average Error: 12.0 → 13.7
Time: 2.2m
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 -5.804223743897768589296254303936316719646 \cdot 10^{-190}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(t \cdot i - z \cdot c, b, \left(z \cdot y - a \cdot t\right) \cdot x\right)\right)\\ \mathbf{elif}\;j \le 1.189265720085326010143100313739170225725 \cdot 10^{-261}:\\ \;\;\;\;\left(y \cdot x - c \cdot b\right) \cdot z - a \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(t \cdot i - z \cdot c, b, \left(z \cdot y - a \cdot t\right) \cdot x\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 -5.804223743897768589296254303936316719646 \cdot 10^{-190}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(t \cdot i - z \cdot c, b, \left(z \cdot y - a \cdot t\right) \cdot x\right)\right)\\

\mathbf{elif}\;j \le 1.189265720085326010143100313739170225725 \cdot 10^{-261}:\\
\;\;\;\;\left(y \cdot x - c \cdot b\right) \cdot z - a \cdot \left(x \cdot t\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(t \cdot i - z \cdot c, b, \left(z \cdot y - a \cdot t\right) \cdot x\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 r21013458 = x;
        double r21013459 = y;
        double r21013460 = z;
        double r21013461 = r21013459 * r21013460;
        double r21013462 = t;
        double r21013463 = a;
        double r21013464 = r21013462 * r21013463;
        double r21013465 = r21013461 - r21013464;
        double r21013466 = r21013458 * r21013465;
        double r21013467 = b;
        double r21013468 = c;
        double r21013469 = r21013468 * r21013460;
        double r21013470 = i;
        double r21013471 = r21013462 * r21013470;
        double r21013472 = r21013469 - r21013471;
        double r21013473 = r21013467 * r21013472;
        double r21013474 = r21013466 - r21013473;
        double r21013475 = j;
        double r21013476 = r21013468 * r21013463;
        double r21013477 = r21013459 * r21013470;
        double r21013478 = r21013476 - r21013477;
        double r21013479 = r21013475 * r21013478;
        double r21013480 = r21013474 + r21013479;
        return r21013480;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r21013481 = j;
        double r21013482 = -5.804223743897769e-190;
        bool r21013483 = r21013481 <= r21013482;
        double r21013484 = a;
        double r21013485 = c;
        double r21013486 = r21013484 * r21013485;
        double r21013487 = i;
        double r21013488 = y;
        double r21013489 = r21013487 * r21013488;
        double r21013490 = r21013486 - r21013489;
        double r21013491 = t;
        double r21013492 = r21013491 * r21013487;
        double r21013493 = z;
        double r21013494 = r21013493 * r21013485;
        double r21013495 = r21013492 - r21013494;
        double r21013496 = b;
        double r21013497 = r21013493 * r21013488;
        double r21013498 = r21013484 * r21013491;
        double r21013499 = r21013497 - r21013498;
        double r21013500 = x;
        double r21013501 = r21013499 * r21013500;
        double r21013502 = fma(r21013495, r21013496, r21013501);
        double r21013503 = fma(r21013490, r21013481, r21013502);
        double r21013504 = 1.189265720085326e-261;
        bool r21013505 = r21013481 <= r21013504;
        double r21013506 = r21013488 * r21013500;
        double r21013507 = r21013485 * r21013496;
        double r21013508 = r21013506 - r21013507;
        double r21013509 = r21013508 * r21013493;
        double r21013510 = r21013500 * r21013491;
        double r21013511 = r21013484 * r21013510;
        double r21013512 = r21013509 - r21013511;
        double r21013513 = r21013505 ? r21013512 : r21013503;
        double r21013514 = r21013483 ? r21013503 : r21013513;
        return r21013514;
}

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.1
Herbie13.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 < -5.804223743897769e-190 or 1.189265720085326e-261 < j

    1. Initial program 10.8

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

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

    if -5.804223743897769e-190 < j < 1.189265720085326e-261

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(z \cdot y\right) - \left(z \cdot \left(b \cdot c\right) + t \cdot \left(x \cdot a\right)\right)}\]
    7. Simplified27.1

      \[\leadsto \color{blue}{z \cdot \left(x \cdot y - b \cdot c\right) - \left(x \cdot t\right) \cdot a}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification13.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;j \le -5.804223743897768589296254303936316719646 \cdot 10^{-190}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(t \cdot i - z \cdot c, b, \left(z \cdot y - a \cdot t\right) \cdot x\right)\right)\\ \mathbf{elif}\;j \le 1.189265720085326010143100313739170225725 \cdot 10^{-261}:\\ \;\;\;\;\left(y \cdot x - c \cdot b\right) \cdot z - a \cdot \left(x \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - i \cdot y, j, \mathsf{fma}\left(t \cdot i - z \cdot c, b, \left(z \cdot y - a \cdot t\right) \cdot x\right)\right)\\ \end{array}\]

Reproduce

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