Average Error: 6.5 → 2.3
Time: 8.4s
Precision: 64
\[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\]
\[\begin{array}{l} \mathbf{if}\;b \le -2.2953582784698825 \cdot 10^{-240} \lor \neg \left(b \le 1.57931053270253855 \cdot 10^{-239}\right):\\ \;\;\;\;\mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \left({\left(-\sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right)}^{3} \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \left(-\left(\mathsf{fma}\left(c, b, a\right) \cdot c\right) \cdot i\right)\right)\\ \end{array}\]
2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
\begin{array}{l}
\mathbf{if}\;b \le -2.2953582784698825 \cdot 10^{-240} \lor \neg \left(b \le 1.57931053270253855 \cdot 10^{-239}\right):\\
\;\;\;\;\mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \left({\left(-\sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right)}^{3} \cdot \left(c \cdot i\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \left(-\left(\mathsf{fma}\left(c, b, a\right) \cdot c\right) \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 r778337 = 2.0;
        double r778338 = x;
        double r778339 = y;
        double r778340 = r778338 * r778339;
        double r778341 = z;
        double r778342 = t;
        double r778343 = r778341 * r778342;
        double r778344 = r778340 + r778343;
        double r778345 = a;
        double r778346 = b;
        double r778347 = c;
        double r778348 = r778346 * r778347;
        double r778349 = r778345 + r778348;
        double r778350 = r778349 * r778347;
        double r778351 = i;
        double r778352 = r778350 * r778351;
        double r778353 = r778344 - r778352;
        double r778354 = r778337 * r778353;
        return r778354;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r778355 = b;
        double r778356 = -2.2953582784698825e-240;
        bool r778357 = r778355 <= r778356;
        double r778358 = 1.5793105327025385e-239;
        bool r778359 = r778355 <= r778358;
        double r778360 = !r778359;
        bool r778361 = r778357 || r778360;
        double r778362 = 2.0;
        double r778363 = x;
        double r778364 = y;
        double r778365 = z;
        double r778366 = t;
        double r778367 = r778365 * r778366;
        double r778368 = fma(r778363, r778364, r778367);
        double r778369 = c;
        double r778370 = a;
        double r778371 = fma(r778369, r778355, r778370);
        double r778372 = cbrt(r778371);
        double r778373 = -r778372;
        double r778374 = 3.0;
        double r778375 = pow(r778373, r778374);
        double r778376 = i;
        double r778377 = r778369 * r778376;
        double r778378 = r778375 * r778377;
        double r778379 = r778362 * r778378;
        double r778380 = fma(r778362, r778368, r778379);
        double r778381 = r778371 * r778369;
        double r778382 = r778381 * r778376;
        double r778383 = -r778382;
        double r778384 = r778362 * r778383;
        double r778385 = fma(r778362, r778368, r778384);
        double r778386 = r778361 ? r778380 : r778385;
        return r778386;
}

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

Target

Original6.5
Target1.7
Herbie2.3
\[2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right)\]

Derivation

  1. Split input into 2 regimes
  2. if b < -2.2953582784698825e-240 or 1.5793105327025385e-239 < b

    1. Initial program 6.8

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

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

      \[\leadsto \mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \left(\left(-\color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(c, b, a\right)} \cdot \sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(c, b, a\right)}}\right) \cdot \left(c \cdot i\right)\right)\right)\]
    5. Applied distribute-rgt-neg-in2.0

      \[\leadsto \mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \left(\color{blue}{\left(\left(\sqrt[3]{\mathsf{fma}\left(c, b, a\right)} \cdot \sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right) \cdot \left(-\sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right)\right)} \cdot \left(c \cdot i\right)\right)\right)\]
    6. Applied associate-*l*2.0

      \[\leadsto \mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \color{blue}{\left(\left(\sqrt[3]{\mathsf{fma}\left(c, b, a\right)} \cdot \sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right) \cdot \left(\left(-\sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right) \cdot \left(c \cdot i\right)\right)\right)}\right)\]
    7. Using strategy rm
    8. Applied associate-*r*2.0

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

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

    if -2.2953582784698825e-240 < b < 1.5793105327025385e-239

    1. Initial program 4.4

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

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

      \[\leadsto \mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \left(\left(-\color{blue}{\left(\sqrt[3]{\mathsf{fma}\left(c, b, a\right)} \cdot \sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(c, b, a\right)}}\right) \cdot \left(c \cdot i\right)\right)\right)\]
    5. Applied distribute-rgt-neg-in2.3

      \[\leadsto \mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \left(\color{blue}{\left(\left(\sqrt[3]{\mathsf{fma}\left(c, b, a\right)} \cdot \sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right) \cdot \left(-\sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right)\right)} \cdot \left(c \cdot i\right)\right)\right)\]
    6. Applied associate-*l*2.3

      \[\leadsto \mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \color{blue}{\left(\left(\sqrt[3]{\mathsf{fma}\left(c, b, a\right)} \cdot \sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right) \cdot \left(\left(-\sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right) \cdot \left(c \cdot i\right)\right)\right)}\right)\]
    7. Using strategy rm
    8. Applied associate-*r*2.3

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

      \[\leadsto \mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \left(\color{blue}{{\left(-\sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right)}^{3}} \cdot \left(c \cdot i\right)\right)\right)\]
    10. Using strategy rm
    11. Applied cube-neg2.3

      \[\leadsto \mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \left(\color{blue}{\left(-{\left(\sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right)}^{3}\right)} \cdot \left(c \cdot i\right)\right)\right)\]
    12. Applied distribute-lft-neg-out2.3

      \[\leadsto \mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \color{blue}{\left(-{\left(\sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right)}^{3} \cdot \left(c \cdot i\right)\right)}\right)\]
    13. Simplified4.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -2.2953582784698825 \cdot 10^{-240} \lor \neg \left(b \le 1.57931053270253855 \cdot 10^{-239}\right):\\ \;\;\;\;\mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \left({\left(-\sqrt[3]{\mathsf{fma}\left(c, b, a\right)}\right)}^{3} \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \left(-\left(\mathsf{fma}\left(c, b, a\right) \cdot c\right) \cdot i\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020065 +o rules:numerics
(FPCore (x y z t a b c i)
  :name "Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, A"
  :precision binary64

  :herbie-target
  (* 2 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i))))

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