Average Error: 6.5 → 1.9
Time: 10.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)\]
\[\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 r693385 = 2.0;
        double r693386 = x;
        double r693387 = y;
        double r693388 = r693386 * r693387;
        double r693389 = z;
        double r693390 = t;
        double r693391 = r693389 * r693390;
        double r693392 = r693388 + r693391;
        double r693393 = a;
        double r693394 = b;
        double r693395 = c;
        double r693396 = r693394 * r693395;
        double r693397 = r693393 + r693396;
        double r693398 = r693397 * r693395;
        double r693399 = i;
        double r693400 = r693398 * r693399;
        double r693401 = r693392 - r693400;
        double r693402 = r693385 * r693401;
        return r693402;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r693403 = 2.0;
        double r693404 = x;
        double r693405 = y;
        double r693406 = z;
        double r693407 = t;
        double r693408 = r693406 * r693407;
        double r693409 = fma(r693404, r693405, r693408);
        double r693410 = c;
        double r693411 = b;
        double r693412 = a;
        double r693413 = fma(r693410, r693411, r693412);
        double r693414 = -r693413;
        double r693415 = i;
        double r693416 = r693410 * r693415;
        double r693417 = r693414 * r693416;
        double r693418 = r693403 * r693417;
        double r693419 = fma(r693403, r693409, r693418);
        return r693419;
}

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.5
Target2.0
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.5

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