Average Error: 6.5 → 1.8
Time: 20.5s
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, z \cdot t - \left(i \cdot c\right) \cdot \mathsf{fma}\left(c, b, a\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, z \cdot t - \left(i \cdot c\right) \cdot \mathsf{fma}\left(c, b, a\right)\right)
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r553538 = 2.0;
        double r553539 = x;
        double r553540 = y;
        double r553541 = r553539 * r553540;
        double r553542 = z;
        double r553543 = t;
        double r553544 = r553542 * r553543;
        double r553545 = r553541 + r553544;
        double r553546 = a;
        double r553547 = b;
        double r553548 = c;
        double r553549 = r553547 * r553548;
        double r553550 = r553546 + r553549;
        double r553551 = r553550 * r553548;
        double r553552 = i;
        double r553553 = r553551 * r553552;
        double r553554 = r553545 - r553553;
        double r553555 = r553538 * r553554;
        return r553555;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r553556 = 2.0;
        double r553557 = y;
        double r553558 = x;
        double r553559 = z;
        double r553560 = t;
        double r553561 = r553559 * r553560;
        double r553562 = i;
        double r553563 = c;
        double r553564 = r553562 * r553563;
        double r553565 = b;
        double r553566 = a;
        double r553567 = fma(r553563, r553565, r553566);
        double r553568 = r553564 * r553567;
        double r553569 = r553561 - r553568;
        double r553570 = fma(r553557, r553558, r553569);
        double r553571 = r553556 * r553570;
        return r553571;
}

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.8
Herbie1.8
\[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.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. Simplified6.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 pow16.5

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

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

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

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

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

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

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

Reproduce

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