Average Error: 6.4 → 1.9
Time: 37.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)\]
\[2 \cdot \mathsf{fma}\left(y, x, z \cdot t - \left(c \cdot i\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(c \cdot i\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 r516627 = 2.0;
        double r516628 = x;
        double r516629 = y;
        double r516630 = r516628 * r516629;
        double r516631 = z;
        double r516632 = t;
        double r516633 = r516631 * r516632;
        double r516634 = r516630 + r516633;
        double r516635 = a;
        double r516636 = b;
        double r516637 = c;
        double r516638 = r516636 * r516637;
        double r516639 = r516635 + r516638;
        double r516640 = r516639 * r516637;
        double r516641 = i;
        double r516642 = r516640 * r516641;
        double r516643 = r516634 - r516642;
        double r516644 = r516627 * r516643;
        return r516644;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r516645 = 2.0;
        double r516646 = y;
        double r516647 = x;
        double r516648 = z;
        double r516649 = t;
        double r516650 = r516648 * r516649;
        double r516651 = c;
        double r516652 = i;
        double r516653 = r516651 * r516652;
        double r516654 = b;
        double r516655 = a;
        double r516656 = fma(r516651, r516654, r516655);
        double r516657 = r516653 * r516656;
        double r516658 = r516650 - r516657;
        double r516659 = fma(r516646, r516647, r516658);
        double r516660 = r516645 * r516659;
        return r516660;
}

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.4
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.4

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

    \[\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*5.6

    \[\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)\]
  5. Using strategy rm
  6. Applied add-cube-cbrt5.9

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

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

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

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

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

Reproduce

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