Average Error: 6.2 → 1.7
Time: 19.8s
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 r503830 = 2.0;
        double r503831 = x;
        double r503832 = y;
        double r503833 = r503831 * r503832;
        double r503834 = z;
        double r503835 = t;
        double r503836 = r503834 * r503835;
        double r503837 = r503833 + r503836;
        double r503838 = a;
        double r503839 = b;
        double r503840 = c;
        double r503841 = r503839 * r503840;
        double r503842 = r503838 + r503841;
        double r503843 = r503842 * r503840;
        double r503844 = i;
        double r503845 = r503843 * r503844;
        double r503846 = r503837 - r503845;
        double r503847 = r503830 * r503846;
        return r503847;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r503848 = 2.0;
        double r503849 = y;
        double r503850 = x;
        double r503851 = z;
        double r503852 = t;
        double r503853 = r503851 * r503852;
        double r503854 = i;
        double r503855 = c;
        double r503856 = r503854 * r503855;
        double r503857 = b;
        double r503858 = a;
        double r503859 = fma(r503855, r503857, r503858);
        double r503860 = r503856 * r503859;
        double r503861 = r503853 - r503860;
        double r503862 = fma(r503849, r503850, r503861);
        double r503863 = r503848 * r503862;
        return r503863;
}

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.2
Target1.7
Herbie1.7
\[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.2

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

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

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

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

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

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

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

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

    \[\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 2019198 +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))))