Average Error: 0.2 → 0.0
Time: 3.7s
Precision: 64
\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}\]
\[6 \cdot \frac{x - 1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}\]
\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}
6 \cdot \frac{x - 1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}
double f(double x) {
        double r807929 = 6.0;
        double r807930 = x;
        double r807931 = 1.0;
        double r807932 = r807930 - r807931;
        double r807933 = r807929 * r807932;
        double r807934 = r807930 + r807931;
        double r807935 = 4.0;
        double r807936 = sqrt(r807930);
        double r807937 = r807935 * r807936;
        double r807938 = r807934 + r807937;
        double r807939 = r807933 / r807938;
        return r807939;
}

double f(double x) {
        double r807940 = 6.0;
        double r807941 = x;
        double r807942 = 1.0;
        double r807943 = r807941 - r807942;
        double r807944 = sqrt(r807941);
        double r807945 = 4.0;
        double r807946 = r807941 + r807942;
        double r807947 = fma(r807944, r807945, r807946);
        double r807948 = r807943 / r807947;
        double r807949 = r807940 * r807948;
        return r807949;
}

Error

Bits error versus x

Target

Original0.2
Target0.1
Herbie0.0
\[\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}{\frac{x - 1}{\frac{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}{6}}}\]
  3. Using strategy rm
  4. Applied associate-/r/0.0

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

    \[\leadsto \color{blue}{\log \left(e^{\frac{x - 1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}}\right)} \cdot 6\]
  7. Using strategy rm
  8. Applied pow10.1

    \[\leadsto \log \left(e^{\frac{x - 1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}}\right) \cdot \color{blue}{{6}^{1}}\]
  9. Applied pow10.1

    \[\leadsto \color{blue}{{\left(\log \left(e^{\frac{x - 1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}}\right)\right)}^{1}} \cdot {6}^{1}\]
  10. Applied pow-prod-down0.1

    \[\leadsto \color{blue}{{\left(\log \left(e^{\frac{x - 1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}}\right) \cdot 6\right)}^{1}}\]
  11. Simplified0.0

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

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

Reproduce

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

  :herbie-target
  (/ 6 (/ (+ (+ x 1) (* 4 (sqrt x))) (- x 1)))

  (/ (* 6 (- x 1)) (+ (+ x 1) (* 4 (sqrt x)))))