Average Error: 6.2 → 1.8
Time: 35.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 \mathsf{fma}\left(y, x, \mathsf{fma}\left(\left(-c\right) \cdot i, \mathsf{fma}\left(c, b, a\right), z \cdot t\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, \mathsf{fma}\left(\left(-c\right) \cdot i, \mathsf{fma}\left(c, b, a\right), z \cdot t\right)\right)
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r411046 = 2.0;
        double r411047 = x;
        double r411048 = y;
        double r411049 = r411047 * r411048;
        double r411050 = z;
        double r411051 = t;
        double r411052 = r411050 * r411051;
        double r411053 = r411049 + r411052;
        double r411054 = a;
        double r411055 = b;
        double r411056 = c;
        double r411057 = r411055 * r411056;
        double r411058 = r411054 + r411057;
        double r411059 = r411058 * r411056;
        double r411060 = i;
        double r411061 = r411059 * r411060;
        double r411062 = r411053 - r411061;
        double r411063 = r411046 * r411062;
        return r411063;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r411064 = 2.0;
        double r411065 = y;
        double r411066 = x;
        double r411067 = c;
        double r411068 = -r411067;
        double r411069 = i;
        double r411070 = r411068 * r411069;
        double r411071 = b;
        double r411072 = a;
        double r411073 = fma(r411067, r411071, r411072);
        double r411074 = z;
        double r411075 = t;
        double r411076 = r411074 * r411075;
        double r411077 = fma(r411070, r411073, r411076);
        double r411078 = fma(r411065, r411066, r411077);
        double r411079 = r411064 * r411078;
        return r411079;
}

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.9
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 \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 associate-*l*5.4

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

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

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

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

Reproduce

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