Average Error: 6.7 → 2.6
Time: 23.1s
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}\;c \le -4.55654662541823949653768661353737387464 \cdot 10^{160} \lor \neg \left(c \le 9.075256899225485243342018453401870557589 \cdot 10^{45}\right):\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(\mathsf{fma}\left(c, b, a\right) \cdot i\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right) \cdot i\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}\;c \le -4.55654662541823949653768661353737387464 \cdot 10^{160} \lor \neg \left(c \le 9.075256899225485243342018453401870557589 \cdot 10^{45}\right):\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(\mathsf{fma}\left(c, b, a\right) \cdot i\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r799234 = 2.0;
        double r799235 = x;
        double r799236 = y;
        double r799237 = r799235 * r799236;
        double r799238 = z;
        double r799239 = t;
        double r799240 = r799238 * r799239;
        double r799241 = r799237 + r799240;
        double r799242 = a;
        double r799243 = b;
        double r799244 = c;
        double r799245 = r799243 * r799244;
        double r799246 = r799242 + r799245;
        double r799247 = r799246 * r799244;
        double r799248 = i;
        double r799249 = r799247 * r799248;
        double r799250 = r799241 - r799249;
        double r799251 = r799234 * r799250;
        return r799251;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r799252 = c;
        double r799253 = -4.5565466254182395e+160;
        bool r799254 = r799252 <= r799253;
        double r799255 = 9.075256899225485e+45;
        bool r799256 = r799252 <= r799255;
        double r799257 = !r799256;
        bool r799258 = r799254 || r799257;
        double r799259 = 2.0;
        double r799260 = y;
        double r799261 = x;
        double r799262 = z;
        double r799263 = t;
        double r799264 = r799262 * r799263;
        double r799265 = b;
        double r799266 = a;
        double r799267 = fma(r799252, r799265, r799266);
        double r799268 = i;
        double r799269 = r799267 * r799268;
        double r799270 = r799252 * r799269;
        double r799271 = r799264 - r799270;
        double r799272 = fma(r799260, r799261, r799271);
        double r799273 = r799259 * r799272;
        double r799274 = r799252 * r799267;
        double r799275 = r799274 * r799268;
        double r799276 = r799264 - r799275;
        double r799277 = fma(r799260, r799261, r799276);
        double r799278 = r799259 * r799277;
        double r799279 = r799258 ? r799273 : r799278;
        return r799279;
}

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.7
Target1.9
Herbie2.6
\[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 c < -4.5565466254182395e+160 or 9.075256899225485e+45 < c

    1. Initial program 28.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. Simplified28.5

      \[\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 add-cube-cbrt28.7

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

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

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

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

      \[\leadsto 2 \cdot \mathsf{fma}\left(y, x, z \cdot t - \left(\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \left(\color{blue}{{\left(\sqrt[3]{c}\right)}^{1}} \cdot {\left(\mathsf{fma}\left(c, b, a\right)\right)}^{1}\right)\right) \cdot {i}^{1}\right)\]
    10. Applied pow-prod-down28.7

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

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

      \[\leadsto 2 \cdot \mathsf{fma}\left(y, x, z \cdot t - \left(\left(\color{blue}{{\left(\sqrt[3]{c}\right)}^{1}} \cdot {\left(\sqrt[3]{c}\right)}^{1}\right) \cdot {\left(\sqrt[3]{c} \cdot \mathsf{fma}\left(c, b, a\right)\right)}^{1}\right) \cdot {i}^{1}\right)\]
    13. Applied pow-prod-down28.7

      \[\leadsto 2 \cdot \mathsf{fma}\left(y, x, z \cdot t - \left(\color{blue}{{\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right)}^{1}} \cdot {\left(\sqrt[3]{c} \cdot \mathsf{fma}\left(c, b, a\right)\right)}^{1}\right) \cdot {i}^{1}\right)\]
    14. Applied pow-prod-down28.7

      \[\leadsto 2 \cdot \mathsf{fma}\left(y, x, z \cdot t - \color{blue}{{\left(\left(\sqrt[3]{c} \cdot \sqrt[3]{c}\right) \cdot \left(\sqrt[3]{c} \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)}^{1}} \cdot {i}^{1}\right)\]
    15. Applied pow-prod-down28.7

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

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

    if -4.5565466254182395e+160 < c < 9.075256899225485e+45

    1. Initial program 2.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. Simplified2.3

      \[\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. Recombined 2 regimes into one program.
  4. Final simplification2.6

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

Reproduce

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