Average Error: 6.3 → 1.8
Time: 29.7s
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(\left(\left(\mathsf{fma}\left(x, y, t \cdot z\right) - \left(b \cdot c\right) \cdot \left(c \cdot i\right)\right) - a \cdot \left(c \cdot i\right)\right) + \mathsf{fma}\left(b, c, a\right) \cdot \mathsf{fma}\left(-i, c, c \cdot i\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(\left(\left(\mathsf{fma}\left(x, y, t \cdot z\right) - \left(b \cdot c\right) \cdot \left(c \cdot i\right)\right) - a \cdot \left(c \cdot i\right)\right) + \mathsf{fma}\left(b, c, a\right) \cdot \mathsf{fma}\left(-i, c, c \cdot i\right)\right)
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r452990 = 2.0;
        double r452991 = x;
        double r452992 = y;
        double r452993 = r452991 * r452992;
        double r452994 = z;
        double r452995 = t;
        double r452996 = r452994 * r452995;
        double r452997 = r452993 + r452996;
        double r452998 = a;
        double r452999 = b;
        double r453000 = c;
        double r453001 = r452999 * r453000;
        double r453002 = r452998 + r453001;
        double r453003 = r453002 * r453000;
        double r453004 = i;
        double r453005 = r453003 * r453004;
        double r453006 = r452997 - r453005;
        double r453007 = r452990 * r453006;
        return r453007;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r453008 = 2.0;
        double r453009 = x;
        double r453010 = y;
        double r453011 = t;
        double r453012 = z;
        double r453013 = r453011 * r453012;
        double r453014 = fma(r453009, r453010, r453013);
        double r453015 = b;
        double r453016 = c;
        double r453017 = r453015 * r453016;
        double r453018 = i;
        double r453019 = r453016 * r453018;
        double r453020 = r453017 * r453019;
        double r453021 = r453014 - r453020;
        double r453022 = a;
        double r453023 = r453022 * r453019;
        double r453024 = r453021 - r453023;
        double r453025 = fma(r453015, r453016, r453022);
        double r453026 = -r453018;
        double r453027 = fma(r453026, r453016, r453019);
        double r453028 = r453025 * r453027;
        double r453029 = r453024 + r453028;
        double r453030 = r453008 * r453029;
        return r453030;
}

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

    \[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. Using strategy rm
  3. Applied associate-*l*1.8

    \[\leadsto 2 \cdot \left(\left(x \cdot y + z \cdot t\right) - \color{blue}{\left(a + b \cdot c\right) \cdot \left(c \cdot i\right)}\right)\]
  4. Using strategy rm
  5. Applied add-sqr-sqrt31.9

    \[\leadsto 2 \cdot \left(\color{blue}{\sqrt{x \cdot y + z \cdot t} \cdot \sqrt{x \cdot y + z \cdot t}} - \left(a + b \cdot c\right) \cdot \left(c \cdot i\right)\right)\]
  6. Applied prod-diff31.9

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

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

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

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

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

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

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

Reproduce

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