Average Error: 11.7 → 11.9
Time: 10.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}\;x \le -9.6042623790340836 \cdot 10^{-142} \lor \neg \left(x \le 1.7474383666639108 \cdot 10^{-175}\right):\\ \;\;\;\;\left(\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) + \left(j \cdot \left(c \cdot a - y \cdot i\right) + j \cdot \mathsf{fma}\left(-i, y, i \cdot y\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 0 - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\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}\;x \le -9.6042623790340836 \cdot 10^{-142} \lor \neg \left(x \le 1.7474383666639108 \cdot 10^{-175}\right):\\
\;\;\;\;\left(\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) + \left(j \cdot \left(c \cdot a - y \cdot i\right) + j \cdot \mathsf{fma}\left(-i, y, i \cdot y\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot 0 - b \cdot \left(c \cdot z - t \cdot i\right)\right) + j \cdot \left(c \cdot a - y \cdot i\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r1024023 = x;
        double r1024024 = y;
        double r1024025 = z;
        double r1024026 = r1024024 * r1024025;
        double r1024027 = t;
        double r1024028 = a;
        double r1024029 = r1024027 * r1024028;
        double r1024030 = r1024026 - r1024029;
        double r1024031 = r1024023 * r1024030;
        double r1024032 = b;
        double r1024033 = c;
        double r1024034 = r1024033 * r1024025;
        double r1024035 = i;
        double r1024036 = r1024027 * r1024035;
        double r1024037 = r1024034 - r1024036;
        double r1024038 = r1024032 * r1024037;
        double r1024039 = r1024031 - r1024038;
        double r1024040 = j;
        double r1024041 = r1024033 * r1024028;
        double r1024042 = r1024024 * r1024035;
        double r1024043 = r1024041 - r1024042;
        double r1024044 = r1024040 * r1024043;
        double r1024045 = r1024039 + r1024044;
        return r1024045;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r1024046 = x;
        double r1024047 = -9.604262379034084e-142;
        bool r1024048 = r1024046 <= r1024047;
        double r1024049 = 1.7474383666639108e-175;
        bool r1024050 = r1024046 <= r1024049;
        double r1024051 = !r1024050;
        bool r1024052 = r1024048 || r1024051;
        double r1024053 = y;
        double r1024054 = z;
        double r1024055 = a;
        double r1024056 = t;
        double r1024057 = r1024055 * r1024056;
        double r1024058 = -r1024057;
        double r1024059 = fma(r1024053, r1024054, r1024058);
        double r1024060 = r1024046 * r1024059;
        double r1024061 = -r1024055;
        double r1024062 = fma(r1024061, r1024056, r1024057);
        double r1024063 = r1024046 * r1024062;
        double r1024064 = r1024060 + r1024063;
        double r1024065 = b;
        double r1024066 = c;
        double r1024067 = r1024066 * r1024054;
        double r1024068 = i;
        double r1024069 = r1024056 * r1024068;
        double r1024070 = r1024067 - r1024069;
        double r1024071 = r1024065 * r1024070;
        double r1024072 = -r1024068;
        double r1024073 = r1024068 * r1024056;
        double r1024074 = fma(r1024072, r1024056, r1024073);
        double r1024075 = r1024065 * r1024074;
        double r1024076 = r1024071 + r1024075;
        double r1024077 = r1024064 - r1024076;
        double r1024078 = j;
        double r1024079 = r1024066 * r1024055;
        double r1024080 = r1024053 * r1024068;
        double r1024081 = r1024079 - r1024080;
        double r1024082 = r1024078 * r1024081;
        double r1024083 = r1024068 * r1024053;
        double r1024084 = fma(r1024072, r1024053, r1024083);
        double r1024085 = r1024078 * r1024084;
        double r1024086 = r1024082 + r1024085;
        double r1024087 = r1024077 + r1024086;
        double r1024088 = 0.0;
        double r1024089 = r1024046 * r1024088;
        double r1024090 = r1024089 - r1024071;
        double r1024091 = r1024090 + r1024082;
        double r1024092 = r1024052 ? r1024087 : r1024091;
        return r1024092;
}

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.7
Target19.0
Herbie11.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 x < -9.604262379034084e-142 or 1.7474383666639108e-175 < x

    1. Initial program 9.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. Using strategy rm
    3. Applied prod-diff9.4

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

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

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

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

      \[\leadsto \left(\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)} - b \cdot \left(c \cdot z - t \cdot i\right)\right) + \left(j \cdot \left(c \cdot a - y \cdot i\right) + j \cdot \mathsf{fma}\left(-i, y, i \cdot y\right)\right)\]
    9. Using strategy rm
    10. Applied prod-diff9.4

      \[\leadsto \left(\left(x \cdot \mathsf{fma}\left(y, z, -a \cdot t\right) + x \cdot \mathsf{fma}\left(-a, t, a \cdot t\right)\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) + \left(j \cdot \left(c \cdot a - y \cdot i\right) + j \cdot \mathsf{fma}\left(-i, y, i \cdot y\right)\right)\]
    11. Applied distribute-lft-in9.4

      \[\leadsto \left(\left(x \cdot \mathsf{fma}\left(y, z, -a \cdot t\right) + x \cdot \mathsf{fma}\left(-a, t, a \cdot t\right)\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) + \left(j \cdot \left(c \cdot a - y \cdot i\right) + j \cdot \mathsf{fma}\left(-i, y, i \cdot y\right)\right)\]
    12. Simplified9.4

      \[\leadsto \left(\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(\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) + \left(j \cdot \left(c \cdot a - y \cdot i\right) + j \cdot \mathsf{fma}\left(-i, y, i \cdot y\right)\right)\]

    if -9.604262379034084e-142 < x < 1.7474383666639108e-175

    1. Initial program 16.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. Taylor expanded around 0 17.3

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

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

Reproduce

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