Average Error: 11.9 → 12.2
Time: 1.2m
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)\]
\[j \cdot \left(a \cdot c - i \cdot y\right) + \mathsf{fma}\left(i \cdot t - z \cdot c, b, \left(x \cdot \sqrt[3]{z \cdot y - t \cdot a}\right) \cdot \left(\sqrt[3]{z \cdot y - t \cdot a} \cdot \sqrt[3]{z \cdot y - t \cdot a}\right)\right)\]
\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)
j \cdot \left(a \cdot c - i \cdot y\right) + \mathsf{fma}\left(i \cdot t - z \cdot c, b, \left(x \cdot \sqrt[3]{z \cdot y - t \cdot a}\right) \cdot \left(\sqrt[3]{z \cdot y - t \cdot a} \cdot \sqrt[3]{z \cdot y - t \cdot a}\right)\right)
double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r41043197 = x;
        double r41043198 = y;
        double r41043199 = z;
        double r41043200 = r41043198 * r41043199;
        double r41043201 = t;
        double r41043202 = a;
        double r41043203 = r41043201 * r41043202;
        double r41043204 = r41043200 - r41043203;
        double r41043205 = r41043197 * r41043204;
        double r41043206 = b;
        double r41043207 = c;
        double r41043208 = r41043207 * r41043199;
        double r41043209 = i;
        double r41043210 = r41043201 * r41043209;
        double r41043211 = r41043208 - r41043210;
        double r41043212 = r41043206 * r41043211;
        double r41043213 = r41043205 - r41043212;
        double r41043214 = j;
        double r41043215 = r41043207 * r41043202;
        double r41043216 = r41043198 * r41043209;
        double r41043217 = r41043215 - r41043216;
        double r41043218 = r41043214 * r41043217;
        double r41043219 = r41043213 + r41043218;
        return r41043219;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r41043220 = j;
        double r41043221 = a;
        double r41043222 = c;
        double r41043223 = r41043221 * r41043222;
        double r41043224 = i;
        double r41043225 = y;
        double r41043226 = r41043224 * r41043225;
        double r41043227 = r41043223 - r41043226;
        double r41043228 = r41043220 * r41043227;
        double r41043229 = t;
        double r41043230 = r41043224 * r41043229;
        double r41043231 = z;
        double r41043232 = r41043231 * r41043222;
        double r41043233 = r41043230 - r41043232;
        double r41043234 = b;
        double r41043235 = x;
        double r41043236 = r41043231 * r41043225;
        double r41043237 = r41043229 * r41043221;
        double r41043238 = r41043236 - r41043237;
        double r41043239 = cbrt(r41043238);
        double r41043240 = r41043235 * r41043239;
        double r41043241 = r41043239 * r41043239;
        double r41043242 = r41043240 * r41043241;
        double r41043243 = fma(r41043233, r41043234, r41043242);
        double r41043244 = r41043228 + r41043243;
        return r41043244;
}

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.9
Target20.1
Herbie12.2
\[\begin{array}{l} \mathbf{if}\;x \lt -1.469694296777705016266218530347997287942 \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.21135273622268028942701600607048800714 \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. Initial program 11.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. Simplified11.9

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

    \[\leadsto \color{blue}{\left(a \cdot c - i \cdot y\right) \cdot j + \mathsf{fma}\left(i \cdot t - z \cdot c, b, \left(z \cdot y - t \cdot a\right) \cdot x\right)}\]
  5. Using strategy rm
  6. Applied add-cube-cbrt12.2

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

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

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

Reproduce

herbie shell --seed 2019168 +o rules:numerics
(FPCore (x y z t a b c i j)
  :name "Data.Colour.Matrix:determinant from colour-2.3.3, A"

  :herbie-target
  (if (< x -1.469694296777705e-64) (+ (- (* x (- (* y z) (* t a))) (/ (* b (- (pow (* c z) 2.0) (pow (* t i) 2.0))) (+ (* 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.0) (pow (* t i) 2.0))) (+ (* c z) (* t i)))) (* j (- (* c a) (* y i))))))

  (+ (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* t i)))) (* j (- (* c a) (* y i)))))