Average Error: 6.3 → 1.9
Time: 7.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)\]
\[\mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \left(\left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot \left(c \cdot i\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)
\mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), 2 \cdot \left(\left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot \left(c \cdot i\right)\right)\right)
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r2180157 = 2.0;
        double r2180158 = x;
        double r2180159 = y;
        double r2180160 = r2180158 * r2180159;
        double r2180161 = z;
        double r2180162 = t;
        double r2180163 = r2180161 * r2180162;
        double r2180164 = r2180160 + r2180163;
        double r2180165 = a;
        double r2180166 = b;
        double r2180167 = c;
        double r2180168 = r2180166 * r2180167;
        double r2180169 = r2180165 + r2180168;
        double r2180170 = r2180169 * r2180167;
        double r2180171 = i;
        double r2180172 = r2180170 * r2180171;
        double r2180173 = r2180164 - r2180172;
        double r2180174 = r2180157 * r2180173;
        return r2180174;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r2180175 = 2.0;
        double r2180176 = x;
        double r2180177 = y;
        double r2180178 = z;
        double r2180179 = t;
        double r2180180 = r2180178 * r2180179;
        double r2180181 = fma(r2180176, r2180177, r2180180);
        double r2180182 = c;
        double r2180183 = b;
        double r2180184 = a;
        double r2180185 = fma(r2180182, r2180183, r2180184);
        double r2180186 = -r2180185;
        double r2180187 = i;
        double r2180188 = r2180182 * r2180187;
        double r2180189 = r2180186 * r2180188;
        double r2180190 = r2180175 * r2180189;
        double r2180191 = fma(r2180175, r2180181, r2180190);
        return r2180191;
}

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. Simplified1.9

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

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

Reproduce

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