Average Error: 5.8 → 1.9
Time: 23.5s
Precision: 64
\[2.0 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\]
\[2.0 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(c \cdot i\right) \cdot \mathsf{fma}\left(b, c, a\right)\right)\]
2.0 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)
2.0 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\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 r30897790 = 2.0;
        double r30897791 = x;
        double r30897792 = y;
        double r30897793 = r30897791 * r30897792;
        double r30897794 = z;
        double r30897795 = t;
        double r30897796 = r30897794 * r30897795;
        double r30897797 = r30897793 + r30897796;
        double r30897798 = a;
        double r30897799 = b;
        double r30897800 = c;
        double r30897801 = r30897799 * r30897800;
        double r30897802 = r30897798 + r30897801;
        double r30897803 = r30897802 * r30897800;
        double r30897804 = i;
        double r30897805 = r30897803 * r30897804;
        double r30897806 = r30897797 - r30897805;
        double r30897807 = r30897790 * r30897806;
        return r30897807;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r30897808 = 2.0;
        double r30897809 = t;
        double r30897810 = z;
        double r30897811 = y;
        double r30897812 = x;
        double r30897813 = r30897811 * r30897812;
        double r30897814 = fma(r30897809, r30897810, r30897813);
        double r30897815 = c;
        double r30897816 = i;
        double r30897817 = r30897815 * r30897816;
        double r30897818 = b;
        double r30897819 = a;
        double r30897820 = fma(r30897818, r30897815, r30897819);
        double r30897821 = r30897817 * r30897820;
        double r30897822 = r30897814 - r30897821;
        double r30897823 = r30897808 * r30897822;
        return r30897823;
}

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

Original5.8
Target1.9
Herbie1.9
\[2.0 \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 5.8

    \[2.0 \cdot \left(\left(x \cdot y + z \cdot t\right) - \left(\left(a + b \cdot c\right) \cdot c\right) \cdot i\right)\]
  2. Simplified5.8

    \[\leadsto \color{blue}{2.0 \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. Using strategy rm
  4. Applied associate-*r*5.5

    \[\leadsto 2.0 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \color{blue}{\left(i \cdot \mathsf{fma}\left(b, c, a\right)\right) \cdot c}\right)\]
  5. Using strategy rm
  6. Applied add-cube-cbrt5.8

    \[\leadsto 2.0 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(i \cdot \color{blue}{\left(\left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)} \cdot \sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)}\right) \cdot c\right)\]
  7. Applied associate-*r*5.8

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

    \[\leadsto 2.0 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(\left(i \cdot \left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)} \cdot \sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)\right) \cdot \sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right) \cdot \color{blue}{{c}^{1}}\right)\]
  10. Applied pow15.8

    \[\leadsto 2.0 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(\left(i \cdot \left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)} \cdot \sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)\right) \cdot \color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)}^{1}}\right) \cdot {c}^{1}\right)\]
  11. Applied pow15.8

    \[\leadsto 2.0 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(\left(i \cdot \left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)} \cdot \color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)}^{1}}\right)\right) \cdot {\left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)}^{1}\right) \cdot {c}^{1}\right)\]
  12. Applied pow15.8

    \[\leadsto 2.0 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(\left(i \cdot \left(\color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)}^{1}} \cdot {\left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)}^{1}\right)\right) \cdot {\left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)}^{1}\right) \cdot {c}^{1}\right)\]
  13. Applied pow-prod-down5.8

    \[\leadsto 2.0 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(\left(i \cdot \color{blue}{{\left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)} \cdot \sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)}^{1}}\right) \cdot {\left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)}^{1}\right) \cdot {c}^{1}\right)\]
  14. Applied pow15.8

    \[\leadsto 2.0 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(\left(\color{blue}{{i}^{1}} \cdot {\left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)} \cdot \sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)}^{1}\right) \cdot {\left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)}^{1}\right) \cdot {c}^{1}\right)\]
  15. Applied pow-prod-down5.8

    \[\leadsto 2.0 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \left(\color{blue}{{\left(i \cdot \left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)} \cdot \sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)\right)}^{1}} \cdot {\left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)}^{1}\right) \cdot {c}^{1}\right)\]
  16. Applied pow-prod-down5.8

    \[\leadsto 2.0 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \color{blue}{{\left(\left(i \cdot \left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)} \cdot \sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)\right) \cdot \sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)}^{1}} \cdot {c}^{1}\right)\]
  17. Applied pow-prod-down5.8

    \[\leadsto 2.0 \cdot \left(\mathsf{fma}\left(t, z, y \cdot x\right) - \color{blue}{{\left(\left(\left(i \cdot \left(\sqrt[3]{\mathsf{fma}\left(b, c, a\right)} \cdot \sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right)\right) \cdot \sqrt[3]{\mathsf{fma}\left(b, c, a\right)}\right) \cdot c\right)}^{1}}\right)\]
  18. Simplified1.9

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

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

Reproduce

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