Average Error: 12.0 → 10.4
Time: 12.7s
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 -1.32617007123305873 \cdot 10^{157}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, 0 - \left(b \cdot \left(c \cdot z\right) + b \cdot \left(-t \cdot i\right)\right)\right)\\ \mathbf{elif}\;b \le 2.0655648981193822 \cdot 10^{91}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \left(y \cdot z\right) + x \cdot \left(-t \cdot a\right)\right) - \left(\left(b \cdot c\right) \cdot z + \left(b \cdot \left(-t\right)\right) \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, x \cdot \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)\\ \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 -1.32617007123305873 \cdot 10^{157}:\\
\;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, 0 - \left(b \cdot \left(c \cdot z\right) + b \cdot \left(-t \cdot i\right)\right)\right)\\

\mathbf{elif}\;b \le 2.0655648981193822 \cdot 10^{91}:\\
\;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \left(y \cdot z\right) + x \cdot \left(-t \cdot a\right)\right) - \left(\left(b \cdot c\right) \cdot z + \left(b \cdot \left(-t\right)\right) \cdot i\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, x \cdot \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)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r791274 = x;
        double r791275 = y;
        double r791276 = z;
        double r791277 = r791275 * r791276;
        double r791278 = t;
        double r791279 = a;
        double r791280 = r791278 * r791279;
        double r791281 = r791277 - r791280;
        double r791282 = r791274 * r791281;
        double r791283 = b;
        double r791284 = c;
        double r791285 = r791284 * r791276;
        double r791286 = i;
        double r791287 = r791278 * r791286;
        double r791288 = r791285 - r791287;
        double r791289 = r791283 * r791288;
        double r791290 = r791282 - r791289;
        double r791291 = j;
        double r791292 = r791284 * r791279;
        double r791293 = r791275 * r791286;
        double r791294 = r791292 - r791293;
        double r791295 = r791291 * r791294;
        double r791296 = r791290 + r791295;
        return r791296;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r791297 = b;
        double r791298 = -1.3261700712330587e+157;
        bool r791299 = r791297 <= r791298;
        double r791300 = c;
        double r791301 = a;
        double r791302 = r791300 * r791301;
        double r791303 = y;
        double r791304 = i;
        double r791305 = r791303 * r791304;
        double r791306 = r791302 - r791305;
        double r791307 = j;
        double r791308 = 0.0;
        double r791309 = z;
        double r791310 = r791300 * r791309;
        double r791311 = r791297 * r791310;
        double r791312 = t;
        double r791313 = r791312 * r791304;
        double r791314 = -r791313;
        double r791315 = r791297 * r791314;
        double r791316 = r791311 + r791315;
        double r791317 = r791308 - r791316;
        double r791318 = fma(r791306, r791307, r791317);
        double r791319 = 2.0655648981193822e+91;
        bool r791320 = r791297 <= r791319;
        double r791321 = x;
        double r791322 = r791303 * r791309;
        double r791323 = r791321 * r791322;
        double r791324 = r791312 * r791301;
        double r791325 = -r791324;
        double r791326 = r791321 * r791325;
        double r791327 = r791323 + r791326;
        double r791328 = r791297 * r791300;
        double r791329 = r791328 * r791309;
        double r791330 = -r791312;
        double r791331 = r791297 * r791330;
        double r791332 = r791331 * r791304;
        double r791333 = r791329 + r791332;
        double r791334 = r791327 - r791333;
        double r791335 = fma(r791306, r791307, r791334);
        double r791336 = r791322 - r791324;
        double r791337 = cbrt(r791336);
        double r791338 = r791337 * r791337;
        double r791339 = r791338 * r791337;
        double r791340 = r791321 * r791339;
        double r791341 = r791310 - r791313;
        double r791342 = r791297 * r791341;
        double r791343 = r791340 - r791342;
        double r791344 = fma(r791306, r791307, r791343);
        double r791345 = r791320 ? r791335 : r791344;
        double r791346 = r791299 ? r791318 : r791345;
        return r791346;
}

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.6
Herbie10.4
\[\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 3 regimes
  2. if b < -1.3261700712330587e+157

    1. Initial program 5.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. Simplified5.8

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

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

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

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

    if -1.3261700712330587e+157 < b < 2.0655648981193822e+91

    1. Initial program 13.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. Simplified13.5

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(c \cdot a - y \cdot i, j, x \cdot \left(y \cdot z - t \cdot a\right) - \left(\left(b \cdot c\right) \cdot z + \color{blue}{\left(b \cdot \left(-t\right)\right) \cdot i}\right)\right)\]
    11. Using strategy rm
    12. Applied sub-neg10.4

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

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

    if 2.0655648981193822e+91 < b

    1. Initial program 6.9

      \[\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. Simplified6.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.32617007123305873 \cdot 10^{157}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, 0 - \left(b \cdot \left(c \cdot z\right) + b \cdot \left(-t \cdot i\right)\right)\right)\\ \mathbf{elif}\;b \le 2.0655648981193822 \cdot 10^{91}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \left(y \cdot z\right) + x \cdot \left(-t \cdot a\right)\right) - \left(\left(b \cdot c\right) \cdot z + \left(b \cdot \left(-t\right)\right) \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, x \cdot \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)\\ \end{array}\]

Reproduce

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