Average Error: 6.7 → 1.8
Time: 27.8s
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(z, t, x \cdot y\right) - \left(c \cdot i\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(z, t, x \cdot y\right) - \left(c \cdot i\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 r403870 = 2.0;
        double r403871 = x;
        double r403872 = y;
        double r403873 = r403871 * r403872;
        double r403874 = z;
        double r403875 = t;
        double r403876 = r403874 * r403875;
        double r403877 = r403873 + r403876;
        double r403878 = a;
        double r403879 = b;
        double r403880 = c;
        double r403881 = r403879 * r403880;
        double r403882 = r403878 + r403881;
        double r403883 = r403882 * r403880;
        double r403884 = i;
        double r403885 = r403883 * r403884;
        double r403886 = r403877 - r403885;
        double r403887 = r403870 * r403886;
        return r403887;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r403888 = 2.0;
        double r403889 = z;
        double r403890 = t;
        double r403891 = x;
        double r403892 = y;
        double r403893 = r403891 * r403892;
        double r403894 = fma(r403889, r403890, r403893);
        double r403895 = c;
        double r403896 = i;
        double r403897 = r403895 * r403896;
        double r403898 = b;
        double r403899 = a;
        double r403900 = fma(r403898, r403895, r403899);
        double r403901 = r403897 * r403900;
        double r403902 = r403894 - r403901;
        double r403903 = r403888 * r403902;
        return r403903;
}

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

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

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

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

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

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

Reproduce

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