Average Error: 6.1 → 1.5
Time: 34.0s
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, \mathsf{fma}\left(z, t, \left(\left(-i\right) \cdot c\right) \cdot \mathsf{fma}\left(c, b, a\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)
2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, \left(\left(-i\right) \cdot c\right) \cdot \mathsf{fma}\left(c, b, a\right)\right)\right)
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r479203 = 2.0;
        double r479204 = x;
        double r479205 = y;
        double r479206 = r479204 * r479205;
        double r479207 = z;
        double r479208 = t;
        double r479209 = r479207 * r479208;
        double r479210 = r479206 + r479209;
        double r479211 = a;
        double r479212 = b;
        double r479213 = c;
        double r479214 = r479212 * r479213;
        double r479215 = r479211 + r479214;
        double r479216 = r479215 * r479213;
        double r479217 = i;
        double r479218 = r479216 * r479217;
        double r479219 = r479210 - r479218;
        double r479220 = r479203 * r479219;
        return r479220;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r479221 = 2.0;
        double r479222 = y;
        double r479223 = x;
        double r479224 = z;
        double r479225 = t;
        double r479226 = i;
        double r479227 = -r479226;
        double r479228 = c;
        double r479229 = r479227 * r479228;
        double r479230 = b;
        double r479231 = a;
        double r479232 = fma(r479228, r479230, r479231);
        double r479233 = r479229 * r479232;
        double r479234 = fma(r479224, r479225, r479233);
        double r479235 = fma(r479222, r479223, r479234);
        double r479236 = r479221 * r479235;
        return r479236;
}

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

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

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

    \[\leadsto 2 \cdot \mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, \color{blue}{\left(-i\right) \cdot \left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)}\right)\right)\]
  6. Using strategy rm
  7. Applied associate-*r*1.5

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

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

Reproduce

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