Average Error: 6.2 → 1.8
Time: 31.0s
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)\]
\[\left(2 \cdot t\right) \cdot z + \mathsf{fma}\left(\mathsf{fma}\left(c, b, a\right), \left(-i\right) \cdot c, x \cdot y\right) \cdot 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)
\left(2 \cdot t\right) \cdot z + \mathsf{fma}\left(\mathsf{fma}\left(c, b, a\right), \left(-i\right) \cdot c, x \cdot y\right) \cdot 2
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r574958 = 2.0;
        double r574959 = x;
        double r574960 = y;
        double r574961 = r574959 * r574960;
        double r574962 = z;
        double r574963 = t;
        double r574964 = r574962 * r574963;
        double r574965 = r574961 + r574964;
        double r574966 = a;
        double r574967 = b;
        double r574968 = c;
        double r574969 = r574967 * r574968;
        double r574970 = r574966 + r574969;
        double r574971 = r574970 * r574968;
        double r574972 = i;
        double r574973 = r574971 * r574972;
        double r574974 = r574965 - r574973;
        double r574975 = r574958 * r574974;
        return r574975;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r574976 = 2.0;
        double r574977 = t;
        double r574978 = r574976 * r574977;
        double r574979 = z;
        double r574980 = r574978 * r574979;
        double r574981 = c;
        double r574982 = b;
        double r574983 = a;
        double r574984 = fma(r574981, r574982, r574983);
        double r574985 = i;
        double r574986 = -r574985;
        double r574987 = r574986 * r574981;
        double r574988 = x;
        double r574989 = y;
        double r574990 = r574988 * r574989;
        double r574991 = fma(r574984, r574987, r574990);
        double r574992 = r574991 * r574976;
        double r574993 = r574980 + r574992;
        return r574993;
}

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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