Average Error: 12.1 → 12.6
Time: 1.3m
Precision: 64
\[\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.946192327766243075167726822032469815816 \cdot 10^{-118}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot t - i \cdot y, j, \mathsf{fma}\left(i \cdot a - z \cdot c, b, \left(y \cdot z - t \cdot a\right) \cdot x\right)\right)\\ \mathbf{elif}\;x \le 1.141247624710465205318881101525926390653 \cdot 10^{-147}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot t - i \cdot y, j, \mathsf{fma}\left(i \cdot a - z \cdot c, b, 0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot t - i \cdot y, j, \mathsf{fma}\left(i \cdot a - z \cdot c, b, \left(y \cdot z - t \cdot a\right) \cdot x\right)\right)\\ \end{array}\]
\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)
\begin{array}{l}
\mathbf{if}\;x \le -2.946192327766243075167726822032469815816 \cdot 10^{-118}:\\
\;\;\;\;\mathsf{fma}\left(c \cdot t - i \cdot y, j, \mathsf{fma}\left(i \cdot a - z \cdot c, b, \left(y \cdot z - t \cdot a\right) \cdot x\right)\right)\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c \cdot t - i \cdot y, j, \mathsf{fma}\left(i \cdot a - z \cdot c, b, \left(y \cdot z - t \cdot a\right) \cdot x\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 r18885149 = x;
        double r18885150 = y;
        double r18885151 = z;
        double r18885152 = r18885150 * r18885151;
        double r18885153 = t;
        double r18885154 = a;
        double r18885155 = r18885153 * r18885154;
        double r18885156 = r18885152 - r18885155;
        double r18885157 = r18885149 * r18885156;
        double r18885158 = b;
        double r18885159 = c;
        double r18885160 = r18885159 * r18885151;
        double r18885161 = i;
        double r18885162 = r18885161 * r18885154;
        double r18885163 = r18885160 - r18885162;
        double r18885164 = r18885158 * r18885163;
        double r18885165 = r18885157 - r18885164;
        double r18885166 = j;
        double r18885167 = r18885159 * r18885153;
        double r18885168 = r18885161 * r18885150;
        double r18885169 = r18885167 - r18885168;
        double r18885170 = r18885166 * r18885169;
        double r18885171 = r18885165 + r18885170;
        return r18885171;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r18885172 = x;
        double r18885173 = -2.946192327766243e-118;
        bool r18885174 = r18885172 <= r18885173;
        double r18885175 = c;
        double r18885176 = t;
        double r18885177 = r18885175 * r18885176;
        double r18885178 = i;
        double r18885179 = y;
        double r18885180 = r18885178 * r18885179;
        double r18885181 = r18885177 - r18885180;
        double r18885182 = j;
        double r18885183 = a;
        double r18885184 = r18885178 * r18885183;
        double r18885185 = z;
        double r18885186 = r18885185 * r18885175;
        double r18885187 = r18885184 - r18885186;
        double r18885188 = b;
        double r18885189 = r18885179 * r18885185;
        double r18885190 = r18885176 * r18885183;
        double r18885191 = r18885189 - r18885190;
        double r18885192 = r18885191 * r18885172;
        double r18885193 = fma(r18885187, r18885188, r18885192);
        double r18885194 = fma(r18885181, r18885182, r18885193);
        double r18885195 = 1.1412476247104652e-147;
        bool r18885196 = r18885172 <= r18885195;
        double r18885197 = 0.0;
        double r18885198 = fma(r18885187, r18885188, r18885197);
        double r18885199 = fma(r18885181, r18885182, r18885198);
        double r18885200 = r18885196 ? r18885199 : r18885194;
        double r18885201 = r18885174 ? r18885194 : r18885200;
        return r18885201;
}

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.1
Target15.9
Herbie12.6
\[\begin{array}{l} \mathbf{if}\;t \lt -8.12097891919591218149793027759825150959 \cdot 10^{-33}:\\ \;\;\;\;x \cdot \left(z \cdot y - a \cdot t\right) - \left(b \cdot \left(z \cdot c - a \cdot i\right) - \left(c \cdot t - y \cdot i\right) \cdot j\right)\\ \mathbf{elif}\;t \lt -4.712553818218485141757938537793350881052 \cdot 10^{-169}:\\ \;\;\;\;\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right) + \frac{j \cdot \left({\left(c \cdot t\right)}^{2} - {\left(i \cdot y\right)}^{2}\right)}{c \cdot t + i \cdot y}\\ \mathbf{elif}\;t \lt -7.633533346031583686060259351057142920433 \cdot 10^{-308}:\\ \;\;\;\;x \cdot \left(z \cdot y - a \cdot t\right) - \left(b \cdot \left(z \cdot c - a \cdot i\right) - \left(c \cdot t - y \cdot i\right) \cdot j\right)\\ \mathbf{elif}\;t \lt 1.053588855745548710002760210539645467715 \cdot 10^{-139}:\\ \;\;\;\;\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right) + \frac{j \cdot \left({\left(c \cdot t\right)}^{2} - {\left(i \cdot y\right)}^{2}\right)}{c \cdot t + i \cdot y}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(z \cdot y - a \cdot t\right) - \left(b \cdot \left(z \cdot c - a \cdot i\right) - \left(c \cdot t - y \cdot i\right) \cdot j\right)\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -2.946192327766243e-118 or 1.1412476247104652e-147 < x

    1. Initial program 9.0

      \[\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)\]
    2. Simplified9.0

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

    if -2.946192327766243e-118 < x < 1.1412476247104652e-147

    1. Initial program 17.6

      \[\left(x \cdot \left(y \cdot z - t \cdot a\right) - b \cdot \left(c \cdot z - i \cdot a\right)\right) + j \cdot \left(c \cdot t - i \cdot y\right)\]
    2. Simplified17.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -2.946192327766243075167726822032469815816 \cdot 10^{-118}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot t - i \cdot y, j, \mathsf{fma}\left(i \cdot a - z \cdot c, b, \left(y \cdot z - t \cdot a\right) \cdot x\right)\right)\\ \mathbf{elif}\;x \le 1.141247624710465205318881101525926390653 \cdot 10^{-147}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot t - i \cdot y, j, \mathsf{fma}\left(i \cdot a - z \cdot c, b, 0\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot t - i \cdot y, j, \mathsf{fma}\left(i \cdot a - z \cdot c, b, \left(y \cdot z - t \cdot a\right) \cdot x\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019200 +o rules:numerics
(FPCore (x y z t a b c i j)
  :name "Linear.Matrix:det33 from linear-1.19.1.3"

  :herbie-target
  (if (< t -8.120978919195912e-33) (- (* x (- (* z y) (* a t))) (- (* b (- (* z c) (* a i))) (* (- (* c t) (* y i)) j))) (if (< t -4.712553818218485e-169) (+ (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* i a)))) (/ (* j (- (pow (* c t) 2.0) (pow (* i y) 2.0))) (+ (* c t) (* i y)))) (if (< t -7.633533346031584e-308) (- (* x (- (* z y) (* a t))) (- (* b (- (* z c) (* a i))) (* (- (* c t) (* y i)) j))) (if (< t 1.0535888557455487e-139) (+ (- (* x (- (* y z) (* t a))) (* b (- (* c z) (* i a)))) (/ (* j (- (pow (* c t) 2.0) (pow (* i y) 2.0))) (+ (* c t) (* i y)))) (- (* x (- (* z y) (* a t))) (- (* b (- (* z c) (* a i))) (* (- (* c t) (* y i)) j)))))))

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