Average Error: 6.2 → 1.6
Time: 25.7s
Precision: 64
\[2.0 \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}\;c \le -5.02546033382806 \cdot 10^{-11}:\\ \;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - c \cdot \left(i \cdot \mathsf{fma}\left(b, c, a\right)\right)\right)\\ \mathbf{elif}\;c \le 5.213977875097998 \cdot 10^{-66}:\\ \;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right) \cdot i\right)\\ \mathbf{else}:\\ \;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - \left(c \cdot \left(i \cdot b\right) + a \cdot i\right) \cdot c\right)\\ \end{array}\]
2.0 \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}\;c \le -5.02546033382806 \cdot 10^{-11}:\\
\;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - c \cdot \left(i \cdot \mathsf{fma}\left(b, c, a\right)\right)\right)\\

\mathbf{elif}\;c \le 5.213977875097998 \cdot 10^{-66}:\\
\;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right) \cdot i\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r32112073 = 2.0;
        double r32112074 = x;
        double r32112075 = y;
        double r32112076 = r32112074 * r32112075;
        double r32112077 = z;
        double r32112078 = t;
        double r32112079 = r32112077 * r32112078;
        double r32112080 = r32112076 + r32112079;
        double r32112081 = a;
        double r32112082 = b;
        double r32112083 = c;
        double r32112084 = r32112082 * r32112083;
        double r32112085 = r32112081 + r32112084;
        double r32112086 = r32112085 * r32112083;
        double r32112087 = i;
        double r32112088 = r32112086 * r32112087;
        double r32112089 = r32112080 - r32112088;
        double r32112090 = r32112073 * r32112089;
        return r32112090;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r32112091 = c;
        double r32112092 = -5.02546033382806e-11;
        bool r32112093 = r32112091 <= r32112092;
        double r32112094 = 2.0;
        double r32112095 = t;
        double r32112096 = z;
        double r32112097 = x;
        double r32112098 = y;
        double r32112099 = r32112097 * r32112098;
        double r32112100 = fma(r32112095, r32112096, r32112099);
        double r32112101 = i;
        double r32112102 = b;
        double r32112103 = a;
        double r32112104 = fma(r32112102, r32112091, r32112103);
        double r32112105 = r32112101 * r32112104;
        double r32112106 = r32112091 * r32112105;
        double r32112107 = r32112100 - r32112106;
        double r32112108 = r32112094 * r32112107;
        double r32112109 = 5.213977875097998e-66;
        bool r32112110 = r32112091 <= r32112109;
        double r32112111 = r32112104 * r32112091;
        double r32112112 = r32112111 * r32112101;
        double r32112113 = r32112100 - r32112112;
        double r32112114 = r32112094 * r32112113;
        double r32112115 = r32112101 * r32112102;
        double r32112116 = r32112091 * r32112115;
        double r32112117 = r32112103 * r32112101;
        double r32112118 = r32112116 + r32112117;
        double r32112119 = r32112118 * r32112091;
        double r32112120 = r32112100 - r32112119;
        double r32112121 = r32112094 * r32112120;
        double r32112122 = r32112110 ? r32112114 : r32112121;
        double r32112123 = r32112093 ? r32112108 : r32112122;
        return r32112123;
}

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.7
Herbie1.6
\[2.0 \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 3 regimes
  2. if c < -5.02546033382806e-11

    1. Initial program 16.2

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

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

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

    if -5.02546033382806e-11 < c < 5.213977875097998e-66

    1. Initial program 0.5

      \[2.0 \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.5

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

    if 5.213977875097998e-66 < c

    1. Initial program 13.6

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \le -5.02546033382806 \cdot 10^{-11}:\\ \;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - c \cdot \left(i \cdot \mathsf{fma}\left(b, c, a\right)\right)\right)\\ \mathbf{elif}\;c \le 5.213977875097998 \cdot 10^{-66}:\\ \;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - \left(\mathsf{fma}\left(b, c, a\right) \cdot c\right) \cdot i\right)\\ \mathbf{else}:\\ \;\;\;\;2.0 \cdot \left(\mathsf{fma}\left(t, z, x \cdot y\right) - \left(c \cdot \left(i \cdot b\right) + a \cdot i\right) \cdot c\right)\\ \end{array}\]

Reproduce

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