Average Error: 12.3 → 13.5
Time: 11.2s
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}\;i \le -2.7850060019532971 \cdot 10^{104} \lor \neg \left(i \le -1.19729850374981135 \cdot 10^{51}\right):\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \left(\sqrt[3]{y \cdot z - t \cdot a} \cdot \sqrt[3]{y \cdot z - t \cdot a}\right)\right) \cdot \sqrt[3]{y \cdot z - t \cdot a} - b \cdot \left(c \cdot z - t \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t, i \cdot b, -\mathsf{fma}\left(z, b \cdot c, t \cdot \left(x \cdot a\right)\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}\;i \le -2.7850060019532971 \cdot 10^{104} \lor \neg \left(i \le -1.19729850374981135 \cdot 10^{51}\right):\\
\;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \left(\sqrt[3]{y \cdot z - t \cdot a} \cdot \sqrt[3]{y \cdot z - t \cdot a}\right)\right) \cdot \sqrt[3]{y \cdot z - t \cdot a} - b \cdot \left(c \cdot z - t \cdot i\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, i \cdot b, -\mathsf{fma}\left(z, b \cdot c, t \cdot \left(x \cdot a\right)\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 r894303 = x;
        double r894304 = y;
        double r894305 = z;
        double r894306 = r894304 * r894305;
        double r894307 = t;
        double r894308 = a;
        double r894309 = r894307 * r894308;
        double r894310 = r894306 - r894309;
        double r894311 = r894303 * r894310;
        double r894312 = b;
        double r894313 = c;
        double r894314 = r894313 * r894305;
        double r894315 = i;
        double r894316 = r894307 * r894315;
        double r894317 = r894314 - r894316;
        double r894318 = r894312 * r894317;
        double r894319 = r894311 - r894318;
        double r894320 = j;
        double r894321 = r894313 * r894308;
        double r894322 = r894304 * r894315;
        double r894323 = r894321 - r894322;
        double r894324 = r894320 * r894323;
        double r894325 = r894319 + r894324;
        return r894325;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r894326 = i;
        double r894327 = -2.785006001953297e+104;
        bool r894328 = r894326 <= r894327;
        double r894329 = -1.1972985037498114e+51;
        bool r894330 = r894326 <= r894329;
        double r894331 = !r894330;
        bool r894332 = r894328 || r894331;
        double r894333 = c;
        double r894334 = a;
        double r894335 = r894333 * r894334;
        double r894336 = y;
        double r894337 = r894336 * r894326;
        double r894338 = r894335 - r894337;
        double r894339 = j;
        double r894340 = x;
        double r894341 = z;
        double r894342 = r894336 * r894341;
        double r894343 = t;
        double r894344 = r894343 * r894334;
        double r894345 = r894342 - r894344;
        double r894346 = cbrt(r894345);
        double r894347 = r894346 * r894346;
        double r894348 = r894340 * r894347;
        double r894349 = r894348 * r894346;
        double r894350 = b;
        double r894351 = r894333 * r894341;
        double r894352 = r894343 * r894326;
        double r894353 = r894351 - r894352;
        double r894354 = r894350 * r894353;
        double r894355 = r894349 - r894354;
        double r894356 = fma(r894338, r894339, r894355);
        double r894357 = r894326 * r894350;
        double r894358 = r894350 * r894333;
        double r894359 = r894340 * r894334;
        double r894360 = r894343 * r894359;
        double r894361 = fma(r894341, r894358, r894360);
        double r894362 = -r894361;
        double r894363 = fma(r894343, r894357, r894362);
        double r894364 = r894332 ? r894356 : r894363;
        return r894364;
}

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.3
Target19.7
Herbie13.5
\[\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 i < -2.785006001953297e+104 or -1.1972985037498114e+51 < i

    1. Initial program 12.3

      \[\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. Simplified12.3

      \[\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 add-cube-cbrt12.6

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

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

    if -2.785006001953297e+104 < i < -1.1972985037498114e+51

    1. Initial program 12.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. Simplified12.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. Taylor expanded around inf 35.2

      \[\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)}\]
    4. Simplified35.2

      \[\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)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification13.5

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

Reproduce

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