Average Error: 12.1 → 11.6
Time: 12.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}\;t \le -1.33142358530114826 \cdot 10^{181} \lor \neg \left(t \le 3.84285780752837451 \cdot 10^{234}\right):\\ \;\;\;\;\mathsf{fma}\left(t, i \cdot b, -\mathsf{fma}\left(z, b \cdot c, t \cdot \left(x \cdot a\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, x \cdot \left(\left(\sqrt[3]{y \cdot z - t \cdot a} \cdot \sqrt[3]{y \cdot z - t \cdot a}\right) \cdot \sqrt[3]{y \cdot z - t \cdot a}\right) - b \cdot \left(c \cdot z - t \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}\;t \le -1.33142358530114826 \cdot 10^{181} \lor \neg \left(t \le 3.84285780752837451 \cdot 10^{234}\right):\\
\;\;\;\;\mathsf{fma}\left(t, i \cdot b, -\mathsf{fma}\left(z, b \cdot c, t \cdot \left(x \cdot a\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, x \cdot \left(\left(\sqrt[3]{y \cdot z - t \cdot a} \cdot \sqrt[3]{y \cdot z - t \cdot a}\right) \cdot \sqrt[3]{y \cdot z - t \cdot a}\right) - b \cdot \left(c \cdot z - t \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 r875231 = x;
        double r875232 = y;
        double r875233 = z;
        double r875234 = r875232 * r875233;
        double r875235 = t;
        double r875236 = a;
        double r875237 = r875235 * r875236;
        double r875238 = r875234 - r875237;
        double r875239 = r875231 * r875238;
        double r875240 = b;
        double r875241 = c;
        double r875242 = r875241 * r875233;
        double r875243 = i;
        double r875244 = r875235 * r875243;
        double r875245 = r875242 - r875244;
        double r875246 = r875240 * r875245;
        double r875247 = r875239 - r875246;
        double r875248 = j;
        double r875249 = r875241 * r875236;
        double r875250 = r875232 * r875243;
        double r875251 = r875249 - r875250;
        double r875252 = r875248 * r875251;
        double r875253 = r875247 + r875252;
        return r875253;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i, double j) {
        double r875254 = t;
        double r875255 = -1.3314235853011483e+181;
        bool r875256 = r875254 <= r875255;
        double r875257 = 3.8428578075283745e+234;
        bool r875258 = r875254 <= r875257;
        double r875259 = !r875258;
        bool r875260 = r875256 || r875259;
        double r875261 = i;
        double r875262 = b;
        double r875263 = r875261 * r875262;
        double r875264 = z;
        double r875265 = c;
        double r875266 = r875262 * r875265;
        double r875267 = x;
        double r875268 = a;
        double r875269 = r875267 * r875268;
        double r875270 = r875254 * r875269;
        double r875271 = fma(r875264, r875266, r875270);
        double r875272 = -r875271;
        double r875273 = fma(r875254, r875263, r875272);
        double r875274 = r875265 * r875268;
        double r875275 = y;
        double r875276 = r875275 * r875261;
        double r875277 = r875274 - r875276;
        double r875278 = j;
        double r875279 = r875275 * r875264;
        double r875280 = r875254 * r875268;
        double r875281 = r875279 - r875280;
        double r875282 = cbrt(r875281);
        double r875283 = r875282 * r875282;
        double r875284 = r875283 * r875282;
        double r875285 = r875267 * r875284;
        double r875286 = r875265 * r875264;
        double r875287 = r875254 * r875261;
        double r875288 = r875286 - r875287;
        double r875289 = r875262 * r875288;
        double r875290 = r875285 - r875289;
        double r875291 = fma(r875277, r875278, r875290);
        double r875292 = r875260 ? r875273 : r875291;
        return r875292;
}

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
Target19.8
Herbie11.6
\[\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 t < -1.3314235853011483e+181 or 3.8428578075283745e+234 < t

    1. Initial program 26.8

      \[\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. Simplified26.8

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

      \[\leadsto \color{blue}{t \cdot \left(i \cdot b\right) - \left(z \cdot \left(b \cdot c\right) + t \cdot \left(x \cdot a\right)\right)}\]
    4. Simplified18.2

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

    if -1.3314235853011483e+181 < t < 3.8428578075283745e+234

    1. Initial program 10.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \le -1.33142358530114826 \cdot 10^{181} \lor \neg \left(t \le 3.84285780752837451 \cdot 10^{234}\right):\\ \;\;\;\;\mathsf{fma}\left(t, i \cdot b, -\mathsf{fma}\left(z, b \cdot c, t \cdot \left(x \cdot a\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(c \cdot a - y \cdot i, j, x \cdot \left(\left(\sqrt[3]{y \cdot z - t \cdot a} \cdot \sqrt[3]{y \cdot z - t \cdot a}\right) \cdot \sqrt[3]{y \cdot z - t \cdot a}\right) - b \cdot \left(c \cdot z - t \cdot i\right)\right)\\ \end{array}\]

Reproduce

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