Average Error: 5.8 → 1.8
Time: 25.7s
Precision: 64
\[2.0 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\]
\[2.0 \cdot \left(\mathsf{fma}\left(y, x, t \cdot z - \mathsf{fma}\left(b, c, a\right) \cdot \left(i \cdot c\right)\right) + \mathsf{fma}\left(b, c, a\right) \cdot \left(\left(-c\right) \cdot i + i \cdot c\right)\right)\]
2.0 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
2.0 \cdot \left(\mathsf{fma}\left(y, x, t \cdot z - \mathsf{fma}\left(b, c, a\right) \cdot \left(i \cdot c\right)\right) + \mathsf{fma}\left(b, c, a\right) \cdot \left(\left(-c\right) \cdot i + i \cdot c\right)\right)
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r29540868 = 2.0;
        double r29540869 = x;
        double r29540870 = y;
        double r29540871 = r29540869 * r29540870;
        double r29540872 = z;
        double r29540873 = t;
        double r29540874 = r29540872 * r29540873;
        double r29540875 = r29540871 + r29540874;
        double r29540876 = a;
        double r29540877 = b;
        double r29540878 = c;
        double r29540879 = r29540877 * r29540878;
        double r29540880 = r29540876 + r29540879;
        double r29540881 = r29540880 * r29540878;
        double r29540882 = i;
        double r29540883 = r29540881 * r29540882;
        double r29540884 = r29540875 - r29540883;
        double r29540885 = r29540868 * r29540884;
        return r29540885;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r29540886 = 2.0;
        double r29540887 = y;
        double r29540888 = x;
        double r29540889 = t;
        double r29540890 = z;
        double r29540891 = r29540889 * r29540890;
        double r29540892 = b;
        double r29540893 = c;
        double r29540894 = a;
        double r29540895 = fma(r29540892, r29540893, r29540894);
        double r29540896 = i;
        double r29540897 = r29540896 * r29540893;
        double r29540898 = r29540895 * r29540897;
        double r29540899 = r29540891 - r29540898;
        double r29540900 = fma(r29540887, r29540888, r29540899);
        double r29540901 = -r29540893;
        double r29540902 = r29540901 * r29540896;
        double r29540903 = r29540902 + r29540897;
        double r29540904 = r29540895 * r29540903;
        double r29540905 = r29540900 + r29540904;
        double r29540906 = r29540886 * r29540905;
        return r29540906;
}

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

Original5.8
Target1.7
Herbie1.8
\[2.0 \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 5.8

    \[2.0 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\]
  2. Using strategy rm
  3. Applied associate-*l*1.7

    \[\leadsto 2.0 \cdot \left(\left(x \cdot y + z \cdot t\right) - \color{blue}{\left(a + b \cdot c\right) \cdot \left(c \cdot i\right)}\right)\]
  4. Using strategy rm
  5. Applied add-sqr-sqrt32.0

    \[\leadsto 2.0 \cdot \left(\color{blue}{\sqrt{x \cdot y + z \cdot t} \cdot \sqrt{x \cdot y + z \cdot t}} - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right)\]
  6. Applied prod-diff32.0

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

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

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

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

Reproduce

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