Average Error: 6.7 → 1.9
Time: 16.7s
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, z \cdot t - \left(i \cdot c\right) \cdot \mathsf{fma}\left(c, b, a\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, z \cdot t - \left(i \cdot c\right) \cdot \mathsf{fma}\left(c, b, a\right)\right)
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r461094 = 2.0;
        double r461095 = x;
        double r461096 = y;
        double r461097 = r461095 * r461096;
        double r461098 = z;
        double r461099 = t;
        double r461100 = r461098 * r461099;
        double r461101 = r461097 + r461100;
        double r461102 = a;
        double r461103 = b;
        double r461104 = c;
        double r461105 = r461103 * r461104;
        double r461106 = r461102 + r461105;
        double r461107 = r461106 * r461104;
        double r461108 = i;
        double r461109 = r461107 * r461108;
        double r461110 = r461101 - r461109;
        double r461111 = r461094 * r461110;
        return r461111;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r461112 = 2.0;
        double r461113 = y;
        double r461114 = x;
        double r461115 = z;
        double r461116 = t;
        double r461117 = r461115 * r461116;
        double r461118 = i;
        double r461119 = c;
        double r461120 = r461118 * r461119;
        double r461121 = b;
        double r461122 = a;
        double r461123 = fma(r461119, r461121, r461122);
        double r461124 = r461120 * r461123;
        double r461125 = r461117 - r461124;
        double r461126 = fma(r461113, r461114, r461125);
        double r461127 = r461112 * r461126;
        return r461127;
}

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

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

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

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

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

    \[\leadsto 2 \cdot \mathsf{fma}\left(y, x, z \cdot t - \left(\color{blue}{{c}^{1}} \cdot {\left(\mathsf{fma}\left(c, b, a\right)\right)}^{1}\right) \cdot {i}^{1}\right)\]
  7. Applied pow-prod-down6.7

    \[\leadsto 2 \cdot \mathsf{fma}\left(y, x, z \cdot t - \color{blue}{{\left(c \cdot \mathsf{fma}\left(c, b, a\right)\right)}^{1}} \cdot {i}^{1}\right)\]
  8. Applied pow-prod-down6.7

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

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

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

Reproduce

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