Average Error: 6.2 → 1.6
Time: 8.9s
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 r1422190 = 2.0;
        double r1422191 = x;
        double r1422192 = y;
        double r1422193 = r1422191 * r1422192;
        double r1422194 = z;
        double r1422195 = t;
        double r1422196 = r1422194 * r1422195;
        double r1422197 = r1422193 + r1422196;
        double r1422198 = a;
        double r1422199 = b;
        double r1422200 = c;
        double r1422201 = r1422199 * r1422200;
        double r1422202 = r1422198 + r1422201;
        double r1422203 = r1422202 * r1422200;
        double r1422204 = i;
        double r1422205 = r1422203 * r1422204;
        double r1422206 = r1422197 - r1422205;
        double r1422207 = r1422190 * r1422206;
        return r1422207;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r1422208 = 2.0;
        double r1422209 = x;
        double r1422210 = y;
        double r1422211 = z;
        double r1422212 = t;
        double r1422213 = r1422211 * r1422212;
        double r1422214 = fma(r1422209, r1422210, r1422213);
        double r1422215 = c;
        double r1422216 = b;
        double r1422217 = a;
        double r1422218 = fma(r1422215, r1422216, r1422217);
        double r1422219 = -r1422218;
        double r1422220 = i;
        double r1422221 = r1422215 * r1422220;
        double r1422222 = r1422219 * r1422221;
        double r1422223 = r1422208 * r1422222;
        double r1422224 = fma(r1422208, r1422214, r1422223);
        return r1422224;
}

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.6
Herbie1.6
\[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. Simplified1.6

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

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