Average Error: 6.5 → 1.7
Time: 21.0s
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 -7.472033446684188899599491262791955462412 \cdot 10^{-59} \lor \neg \left(i \le 1.502007598359967449068109020258153999519 \cdot 10^{-55}\right):\\ \;\;\;\;2 \cdot \mathsf{fma}\left(x, y, \mathsf{fma}\left(i, \mathsf{fma}\left(b, c, a\right) \cdot \left(-c\right), z \cdot t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(x, y, \left(-c\right) \cdot \left(i \cdot \mathsf{fma}\left(c, b, a\right)\right) + z \cdot t\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 -7.472033446684188899599491262791955462412 \cdot 10^{-59} \lor \neg \left(i \le 1.502007598359967449068109020258153999519 \cdot 10^{-55}\right):\\
\;\;\;\;2 \cdot \mathsf{fma}\left(x, y, \mathsf{fma}\left(i, \mathsf{fma}\left(b, c, a\right) \cdot \left(-c\right), z \cdot t\right)\right)\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \mathsf{fma}\left(x, y, \left(-c\right) \cdot \left(i \cdot \mathsf{fma}\left(c, b, a\right)\right) + z \cdot t\right)\\

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r501972 = 2.0;
        double r501973 = x;
        double r501974 = y;
        double r501975 = r501973 * r501974;
        double r501976 = z;
        double r501977 = t;
        double r501978 = r501976 * r501977;
        double r501979 = r501975 + r501978;
        double r501980 = a;
        double r501981 = b;
        double r501982 = c;
        double r501983 = r501981 * r501982;
        double r501984 = r501980 + r501983;
        double r501985 = r501984 * r501982;
        double r501986 = i;
        double r501987 = r501985 * r501986;
        double r501988 = r501979 - r501987;
        double r501989 = r501972 * r501988;
        return r501989;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r501990 = i;
        double r501991 = -7.472033446684189e-59;
        bool r501992 = r501990 <= r501991;
        double r501993 = 1.5020075983599674e-55;
        bool r501994 = r501990 <= r501993;
        double r501995 = !r501994;
        bool r501996 = r501992 || r501995;
        double r501997 = 2.0;
        double r501998 = x;
        double r501999 = y;
        double r502000 = b;
        double r502001 = c;
        double r502002 = a;
        double r502003 = fma(r502000, r502001, r502002);
        double r502004 = -r502001;
        double r502005 = r502003 * r502004;
        double r502006 = z;
        double r502007 = t;
        double r502008 = r502006 * r502007;
        double r502009 = fma(r501990, r502005, r502008);
        double r502010 = fma(r501998, r501999, r502009);
        double r502011 = r501997 * r502010;
        double r502012 = fma(r502001, r502000, r502002);
        double r502013 = r501990 * r502012;
        double r502014 = r502004 * r502013;
        double r502015 = r502014 + r502008;
        double r502016 = fma(r501998, r501999, r502015);
        double r502017 = r501997 * r502016;
        double r502018 = r501996 ? r502011 : r502017;
        return r502018;
}

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
Target2.1
Herbie1.7
\[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 < -7.472033446684189e-59 or 1.5020075983599674e-55 < i

    1. Initial program 1.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. Using strategy rm
    3. Applied associate--l+1.3

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

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

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

    if -7.472033446684189e-59 < i < 1.5020075983599674e-55

    1. Initial program 11.5

      \[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. Using strategy rm
    3. Applied associate--l+11.5

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

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

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

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

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

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

Reproduce

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