Average Error: 12.8 → 11.9
Time: 27.3s
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}\;b \le -3.6251610344492796 \cdot 10^{-120} \lor \neg \left(b \le 3.05403375428719925 \cdot 10^{-89}\right):\\ \;\;\;\;\left(\sqrt[3]{\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)} \cdot \sqrt[3]{\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)}\right) \cdot \sqrt[3]{\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)}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \left(y \cdot z\right) + x \cdot \left(-t \cdot a\right)\right) + \left(c \cdot \left(a \cdot j - z \cdot b\right) - i \cdot \left(y \cdot j\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}\;b \le -3.6251610344492796 \cdot 10^{-120} \lor \neg \left(b \le 3.05403375428719925 \cdot 10^{-89}\right):\\
\;\;\;\;\left(\sqrt[3]{\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)} \cdot \sqrt[3]{\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)}\right) \cdot \sqrt[3]{\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)}\\

\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left(y \cdot z\right) + x \cdot \left(-t \cdot a\right)\right) + \left(c \cdot \left(a \cdot j - z \cdot b\right) - i \cdot \left(y \cdot j\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 r405806 = x;
        double r405807 = y;
        double r405808 = z;
        double r405809 = r405807 * r405808;
        double r405810 = t;
        double r405811 = a;
        double r405812 = r405810 * r405811;
        double r405813 = r405809 - r405812;
        double r405814 = r405806 * r405813;
        double r405815 = b;
        double r405816 = c;
        double r405817 = r405816 * r405808;
        double r405818 = i;
        double r405819 = r405810 * r405818;
        double r405820 = r405817 - r405819;
        double r405821 = r405815 * r405820;
        double r405822 = r405814 - r405821;
        double r405823 = j;
        double r405824 = r405816 * r405811;
        double r405825 = r405807 * r405818;
        double r405826 = r405824 - r405825;
        double r405827 = r405823 * r405826;
        double r405828 = r405822 + r405827;
        return r405828;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r405829 = b;
        double r405830 = -3.6251610344492796e-120;
        bool r405831 = r405829 <= r405830;
        double r405832 = 3.0540337542871992e-89;
        bool r405833 = r405829 <= r405832;
        double r405834 = !r405833;
        bool r405835 = r405831 || r405834;
        double r405836 = x;
        double r405837 = y;
        double r405838 = z;
        double r405839 = r405837 * r405838;
        double r405840 = t;
        double r405841 = a;
        double r405842 = r405840 * r405841;
        double r405843 = r405839 - r405842;
        double r405844 = i;
        double r405845 = r405840 * r405844;
        double r405846 = c;
        double r405847 = r405846 * r405838;
        double r405848 = r405845 - r405847;
        double r405849 = j;
        double r405850 = r405846 * r405841;
        double r405851 = r405837 * r405844;
        double r405852 = r405850 - r405851;
        double r405853 = r405849 * r405852;
        double r405854 = fma(r405829, r405848, r405853);
        double r405855 = fma(r405836, r405843, r405854);
        double r405856 = cbrt(r405855);
        double r405857 = r405856 * r405856;
        double r405858 = r405857 * r405856;
        double r405859 = r405836 * r405839;
        double r405860 = -r405842;
        double r405861 = r405836 * r405860;
        double r405862 = r405859 + r405861;
        double r405863 = r405841 * r405849;
        double r405864 = r405838 * r405829;
        double r405865 = r405863 - r405864;
        double r405866 = r405846 * r405865;
        double r405867 = r405837 * r405849;
        double r405868 = r405844 * r405867;
        double r405869 = r405866 - r405868;
        double r405870 = r405862 + r405869;
        double r405871 = r405835 ? r405858 : r405870;
        return r405871;
}

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.8
Target20.1
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 b < -3.6251610344492796e-120 or 3.0540337542871992e-89 < b

    1. Initial program 9.5

      \[\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. Simplified9.5

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

      \[\leadsto \color{blue}{\left(\sqrt[3]{\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)} \cdot \sqrt[3]{\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)}\right) \cdot \sqrt[3]{\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)}}\]

    if -3.6251610344492796e-120 < b < 3.0540337542871992e-89

    1. Initial program 17.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. Simplified17.3

      \[\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. Taylor expanded around inf 14.5

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

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

      \[\leadsto \color{blue}{x \cdot \left(y \cdot z - t \cdot a\right) + \left(c \cdot \left(a \cdot j - z \cdot b\right) - i \cdot \left(y \cdot j\right)\right)}\]
    7. Using strategy rm
    8. Applied sub-neg13.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.6251610344492796 \cdot 10^{-120} \lor \neg \left(b \le 3.05403375428719925 \cdot 10^{-89}\right):\\ \;\;\;\;\left(\sqrt[3]{\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)} \cdot \sqrt[3]{\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)}\right) \cdot \sqrt[3]{\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)}\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot \left(y \cdot z\right) + x \cdot \left(-t \cdot a\right)\right) + \left(c \cdot \left(a \cdot j - z \cdot b\right) - i \cdot \left(y \cdot j\right)\right)\\ \end{array}\]

Reproduce

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