Average Error: 6.3 → 1.9
Time: 38.4s
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)\]
\[2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, \mathsf{fma}\left(c, b, a\right) \cdot \left(\left(-i\right) \cdot c\right)\right)\right)\]
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 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, \mathsf{fma}\left(c, b, a\right) \cdot \left(\left(-i\right) \cdot c\right)\right)\right)
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r436614 = 2.0;
        double r436615 = x;
        double r436616 = y;
        double r436617 = r436615 * r436616;
        double r436618 = z;
        double r436619 = t;
        double r436620 = r436618 * r436619;
        double r436621 = r436617 + r436620;
        double r436622 = a;
        double r436623 = b;
        double r436624 = c;
        double r436625 = r436623 * r436624;
        double r436626 = r436622 + r436625;
        double r436627 = r436626 * r436624;
        double r436628 = i;
        double r436629 = r436627 * r436628;
        double r436630 = r436621 - r436629;
        double r436631 = r436614 * r436630;
        return r436631;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r436632 = 2.0;
        double r436633 = y;
        double r436634 = x;
        double r436635 = z;
        double r436636 = t;
        double r436637 = c;
        double r436638 = b;
        double r436639 = a;
        double r436640 = fma(r436637, r436638, r436639);
        double r436641 = i;
        double r436642 = -r436641;
        double r436643 = r436642 * r436637;
        double r436644 = r436640 * r436643;
        double r436645 = fma(r436635, r436636, r436644);
        double r436646 = fma(r436633, r436634, r436645);
        double r436647 = r436632 * r436646;
        return r436647;
}

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.9
Herbie1.9
\[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. Initial program 6.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. Simplified6.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. Using strategy rm
  4. Applied fma-neg6.3

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

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

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

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

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

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

Reproduce

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