Average Error: 0.2 → 0.1
Time: 16.8s
Precision: 64
\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}\]
\[\left(\frac{x}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)} - \sqrt[3]{\frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}} \cdot \left(\sqrt[3]{\frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}} \cdot \sqrt[3]{\frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}}\right)\right) \cdot 6\]
\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}
\left(\frac{x}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)} - \sqrt[3]{\frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}} \cdot \left(\sqrt[3]{\frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}} \cdot \sqrt[3]{\frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}}\right)\right) \cdot 6
double f(double x) {
        double r35666607 = 6.0;
        double r35666608 = x;
        double r35666609 = 1.0;
        double r35666610 = r35666608 - r35666609;
        double r35666611 = r35666607 * r35666610;
        double r35666612 = r35666608 + r35666609;
        double r35666613 = 4.0;
        double r35666614 = sqrt(r35666608);
        double r35666615 = r35666613 * r35666614;
        double r35666616 = r35666612 + r35666615;
        double r35666617 = r35666611 / r35666616;
        return r35666617;
}

double f(double x) {
        double r35666618 = x;
        double r35666619 = sqrt(r35666618);
        double r35666620 = 4.0;
        double r35666621 = 1.0;
        double r35666622 = r35666618 + r35666621;
        double r35666623 = fma(r35666619, r35666620, r35666622);
        double r35666624 = r35666618 / r35666623;
        double r35666625 = r35666621 / r35666623;
        double r35666626 = cbrt(r35666625);
        double r35666627 = r35666626 * r35666626;
        double r35666628 = r35666626 * r35666627;
        double r35666629 = r35666624 - r35666628;
        double r35666630 = 6.0;
        double r35666631 = r35666629 * r35666630;
        return r35666631;
}

Error

Bits error versus x

Target

Original0.2
Target0.0
Herbie0.1
\[\frac{6}{\frac{\left(x + 1\right) + 4 \cdot \sqrt{x}}{x - 1}}\]

Derivation

  1. Initial program 0.2

    \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}\]
  2. Simplified0.0

    \[\leadsto \color{blue}{6 \cdot \frac{x - 1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}}\]
  3. Using strategy rm
  4. Applied div-sub0.0

    \[\leadsto 6 \cdot \color{blue}{\left(\frac{x}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)} - \frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}\right)}\]
  5. Using strategy rm
  6. Applied add-cube-cbrt0.1

    \[\leadsto 6 \cdot \left(\frac{x}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)} - \color{blue}{\left(\sqrt[3]{\frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}} \cdot \sqrt[3]{\frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}}\right) \cdot \sqrt[3]{\frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}}}\right)\]
  7. Final simplification0.1

    \[\leadsto \left(\frac{x}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)} - \sqrt[3]{\frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}} \cdot \left(\sqrt[3]{\frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}} \cdot \sqrt[3]{\frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}}\right)\right) \cdot 6\]

Reproduce

herbie shell --seed 2019171 +o rules:numerics
(FPCore (x)
  :name "Data.Approximate.Numerics:blog from approximate-0.2.2.1"

  :herbie-target
  (/ 6.0 (/ (+ (+ x 1.0) (* 4.0 (sqrt x))) (- x 1.0)))

  (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))))