Average Error: 6.2 → 2.0
Time: 9.4s
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)\]
\[\mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), \sqrt{\sqrt{2}} \cdot \left(\sqrt{\sqrt{2}} \cdot \left(\left(\sqrt{2} \cdot \left(-\mathsf{fma}\left(c, b, a\right)\right)\right) \cdot \left(c \cdot i\right)\right)\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)
\mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), \sqrt{\sqrt{2}} \cdot \left(\sqrt{\sqrt{2}} \cdot \left(\left(\sqrt{2} \cdot \left(-\mathsf{fma}\left(c, b, a\right)\right)\right) \cdot \left(c \cdot i\right)\right)\right)\right)
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r775673 = 2.0;
        double r775674 = x;
        double r775675 = y;
        double r775676 = r775674 * r775675;
        double r775677 = z;
        double r775678 = t;
        double r775679 = r775677 * r775678;
        double r775680 = r775676 + r775679;
        double r775681 = a;
        double r775682 = b;
        double r775683 = c;
        double r775684 = r775682 * r775683;
        double r775685 = r775681 + r775684;
        double r775686 = r775685 * r775683;
        double r775687 = i;
        double r775688 = r775686 * r775687;
        double r775689 = r775680 - r775688;
        double r775690 = r775673 * r775689;
        return r775690;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r775691 = 2.0;
        double r775692 = x;
        double r775693 = y;
        double r775694 = z;
        double r775695 = t;
        double r775696 = r775694 * r775695;
        double r775697 = fma(r775692, r775693, r775696);
        double r775698 = sqrt(r775691);
        double r775699 = sqrt(r775698);
        double r775700 = c;
        double r775701 = b;
        double r775702 = a;
        double r775703 = fma(r775700, r775701, r775702);
        double r775704 = -r775703;
        double r775705 = r775698 * r775704;
        double r775706 = i;
        double r775707 = r775700 * r775706;
        double r775708 = r775705 * r775707;
        double r775709 = r775699 * r775708;
        double r775710 = r775699 * r775709;
        double r775711 = fma(r775691, r775697, r775710);
        return r775711;
}

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
Herbie2.0
\[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.9

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

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

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

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

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

    \[\leadsto \mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), \color{blue}{\sqrt{\sqrt{2}} \cdot \left(\sqrt{\sqrt{2}} \cdot \left(\sqrt{2} \cdot \left(\left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot \left(c \cdot i\right)\right)\right)\right)}\right)\]
  10. Using strategy rm
  11. Applied associate-*r*2.0

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

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

Reproduce

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