Average Error: 11.8 → 10.9
Time: 9.9s
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}\;z \le -1.0716846611179825 \cdot 10^{-48} \lor \neg \left(z \le 1.1914660913943379 \cdot 10^{-4}\right):\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(\left(x \cdot y\right) \cdot z + x \cdot \left(-t \cdot a\right)\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \left(y \cdot z\right) + \left(x \cdot \left(-t\right)\right) \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}\;z \le -1.0716846611179825 \cdot 10^{-48} \lor \neg \left(z \le 1.1914660913943379 \cdot 10^{-4}\right):\\
\;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(\left(x \cdot y\right) \cdot z + x \cdot \left(-t \cdot a\right)\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \left(y \cdot z\right) + \left(x \cdot \left(-t\right)\right) \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 r803238 = x;
        double r803239 = y;
        double r803240 = z;
        double r803241 = r803239 * r803240;
        double r803242 = t;
        double r803243 = a;
        double r803244 = r803242 * r803243;
        double r803245 = r803241 - r803244;
        double r803246 = r803238 * r803245;
        double r803247 = b;
        double r803248 = c;
        double r803249 = r803248 * r803240;
        double r803250 = i;
        double r803251 = r803242 * r803250;
        double r803252 = r803249 - r803251;
        double r803253 = r803247 * r803252;
        double r803254 = r803246 - r803253;
        double r803255 = j;
        double r803256 = r803248 * r803243;
        double r803257 = r803239 * r803250;
        double r803258 = r803256 - r803257;
        double r803259 = r803255 * r803258;
        double r803260 = r803254 + r803259;
        return r803260;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r803261 = z;
        double r803262 = -1.0716846611179825e-48;
        bool r803263 = r803261 <= r803262;
        double r803264 = 0.00011914660913943379;
        bool r803265 = r803261 <= r803264;
        double r803266 = !r803265;
        bool r803267 = r803263 || r803266;
        double r803268 = c;
        double r803269 = a;
        double r803270 = r803268 * r803269;
        double r803271 = y;
        double r803272 = i;
        double r803273 = r803271 * r803272;
        double r803274 = r803270 - r803273;
        double r803275 = j;
        double r803276 = x;
        double r803277 = r803276 * r803271;
        double r803278 = r803277 * r803261;
        double r803279 = t;
        double r803280 = r803279 * r803269;
        double r803281 = -r803280;
        double r803282 = r803276 * r803281;
        double r803283 = r803278 + r803282;
        double r803284 = b;
        double r803285 = r803268 * r803261;
        double r803286 = r803279 * r803272;
        double r803287 = r803285 - r803286;
        double r803288 = r803284 * r803287;
        double r803289 = r803283 - r803288;
        double r803290 = fma(r803274, r803275, r803289);
        double r803291 = r803271 * r803261;
        double r803292 = r803276 * r803291;
        double r803293 = -r803279;
        double r803294 = r803276 * r803293;
        double r803295 = r803294 * r803269;
        double r803296 = r803292 + r803295;
        double r803297 = r803296 - r803288;
        double r803298 = fma(r803274, r803275, r803297);
        double r803299 = r803267 ? r803290 : r803298;
        return r803299;
}

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

Original11.8
Target19.4
Herbie10.9
\[\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 z < -1.0716846611179825e-48 or 0.00011914660913943379 < z

    1. Initial program 15.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. Simplified15.4

      \[\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-neg15.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)} - b \cdot \left(c \cdot z - t \cdot i\right)\right)\]
    5. Applied distribute-lft-in15.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)} - b \cdot \left(c \cdot z - t \cdot i\right)\right)\]
    6. Using strategy rm
    7. Applied associate-*r*12.2

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

    if -1.0716846611179825e-48 < z < 0.00011914660913943379

    1. Initial program 9.0

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

      \[\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)} - b \cdot \left(c \cdot z - t \cdot i\right)\right)\]
    5. Applied distribute-lft-in8.9

      \[\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)} - b \cdot \left(c \cdot z - t \cdot i\right)\right)\]
    6. Using strategy rm
    7. Applied distribute-lft-neg-in8.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \le -1.0716846611179825 \cdot 10^{-48} \lor \neg \left(z \le 1.1914660913943379 \cdot 10^{-4}\right):\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(\left(x \cdot y\right) \cdot z + x \cdot \left(-t \cdot a\right)\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \left(y \cdot z\right) + \left(x \cdot \left(-t\right)\right) \cdot a\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right)\\ \end{array}\]

Reproduce

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