Average Error: 6.2 → 1.8
Time: 34.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)\]
\[2 \cdot \left(\mathsf{fma}\left(y, x, t \cdot z\right) - \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 \left(\mathsf{fma}\left(y, x, t \cdot z\right) - \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 r28795058 = 2.0;
        double r28795059 = x;
        double r28795060 = y;
        double r28795061 = r28795059 * r28795060;
        double r28795062 = z;
        double r28795063 = t;
        double r28795064 = r28795062 * r28795063;
        double r28795065 = r28795061 + r28795064;
        double r28795066 = a;
        double r28795067 = b;
        double r28795068 = c;
        double r28795069 = r28795067 * r28795068;
        double r28795070 = r28795066 + r28795069;
        double r28795071 = r28795070 * r28795068;
        double r28795072 = i;
        double r28795073 = r28795071 * r28795072;
        double r28795074 = r28795065 - r28795073;
        double r28795075 = r28795058 * r28795074;
        return r28795075;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r28795076 = 2.0;
        double r28795077 = y;
        double r28795078 = x;
        double r28795079 = t;
        double r28795080 = z;
        double r28795081 = r28795079 * r28795080;
        double r28795082 = fma(r28795077, r28795078, r28795081);
        double r28795083 = i;
        double r28795084 = c;
        double r28795085 = r28795083 * r28795084;
        double r28795086 = b;
        double r28795087 = a;
        double r28795088 = fma(r28795084, r28795086, r28795087);
        double r28795089 = r28795085 * r28795088;
        double r28795090 = r28795082 - r28795089;
        double r28795091 = r28795076 * r28795090;
        return r28795091;
}

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. Taylor expanded around inf 8.7

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

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

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

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

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

    \[\leadsto 2 \cdot \left(\mathsf{fma}\left(y, x, t \cdot z\right) - \left(i \cdot c\right) \cdot \mathsf{fma}\left(c, b, 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))))