Average Error: 6.4 → 1.7
Time: 11.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)\]
\[\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 r774422 = 2.0;
        double r774423 = x;
        double r774424 = y;
        double r774425 = r774423 * r774424;
        double r774426 = z;
        double r774427 = t;
        double r774428 = r774426 * r774427;
        double r774429 = r774425 + r774428;
        double r774430 = a;
        double r774431 = b;
        double r774432 = c;
        double r774433 = r774431 * r774432;
        double r774434 = r774430 + r774433;
        double r774435 = r774434 * r774432;
        double r774436 = i;
        double r774437 = r774435 * r774436;
        double r774438 = r774429 - r774437;
        double r774439 = r774422 * r774438;
        return r774439;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r774440 = 2.0;
        double r774441 = x;
        double r774442 = y;
        double r774443 = z;
        double r774444 = t;
        double r774445 = r774443 * r774444;
        double r774446 = fma(r774441, r774442, r774445);
        double r774447 = sqrt(r774440);
        double r774448 = sqrt(r774447);
        double r774449 = c;
        double r774450 = b;
        double r774451 = a;
        double r774452 = fma(r774449, r774450, r774451);
        double r774453 = -r774452;
        double r774454 = i;
        double r774455 = r774449 * r774454;
        double r774456 = r774453 * r774455;
        double r774457 = r774447 * r774456;
        double r774458 = r774448 * r774457;
        double r774459 = r774448 * r774458;
        double r774460 = fma(r774440, r774446, r774459);
        return r774460;
}

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.4
Target1.7
Herbie1.7
\[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.4

    \[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}{\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-sqrt1.9

    \[\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*1.8

    \[\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-sqrt1.8

    \[\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.7

    \[\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.7

    \[\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 simplification1.7

    \[\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 2019353 +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))))