Average Error: 6.2 → 1.2
Time: 26.9s
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}\;i \le -5.8702912398015024 \cdot 10^{-7} \lor \neg \left(i \le 2.99342438571417912 \cdot 10^{-24}\right):\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, \left(-i\right) \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(\mathsf{fma}\left(c, b, a\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}\;i \le -5.8702912398015024 \cdot 10^{-7} \lor \neg \left(i \le 2.99342438571417912 \cdot 10^{-24}\right):\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, \left(-i\right) \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(\mathsf{fma}\left(c, b, a\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 r521497 = 2.0;
        double r521498 = x;
        double r521499 = y;
        double r521500 = r521498 * r521499;
        double r521501 = z;
        double r521502 = t;
        double r521503 = r521501 * r521502;
        double r521504 = r521500 + r521503;
        double r521505 = a;
        double r521506 = b;
        double r521507 = c;
        double r521508 = r521506 * r521507;
        double r521509 = r521505 + r521508;
        double r521510 = r521509 * r521507;
        double r521511 = i;
        double r521512 = r521510 * r521511;
        double r521513 = r521504 - r521512;
        double r521514 = r521497 * r521513;
        return r521514;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r521515 = i;
        double r521516 = -5.870291239801502e-07;
        bool r521517 = r521515 <= r521516;
        double r521518 = 2.993424385714179e-24;
        bool r521519 = r521515 <= r521518;
        double r521520 = !r521519;
        bool r521521 = r521517 || r521520;
        double r521522 = 2.0;
        double r521523 = y;
        double r521524 = x;
        double r521525 = z;
        double r521526 = t;
        double r521527 = -r521515;
        double r521528 = c;
        double r521529 = b;
        double r521530 = a;
        double r521531 = fma(r521528, r521529, r521530);
        double r521532 = r521528 * r521531;
        double r521533 = r521527 * r521532;
        double r521534 = fma(r521525, r521526, r521533);
        double r521535 = fma(r521523, r521524, r521534);
        double r521536 = r521522 * r521535;
        double r521537 = r521525 * r521526;
        double r521538 = r521531 * r521515;
        double r521539 = r521528 * r521538;
        double r521540 = r521537 - r521539;
        double r521541 = fma(r521523, r521524, r521540);
        double r521542 = r521522 * r521541;
        double r521543 = r521521 ? r521536 : r521542;
        return r521543;
}

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.2
Target1.8
Herbie1.2
\[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 i < -5.870291239801502e-07 or 2.993424385714179e-24 < i

    1. Initial program 0.6

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

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

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

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

    if -5.870291239801502e-07 < i < 2.993424385714179e-24

    1. Initial program 10.3

      \[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. Simplified10.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \le -5.8702912398015024 \cdot 10^{-7} \lor \neg \left(i \le 2.99342438571417912 \cdot 10^{-24}\right):\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, \left(-i\right) \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(\mathsf{fma}\left(c, b, a\right) \cdot i\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019199 +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"

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

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