Average Error: 6.3 → 1.4
Time: 37.7s
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 -5.065469180562588569878166538565081134378 \cdot 10^{-39} \lor \neg \left(i \le 6.761551533703822259416640751121583901684 \cdot 10^{53}\right):\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right) \cdot i\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - c \cdot \left(\mathsf{fma}\left(c, b, a\right) \cdot i\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}\;i \le -5.065469180562588569878166538565081134378 \cdot 10^{-39} \lor \neg \left(i \le 6.761551533703822259416640751121583901684 \cdot 10^{53}\right):\\
\;\;\;\;2 \cdot \mathsf{fma}\left(y, x, z \cdot t - \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right) \cdot i\right)\\

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

\end{array}
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r389589 = 2.0;
        double r389590 = x;
        double r389591 = y;
        double r389592 = r389590 * r389591;
        double r389593 = z;
        double r389594 = t;
        double r389595 = r389593 * r389594;
        double r389596 = r389592 + r389595;
        double r389597 = a;
        double r389598 = b;
        double r389599 = c;
        double r389600 = r389598 * r389599;
        double r389601 = r389597 + r389600;
        double r389602 = r389601 * r389599;
        double r389603 = i;
        double r389604 = r389602 * r389603;
        double r389605 = r389596 - r389604;
        double r389606 = r389589 * r389605;
        return r389606;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r389607 = i;
        double r389608 = -5.0654691805625886e-39;
        bool r389609 = r389607 <= r389608;
        double r389610 = 6.761551533703822e+53;
        bool r389611 = r389607 <= r389610;
        double r389612 = !r389611;
        bool r389613 = r389609 || r389612;
        double r389614 = 2.0;
        double r389615 = y;
        double r389616 = x;
        double r389617 = z;
        double r389618 = t;
        double r389619 = r389617 * r389618;
        double r389620 = c;
        double r389621 = b;
        double r389622 = a;
        double r389623 = fma(r389620, r389621, r389622);
        double r389624 = r389620 * r389623;
        double r389625 = r389624 * r389607;
        double r389626 = r389619 - r389625;
        double r389627 = fma(r389615, r389616, r389626);
        double r389628 = r389614 * r389627;
        double r389629 = r389623 * r389607;
        double r389630 = r389620 * r389629;
        double r389631 = r389619 - r389630;
        double r389632 = fma(r389615, r389616, r389631);
        double r389633 = r389614 * r389632;
        double r389634 = r389613 ? r389628 : r389633;
        return r389634;
}

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.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 i < -5.0654691805625886e-39 or 6.761551533703822e+53 < i

    1. Initial program 0.8

      \[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. Simplified0.8

      \[\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)}\]

    if -5.0654691805625886e-39 < i < 6.761551533703822e+53

    1. Initial program 9.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. Simplified9.7

      \[\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 associate-*l*1.7

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

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

Reproduce

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