Average Error: 12.0 → 11.6
Time: 27.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}\;t \le 1.82790134936837119 \cdot 10^{138}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \mathsf{fma}\left(y, z, -a \cdot t\right) + x \cdot \mathsf{fma}\left(-a, t, a \cdot t\right)\right) - \left(b \cdot \left(c \cdot z - t \cdot i\right) + b \cdot \mathsf{fma}\left(-i, t, i \cdot t\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \mathsf{fma}\left(t, i \cdot b, -\mathsf{fma}\left(z, b \cdot c, a \cdot \left(x \cdot t\right)\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}\;t \le 1.82790134936837119 \cdot 10^{138}:\\
\;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \left(x \cdot \mathsf{fma}\left(y, z, -a \cdot t\right) + x \cdot \mathsf{fma}\left(-a, t, a \cdot t\right)\right) - \left(b \cdot \left(c \cdot z - t \cdot i\right) + b \cdot \mathsf{fma}\left(-i, t, i \cdot t\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, \mathsf{fma}\left(t, i \cdot b, -\mathsf{fma}\left(z, b \cdot c, a \cdot \left(x \cdot t\right)\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 r1133102 = x;
        double r1133103 = y;
        double r1133104 = z;
        double r1133105 = r1133103 * r1133104;
        double r1133106 = t;
        double r1133107 = a;
        double r1133108 = r1133106 * r1133107;
        double r1133109 = r1133105 - r1133108;
        double r1133110 = r1133102 * r1133109;
        double r1133111 = b;
        double r1133112 = c;
        double r1133113 = r1133112 * r1133104;
        double r1133114 = i;
        double r1133115 = r1133106 * r1133114;
        double r1133116 = r1133113 - r1133115;
        double r1133117 = r1133111 * r1133116;
        double r1133118 = r1133110 - r1133117;
        double r1133119 = j;
        double r1133120 = r1133112 * r1133107;
        double r1133121 = r1133103 * r1133114;
        double r1133122 = r1133120 - r1133121;
        double r1133123 = r1133119 * r1133122;
        double r1133124 = r1133118 + r1133123;
        return r1133124;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r1133125 = t;
        double r1133126 = 1.8279013493683712e+138;
        bool r1133127 = r1133125 <= r1133126;
        double r1133128 = c;
        double r1133129 = a;
        double r1133130 = r1133128 * r1133129;
        double r1133131 = y;
        double r1133132 = i;
        double r1133133 = r1133131 * r1133132;
        double r1133134 = r1133130 - r1133133;
        double r1133135 = j;
        double r1133136 = x;
        double r1133137 = z;
        double r1133138 = r1133129 * r1133125;
        double r1133139 = -r1133138;
        double r1133140 = fma(r1133131, r1133137, r1133139);
        double r1133141 = r1133136 * r1133140;
        double r1133142 = -r1133129;
        double r1133143 = fma(r1133142, r1133125, r1133138);
        double r1133144 = r1133136 * r1133143;
        double r1133145 = r1133141 + r1133144;
        double r1133146 = b;
        double r1133147 = r1133128 * r1133137;
        double r1133148 = r1133125 * r1133132;
        double r1133149 = r1133147 - r1133148;
        double r1133150 = r1133146 * r1133149;
        double r1133151 = -r1133132;
        double r1133152 = r1133132 * r1133125;
        double r1133153 = fma(r1133151, r1133125, r1133152);
        double r1133154 = r1133146 * r1133153;
        double r1133155 = r1133150 + r1133154;
        double r1133156 = r1133145 - r1133155;
        double r1133157 = fma(r1133134, r1133135, r1133156);
        double r1133158 = r1133132 * r1133146;
        double r1133159 = r1133146 * r1133128;
        double r1133160 = r1133136 * r1133125;
        double r1133161 = r1133129 * r1133160;
        double r1133162 = fma(r1133137, r1133159, r1133161);
        double r1133163 = -r1133162;
        double r1133164 = fma(r1133125, r1133158, r1133163);
        double r1133165 = fma(r1133134, r1133135, r1133164);
        double r1133166 = r1133127 ? r1133157 : r1133165;
        return r1133166;
}

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
Target20.1
Herbie11.6
\[\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 t < 1.8279013493683712e+138

    1. Initial program 10.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. Simplified10.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 prod-diff10.9

      \[\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(\mathsf{fma}\left(c, z, -i \cdot t\right) + \mathsf{fma}\left(-i, t, i \cdot t\right)\right)}\right)\]
    5. Applied distribute-lft-in10.9

      \[\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 \mathsf{fma}\left(c, z, -i \cdot t\right) + b \cdot \mathsf{fma}\left(-i, t, i \cdot t\right)\right)}\right)\]
    6. Simplified10.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}{b \cdot \left(c \cdot z - t \cdot i\right)} + b \cdot \mathsf{fma}\left(-i, t, i \cdot t\right)\right)\right)\]
    7. Using strategy rm
    8. Applied prod-diff10.9

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

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

    if 1.8279013493683712e+138 < t

    1. Initial program 23.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. Simplified23.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. Taylor expanded around inf 19.0

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

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

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

Reproduce

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