Average Error: 6.2 → 1.8
Time: 25.5s
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 \left(\mathsf{fma}\left(y, x, z \cdot t\right) - \left(i \cdot c\right) \cdot \mathsf{fma}\left(b, c, 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 \left(\mathsf{fma}\left(y, x, z \cdot t\right) - \left(i \cdot c\right) \cdot \mathsf{fma}\left(b, c, a\right)\right)
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r25097147 = 2.0;
        double r25097148 = x;
        double r25097149 = y;
        double r25097150 = r25097148 * r25097149;
        double r25097151 = z;
        double r25097152 = t;
        double r25097153 = r25097151 * r25097152;
        double r25097154 = r25097150 + r25097153;
        double r25097155 = a;
        double r25097156 = b;
        double r25097157 = c;
        double r25097158 = r25097156 * r25097157;
        double r25097159 = r25097155 + r25097158;
        double r25097160 = r25097159 * r25097157;
        double r25097161 = i;
        double r25097162 = r25097160 * r25097161;
        double r25097163 = r25097154 - r25097162;
        double r25097164 = r25097147 * r25097163;
        return r25097164;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r25097165 = 2.0;
        double r25097166 = y;
        double r25097167 = x;
        double r25097168 = z;
        double r25097169 = t;
        double r25097170 = r25097168 * r25097169;
        double r25097171 = fma(r25097166, r25097167, r25097170);
        double r25097172 = i;
        double r25097173 = c;
        double r25097174 = r25097172 * r25097173;
        double r25097175 = b;
        double r25097176 = a;
        double r25097177 = fma(r25097175, r25097173, r25097176);
        double r25097178 = r25097174 * r25097177;
        double r25097179 = r25097171 - r25097178;
        double r25097180 = r25097165 * r25097179;
        return r25097180;
}

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.8
Herbie1.8
\[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. Simplified6.2

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

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

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

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

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

    \[\leadsto 2 \cdot \left(\mathsf{fma}\left(y, x, z \cdot t\right) - \color{blue}{\left(i \cdot \left(b \cdot c\right) + i \cdot a\right)} \cdot c\right)\]
  10. Using strategy rm
  11. Applied *-un-lft-identity5.1

    \[\leadsto 2 \cdot \left(\mathsf{fma}\left(y, x, z \cdot t\right) - \color{blue}{\left(1 \cdot \left(i \cdot \left(b \cdot c\right) + i \cdot a\right)\right)} \cdot c\right)\]
  12. Applied associate-*l*5.1

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

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

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

Reproduce

herbie shell --seed 2019172 +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"

  :herbie-target
  (* 2.0 (- (+ (* x y) (* z t)) (* (+ a (* b c)) (* c i))))

  (* 2.0 (- (+ (* x y) (* z t)) (* (* (+ a (* b c)) c) i))))