Average Error: 6.2 → 1.9
Time: 12.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{1} \cdot \left(\left({\left(\sqrt{\sqrt{2}}\right)}^{3} \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{1} \cdot \left(\left({\left(\sqrt{\sqrt{2}}\right)}^{3} \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 r1260373 = 2.0;
        double r1260374 = x;
        double r1260375 = y;
        double r1260376 = r1260374 * r1260375;
        double r1260377 = z;
        double r1260378 = t;
        double r1260379 = r1260377 * r1260378;
        double r1260380 = r1260376 + r1260379;
        double r1260381 = a;
        double r1260382 = b;
        double r1260383 = c;
        double r1260384 = r1260382 * r1260383;
        double r1260385 = r1260381 + r1260384;
        double r1260386 = r1260385 * r1260383;
        double r1260387 = i;
        double r1260388 = r1260386 * r1260387;
        double r1260389 = r1260380 - r1260388;
        double r1260390 = r1260373 * r1260389;
        return r1260390;
}

double f(double x, double y, double z, double t, double a, double b, double c, double i) {
        double r1260391 = 2.0;
        double r1260392 = x;
        double r1260393 = y;
        double r1260394 = z;
        double r1260395 = t;
        double r1260396 = r1260394 * r1260395;
        double r1260397 = fma(r1260392, r1260393, r1260396);
        double r1260398 = sqrt(r1260391);
        double r1260399 = sqrt(r1260398);
        double r1260400 = 1.0;
        double r1260401 = sqrt(r1260400);
        double r1260402 = 3.0;
        double r1260403 = pow(r1260399, r1260402);
        double r1260404 = c;
        double r1260405 = b;
        double r1260406 = a;
        double r1260407 = fma(r1260404, r1260405, r1260406);
        double r1260408 = -r1260407;
        double r1260409 = r1260403 * r1260408;
        double r1260410 = i;
        double r1260411 = r1260404 * r1260410;
        double r1260412 = r1260409 * r1260411;
        double r1260413 = r1260401 * r1260412;
        double r1260414 = r1260399 * r1260413;
        double r1260415 = fma(r1260391, r1260397, r1260414);
        return r1260415;
}

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

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

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

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

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

    \[\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 *-un-lft-identity1.8

    \[\leadsto \mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), \sqrt{\sqrt{2}} \cdot \left(\sqrt{\color{blue}{1 \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)\right)\]
  12. Applied sqrt-prod1.8

    \[\leadsto \mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), \sqrt{\sqrt{2}} \cdot \left(\color{blue}{\left(\sqrt{1} \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)\right)\]
  13. Applied associate-*l*1.8

    \[\leadsto \mathsf{fma}\left(2, \mathsf{fma}\left(x, y, z \cdot t\right), \sqrt{\sqrt{2}} \cdot \color{blue}{\left(\sqrt{1} \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)}\right)\]
  14. Simplified1.9

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

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

Reproduce

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