Average Error: 6.2 → 2.0
Time: 10.3s
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(\sqrt{2} \cdot \left(\left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot \left(c \cdot i\right)\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(\sqrt{2} \cdot \left(\left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot \left(c \cdot i\right)\right)\right)\right)\right)
double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r728578 = 2.0;
        double r728579 = x;
        double r728580 = y;
        double r728581 = r728579 * r728580;
        double r728582 = z;
        double r728583 = t;
        double r728584 = r728582 * r728583;
        double r728585 = r728581 + r728584;
        double r728586 = a;
        double r728587 = b;
        double r728588 = c;
        double r728589 = r728587 * r728588;
        double r728590 = r728586 + r728589;
        double r728591 = r728590 * r728588;
        double r728592 = i;
        double r728593 = r728591 * r728592;
        double r728594 = r728585 - r728593;
        double r728595 = r728578 * r728594;
        return r728595;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r728596 = 2.0;
        double r728597 = x;
        double r728598 = y;
        double r728599 = z;
        double r728600 = t;
        double r728601 = r728599 * r728600;
        double r728602 = fma(r728597, r728598, r728601);
        double r728603 = sqrt(r728596);
        double r728604 = sqrt(r728603);
        double r728605 = c;
        double r728606 = b;
        double r728607 = a;
        double r728608 = fma(r728605, r728606, r728607);
        double r728609 = -r728608;
        double r728610 = i;
        double r728611 = r728605 * r728610;
        double r728612 = r728609 * r728611;
        double r728613 = r728603 * r728612;
        double r728614 = r728604 * r728613;
        double r728615 = r728604 * r728614;
        double r728616 = fma(r728596, r728602, r728615);
        return r728616;
}

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*2.0

    \[\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. 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(\sqrt{2} \cdot \left(\left(-\mathsf{fma}\left(c, b, a\right)\right) \cdot \left(c \cdot i\right)\right)\right)\right)\right)\]

Reproduce

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