Average Error: 6.3 → 0.3
Time: 20.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}\;\left(c \cdot b + a\right) \cdot c \le -2.816503233649596575999453222322489854615 \cdot 10^{286} \lor \neg \left(\left(c \cdot b + a\right) \cdot c \le 2.512868147830362656060006320039326628222 \cdot 10^{304}\right):\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + t \cdot z\right) - \mathsf{fma}\left(\left(c \cdot i\right) \cdot b, c, a \cdot \left(c \cdot i\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \left(\left(x \cdot y + t \cdot z\right) - i \cdot \left(\left(c \cdot b + a\right) \cdot c\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}\;\left(c \cdot b + a\right) \cdot c \le -2.816503233649596575999453222322489854615 \cdot 10^{286} \lor \neg \left(\left(c \cdot b + a\right) \cdot c \le 2.512868147830362656060006320039326628222 \cdot 10^{304}\right):\\
\;\;\;\;2 \cdot \left(\left(x \cdot y + t \cdot z\right) - \mathsf{fma}\left(\left(c \cdot i\right) \cdot b, c, a \cdot \left(c \cdot i\right)\right)\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r965290 = 2.0;
        double r965291 = x;
        double r965292 = y;
        double r965293 = r965291 * r965292;
        double r965294 = z;
        double r965295 = t;
        double r965296 = r965294 * r965295;
        double r965297 = r965293 + r965296;
        double r965298 = a;
        double r965299 = b;
        double r965300 = c;
        double r965301 = r965299 * r965300;
        double r965302 = r965298 + r965301;
        double r965303 = r965302 * r965300;
        double r965304 = i;
        double r965305 = r965303 * r965304;
        double r965306 = r965297 - r965305;
        double r965307 = r965290 * r965306;
        return r965307;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r965308 = c;
        double r965309 = b;
        double r965310 = r965308 * r965309;
        double r965311 = a;
        double r965312 = r965310 + r965311;
        double r965313 = r965312 * r965308;
        double r965314 = -2.8165032336495966e+286;
        bool r965315 = r965313 <= r965314;
        double r965316 = 2.5128681478303627e+304;
        bool r965317 = r965313 <= r965316;
        double r965318 = !r965317;
        bool r965319 = r965315 || r965318;
        double r965320 = 2.0;
        double r965321 = x;
        double r965322 = y;
        double r965323 = r965321 * r965322;
        double r965324 = t;
        double r965325 = z;
        double r965326 = r965324 * r965325;
        double r965327 = r965323 + r965326;
        double r965328 = i;
        double r965329 = r965308 * r965328;
        double r965330 = r965329 * r965309;
        double r965331 = r965311 * r965329;
        double r965332 = fma(r965330, r965308, r965331);
        double r965333 = r965327 - r965332;
        double r965334 = r965320 * r965333;
        double r965335 = r965328 * r965313;
        double r965336 = r965327 - r965335;
        double r965337 = r965320 * r965336;
        double r965338 = r965319 ? r965334 : r965337;
        return r965338;
}

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.3
Target1.8
Herbie0.3
\[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 (* (+ a (* b c)) c) < -2.8165032336495966e+286 or 2.5128681478303627e+304 < (* (+ a (* b c)) c)

    1. Initial program 56.7

      \[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. Taylor expanded around inf 51.9

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

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

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

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

      \[\leadsto 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \mathsf{fma}\left(\left(\color{blue}{{i}^{1}} \cdot {b}^{1}\right) \cdot {c}^{1}, c, a \cdot \left(i \cdot c\right)\right)\right)\]
    8. Applied pow-prod-down4.4

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

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

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

    if -2.8165032336495966e+286 < (* (+ a (* b c)) c) < 2.5128681478303627e+304

    1. Initial program 0.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)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.3

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

Reproduce

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