Average Error: 12.6 → 12.9
Time: 1.3m
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}\;j \le -6.278761456731711 \cdot 10^{-165}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot c - y \cdot i, j, \mathsf{fma}\left(t \cdot i - c \cdot z, b, \left(\left(z \cdot y - t \cdot a\right) \cdot \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right) \cdot \sqrt[3]{x}\right)\right)\\ \mathbf{elif}\;j \le 8.610643150369853 \cdot 10^{-225}:\\ \;\;\;\;\mathsf{fma}\left(t \cdot i - c \cdot z, b, \left(z \cdot y - t \cdot a\right) \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t \cdot i - c \cdot z, b, \left(z \cdot y - t \cdot a\right) \cdot x\right) + \sqrt{j} \cdot \left(\sqrt{j} \cdot \left(a \cdot c - y \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}\;j \le -6.278761456731711 \cdot 10^{-165}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot c - y \cdot i, j, \mathsf{fma}\left(t \cdot i - c \cdot z, b, \left(\left(z \cdot y - t \cdot a\right) \cdot \left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)\right) \cdot \sqrt[3]{x}\right)\right)\\

\mathbf{elif}\;j \le 8.610643150369853 \cdot 10^{-225}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot i - c \cdot z, b, \left(z \cdot y - t \cdot a\right) \cdot x\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t \cdot i - c \cdot z, b, \left(z \cdot y - t \cdot a\right) \cdot x\right) + \sqrt{j} \cdot \left(\sqrt{j} \cdot \left(a \cdot c - y \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 r36902663 = x;
        double r36902664 = y;
        double r36902665 = z;
        double r36902666 = r36902664 * r36902665;
        double r36902667 = t;
        double r36902668 = a;
        double r36902669 = r36902667 * r36902668;
        double r36902670 = r36902666 - r36902669;
        double r36902671 = r36902663 * r36902670;
        double r36902672 = b;
        double r36902673 = c;
        double r36902674 = r36902673 * r36902665;
        double r36902675 = i;
        double r36902676 = r36902667 * r36902675;
        double r36902677 = r36902674 - r36902676;
        double r36902678 = r36902672 * r36902677;
        double r36902679 = r36902671 - r36902678;
        double r36902680 = j;
        double r36902681 = r36902673 * r36902668;
        double r36902682 = r36902664 * r36902675;
        double r36902683 = r36902681 - r36902682;
        double r36902684 = r36902680 * r36902683;
        double r36902685 = r36902679 + r36902684;
        return r36902685;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r36902686 = j;
        double r36902687 = -6.278761456731711e-165;
        bool r36902688 = r36902686 <= r36902687;
        double r36902689 = a;
        double r36902690 = c;
        double r36902691 = r36902689 * r36902690;
        double r36902692 = y;
        double r36902693 = i;
        double r36902694 = r36902692 * r36902693;
        double r36902695 = r36902691 - r36902694;
        double r36902696 = t;
        double r36902697 = r36902696 * r36902693;
        double r36902698 = z;
        double r36902699 = r36902690 * r36902698;
        double r36902700 = r36902697 - r36902699;
        double r36902701 = b;
        double r36902702 = r36902698 * r36902692;
        double r36902703 = r36902696 * r36902689;
        double r36902704 = r36902702 - r36902703;
        double r36902705 = x;
        double r36902706 = cbrt(r36902705);
        double r36902707 = r36902706 * r36902706;
        double r36902708 = r36902704 * r36902707;
        double r36902709 = r36902708 * r36902706;
        double r36902710 = fma(r36902700, r36902701, r36902709);
        double r36902711 = fma(r36902695, r36902686, r36902710);
        double r36902712 = 8.610643150369853e-225;
        bool r36902713 = r36902686 <= r36902712;
        double r36902714 = r36902704 * r36902705;
        double r36902715 = fma(r36902700, r36902701, r36902714);
        double r36902716 = sqrt(r36902686);
        double r36902717 = r36902716 * r36902695;
        double r36902718 = r36902716 * r36902717;
        double r36902719 = r36902715 + r36902718;
        double r36902720 = r36902713 ? r36902715 : r36902719;
        double r36902721 = r36902688 ? r36902711 : r36902720;
        return r36902721;
}

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.6
Target20.5
Herbie12.9
\[\begin{array}{l} \mathbf{if}\;x \lt -1.469694296777705 \cdot 10^{-64}:\\ \;\;\;\;\left(x \cdot \left(y \cdot z - t \cdot a\right) - \frac{b \cdot \left({\left(c \cdot z\right)}^{2.0} - {\left(t \cdot i\right)}^{2.0}\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.0} - {\left(t \cdot i\right)}^{2.0}\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 j < -6.278761456731711e-165

    1. Initial program 10.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. Simplified10.2

      \[\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 add-cube-cbrt10.5

      \[\leadsto \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 \color{blue}{\left(\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right) \cdot \sqrt[3]{x}\right)}\right)\right)\]
    5. Applied associate-*r*10.5

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

    if -6.278761456731711e-165 < j < 8.610643150369853e-225

    1. Initial program 18.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. Simplified18.4

      \[\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-udef18.4

      \[\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. Taylor expanded around 0 18.9

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

    if 8.610643150369853e-225 < j

    1. Initial program 11.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. Simplified11.3

      \[\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.3

      \[\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-sqr-sqrt11.4

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

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

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

Reproduce

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