Average Error: 12.2 → 13.3
Time: 25.2s
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 -4.678704205438575893120558096144862893829 \cdot 10^{89}:\\ \;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, t \cdot i - c \cdot z, \left(\sqrt[3]{j} \cdot \sqrt[3]{j}\right) \cdot \left(\sqrt[3]{j} \cdot \left(c \cdot a - y \cdot i\right)\right)\right)\right)\\ \mathbf{elif}\;x \le -4.270541356322630425633982315397992209855 \cdot 10^{-250} \lor \neg \left(x \le 3.363483265951427129429676499791780808133 \cdot 10^{-255}\right):\\ \;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, t \cdot i - c \cdot z, a \cdot \left(j \cdot c\right) + \left(-i \cdot \left(y \cdot j\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot \left(a \cdot j - z \cdot b\right) - i \cdot \left(y \cdot j\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 -4.678704205438575893120558096144862893829 \cdot 10^{89}:\\
\;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, t \cdot i - c \cdot z, \left(\sqrt[3]{j} \cdot \sqrt[3]{j}\right) \cdot \left(\sqrt[3]{j} \cdot \left(c \cdot a - y \cdot i\right)\right)\right)\right)\\

\mathbf{elif}\;x \le -4.270541356322630425633982315397992209855 \cdot 10^{-250} \lor \neg \left(x \le 3.363483265951427129429676499791780808133 \cdot 10^{-255}\right):\\
\;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, t \cdot i - c \cdot z, a \cdot \left(j \cdot c\right) + \left(-i \cdot \left(y \cdot j\right)\right)\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r492754 = x;
        double r492755 = y;
        double r492756 = z;
        double r492757 = r492755 * r492756;
        double r492758 = t;
        double r492759 = a;
        double r492760 = r492758 * r492759;
        double r492761 = r492757 - r492760;
        double r492762 = r492754 * r492761;
        double r492763 = b;
        double r492764 = c;
        double r492765 = r492764 * r492756;
        double r492766 = i;
        double r492767 = r492758 * r492766;
        double r492768 = r492765 - r492767;
        double r492769 = r492763 * r492768;
        double r492770 = r492762 - r492769;
        double r492771 = j;
        double r492772 = r492764 * r492759;
        double r492773 = r492755 * r492766;
        double r492774 = r492772 - r492773;
        double r492775 = r492771 * r492774;
        double r492776 = r492770 + r492775;
        return r492776;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r492777 = x;
        double r492778 = -4.678704205438576e+89;
        bool r492779 = r492777 <= r492778;
        double r492780 = y;
        double r492781 = z;
        double r492782 = r492780 * r492781;
        double r492783 = t;
        double r492784 = a;
        double r492785 = r492783 * r492784;
        double r492786 = r492782 - r492785;
        double r492787 = b;
        double r492788 = i;
        double r492789 = r492783 * r492788;
        double r492790 = c;
        double r492791 = r492790 * r492781;
        double r492792 = r492789 - r492791;
        double r492793 = j;
        double r492794 = cbrt(r492793);
        double r492795 = r492794 * r492794;
        double r492796 = r492790 * r492784;
        double r492797 = r492780 * r492788;
        double r492798 = r492796 - r492797;
        double r492799 = r492794 * r492798;
        double r492800 = r492795 * r492799;
        double r492801 = fma(r492787, r492792, r492800);
        double r492802 = fma(r492777, r492786, r492801);
        double r492803 = -4.2705413563226304e-250;
        bool r492804 = r492777 <= r492803;
        double r492805 = 3.363483265951427e-255;
        bool r492806 = r492777 <= r492805;
        double r492807 = !r492806;
        bool r492808 = r492804 || r492807;
        double r492809 = r492793 * r492790;
        double r492810 = r492784 * r492809;
        double r492811 = r492780 * r492793;
        double r492812 = r492788 * r492811;
        double r492813 = -r492812;
        double r492814 = r492810 + r492813;
        double r492815 = fma(r492787, r492792, r492814);
        double r492816 = fma(r492777, r492786, r492815);
        double r492817 = r492784 * r492793;
        double r492818 = r492781 * r492787;
        double r492819 = r492817 - r492818;
        double r492820 = r492790 * r492819;
        double r492821 = r492820 - r492812;
        double r492822 = r492808 ? r492816 : r492821;
        double r492823 = r492779 ? r492802 : r492822;
        return r492823;
}

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.2
Target19.1
Herbie13.3
\[\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. Split input into 3 regimes
  2. if x < -4.678704205438576e+89

    1. Initial program 7.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. Simplified7.0

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

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

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

    if -4.678704205438576e+89 < x < -4.2705413563226304e-250 or 3.363483265951427e-255 < x

    1. Initial program 12.3

      \[\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. Simplified12.2

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

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

      \[\leadsto \mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, t \cdot i - c \cdot z, \color{blue}{\left(\sqrt[3]{j} \cdot \sqrt[3]{j}\right) \cdot \left(\sqrt[3]{j} \cdot \left(c \cdot a - y \cdot i\right)\right)}\right)\right)\]
    6. Using strategy rm
    7. Applied sub-neg12.5

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

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

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

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

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

    if -4.2705413563226304e-250 < x < 3.363483265951427e-255

    1. Initial program 17.2

      \[\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. Simplified17.2

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

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

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

      \[\leadsto \color{blue}{a \cdot \left(j \cdot c\right) - \left(z \cdot \left(b \cdot c\right) + i \cdot \left(j \cdot y\right)\right)}\]
    7. Simplified25.7

      \[\leadsto \color{blue}{c \cdot \left(a \cdot j - z \cdot b\right) - i \cdot \left(y \cdot j\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification13.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -4.678704205438575893120558096144862893829 \cdot 10^{89}:\\ \;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, t \cdot i - c \cdot z, \left(\sqrt[3]{j} \cdot \sqrt[3]{j}\right) \cdot \left(\sqrt[3]{j} \cdot \left(c \cdot a - y \cdot i\right)\right)\right)\right)\\ \mathbf{elif}\;x \le -4.270541356322630425633982315397992209855 \cdot 10^{-250} \lor \neg \left(x \le 3.363483265951427129429676499791780808133 \cdot 10^{-255}\right):\\ \;\;\;\;\mathsf{fma}\left(x, y \cdot z - t \cdot a, \mathsf{fma}\left(b, t \cdot i - c \cdot z, a \cdot \left(j \cdot c\right) + \left(-i \cdot \left(y \cdot j\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot \left(a \cdot j - z \cdot b\right) - i \cdot \left(y \cdot j\right)\\ \end{array}\]

Reproduce

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