Average Error: 6.5 → 1.4
Time: 54.3s
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 5.926206862468905479256541974864551127155 \cdot 10^{-23}:\\ \;\;\;\;\left(\left(\mathsf{fma}\left(y, x, t \cdot z\right) - \mathsf{fma}\left(b, c, a\right) \cdot \left(c \cdot i\right)\right) + \left(0\right)\right) \cdot 2\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(c \cdot \left(b \cdot i\right) + i \cdot a\right) \cdot c\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 5.926206862468905479256541974864551127155 \cdot 10^{-23}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(y, x, t \cdot z\right) - \mathsf{fma}\left(b, c, a\right) \cdot \left(c \cdot i\right)\right) + \left(0\right)\right) \cdot 2\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(c \cdot \left(b \cdot i\right) + i \cdot a\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 r31615557 = 2.0;
        double r31615558 = x;
        double r31615559 = y;
        double r31615560 = r31615558 * r31615559;
        double r31615561 = z;
        double r31615562 = t;
        double r31615563 = r31615561 * r31615562;
        double r31615564 = r31615560 + r31615563;
        double r31615565 = a;
        double r31615566 = b;
        double r31615567 = c;
        double r31615568 = r31615566 * r31615567;
        double r31615569 = r31615565 + r31615568;
        double r31615570 = r31615569 * r31615567;
        double r31615571 = i;
        double r31615572 = r31615570 * r31615571;
        double r31615573 = r31615564 - r31615572;
        double r31615574 = r31615557 * r31615573;
        return r31615574;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r31615575 = c;
        double r31615576 = 5.926206862468905e-23;
        bool r31615577 = r31615575 <= r31615576;
        double r31615578 = y;
        double r31615579 = x;
        double r31615580 = t;
        double r31615581 = z;
        double r31615582 = r31615580 * r31615581;
        double r31615583 = fma(r31615578, r31615579, r31615582);
        double r31615584 = b;
        double r31615585 = a;
        double r31615586 = fma(r31615584, r31615575, r31615585);
        double r31615587 = i;
        double r31615588 = r31615575 * r31615587;
        double r31615589 = r31615586 * r31615588;
        double r31615590 = r31615583 - r31615589;
        double r31615591 = 0.0;
        double r31615592 = /* ERROR: no posit support in C */;
        double r31615593 = /* ERROR: no posit support in C */;
        double r31615594 = r31615590 + r31615593;
        double r31615595 = 2.0;
        double r31615596 = r31615594 * r31615595;
        double r31615597 = r31615578 * r31615579;
        double r31615598 = fma(r31615580, r31615581, r31615597);
        double r31615599 = r31615584 * r31615587;
        double r31615600 = r31615575 * r31615599;
        double r31615601 = r31615587 * r31615585;
        double r31615602 = r31615600 + r31615601;
        double r31615603 = r31615602 * r31615575;
        double r31615604 = r31615598 - r31615603;
        double r31615605 = r31615595 * r31615604;
        double r31615606 = r31615577 ? r31615596 : r31615605;
        return r31615606;
}

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
Herbie1.4
\[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 < 5.926206862468905e-23

    1. Initial program 4.1

      \[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. Simplified4.1

      \[\leadsto \color{blue}{2 \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*5.7

      \[\leadsto 2 \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-sqr-sqrt34.8

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

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

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

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

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

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

    if 5.926206862468905e-23 < c

    1. Initial program 17.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. Simplified17.5

      \[\leadsto \color{blue}{2 \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 \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.4

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

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

      \[\leadsto 2 \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. Simplified2.4

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

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

Reproduce

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