Average Error: 7.9 → 1.2
Time: 3.9s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.0852157021331296 \cdot 10^{231} \lor \neg \left(x \cdot y - z \cdot t \le 6.3521234323903313 \cdot 10^{199}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{z}{a} \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\sqrt[3]{\frac{x \cdot y}{a}} \cdot \sqrt[3]{\frac{x \cdot y}{a}}, \sqrt[3]{\frac{x \cdot y}{a}}, -\frac{t \cdot z}{a}\right)\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -1.0852157021331296 \cdot 10^{231} \lor \neg \left(x \cdot y - z \cdot t \le 6.3521234323903313 \cdot 10^{199}\right):\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{z}{a} \cdot t\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\sqrt[3]{\frac{x \cdot y}{a}} \cdot \sqrt[3]{\frac{x \cdot y}{a}}, \sqrt[3]{\frac{x \cdot y}{a}}, -\frac{t \cdot z}{a}\right)\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r961497 = x;
        double r961498 = y;
        double r961499 = r961497 * r961498;
        double r961500 = z;
        double r961501 = t;
        double r961502 = r961500 * r961501;
        double r961503 = r961499 - r961502;
        double r961504 = a;
        double r961505 = r961503 / r961504;
        return r961505;
}

double f(double x, double y, double z, double t, double a) {
        double r961506 = x;
        double r961507 = y;
        double r961508 = r961506 * r961507;
        double r961509 = z;
        double r961510 = t;
        double r961511 = r961509 * r961510;
        double r961512 = r961508 - r961511;
        double r961513 = -1.0852157021331296e+231;
        bool r961514 = r961512 <= r961513;
        double r961515 = 6.352123432390331e+199;
        bool r961516 = r961512 <= r961515;
        double r961517 = !r961516;
        bool r961518 = r961514 || r961517;
        double r961519 = 1.0;
        double r961520 = r961506 / r961519;
        double r961521 = a;
        double r961522 = r961507 / r961521;
        double r961523 = r961509 / r961521;
        double r961524 = r961523 * r961510;
        double r961525 = -r961524;
        double r961526 = fma(r961520, r961522, r961525);
        double r961527 = r961508 / r961521;
        double r961528 = cbrt(r961527);
        double r961529 = r961528 * r961528;
        double r961530 = r961510 * r961509;
        double r961531 = r961530 / r961521;
        double r961532 = -r961531;
        double r961533 = fma(r961529, r961528, r961532);
        double r961534 = r961518 ? r961526 : r961533;
        return r961534;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.9
Target5.9
Herbie1.2
\[\begin{array}{l} \mathbf{if}\;z \lt -2.46868496869954822 \cdot 10^{170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \lt 6.30983112197837121 \cdot 10^{-71}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (- (* x y) (* z t)) < -1.0852157021331296e+231 or 6.352123432390331e+199 < (- (* x y) (* z t))

    1. Initial program 32.1

      \[\frac{x \cdot y - z \cdot t}{a}\]
    2. Using strategy rm
    3. Applied div-sub32.1

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Simplified32.1

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity32.1

      \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot a}} - \frac{t \cdot z}{a}\]
    7. Applied times-frac17.2

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y}{a}} - \frac{t \cdot z}{a}\]
    8. Applied fma-neg17.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{t \cdot z}{a}\right)}\]
    9. Using strategy rm
    10. Applied add-cube-cbrt17.4

      \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{t \cdot z}{\color{blue}{\left(\sqrt[3]{a} \cdot \sqrt[3]{a}\right) \cdot \sqrt[3]{a}}}\right)\]
    11. Applied times-frac1.4

      \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\color{blue}{\frac{t}{\sqrt[3]{a} \cdot \sqrt[3]{a}} \cdot \frac{z}{\sqrt[3]{a}}}\right)\]
    12. Taylor expanded around 0 17.2

      \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\color{blue}{\frac{t \cdot z}{a}}\right)\]
    13. Simplified0.9

      \[\leadsto \mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\color{blue}{\frac{z}{a} \cdot t}\right)\]

    if -1.0852157021331296e+231 < (- (* x y) (* z t)) < 6.352123432390331e+199

    1. Initial program 0.8

      \[\frac{x \cdot y - z \cdot t}{a}\]
    2. Using strategy rm
    3. Applied div-sub0.8

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Simplified0.8

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt1.3

      \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{x \cdot y}{a}} \cdot \sqrt[3]{\frac{x \cdot y}{a}}\right) \cdot \sqrt[3]{\frac{x \cdot y}{a}}} - \frac{t \cdot z}{a}\]
    7. Applied fma-neg1.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -1.0852157021331296 \cdot 10^{231} \lor \neg \left(x \cdot y - z \cdot t \le 6.3521234323903313 \cdot 10^{199}\right):\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{z}{a} \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\sqrt[3]{\frac{x \cdot y}{a}} \cdot \sqrt[3]{\frac{x \cdot y}{a}}, \sqrt[3]{\frac{x \cdot y}{a}}, -\frac{t \cdot z}{a}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020020 +o rules:numerics
(FPCore (x y z t a)
  :name "Data.Colour.Matrix:inverse from colour-2.3.3, B"
  :precision binary64

  :herbie-target
  (if (< z -2.468684968699548e+170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))

  (/ (- (* x y) (* z t)) a))