Average Error: 0.2 → 0.0
Time: 3.4s
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 r769967 = 6.0;
        double r769968 = x;
        double r769969 = 1.0;
        double r769970 = r769968 - r769969;
        double r769971 = r769967 * r769970;
        double r769972 = r769968 + r769969;
        double r769973 = 4.0;
        double r769974 = sqrt(r769968);
        double r769975 = r769973 * r769974;
        double r769976 = r769972 + r769975;
        double r769977 = r769971 / r769976;
        return r769977;
}

double f(double x) {
        double r769978 = 6.0;
        double r769979 = x;
        double r769980 = 1.0;
        double r769981 = r769979 - r769980;
        double r769982 = sqrt(r769979);
        double r769983 = 4.0;
        double r769984 = r769979 + r769980;
        double r769985 = fma(r769982, r769983, r769984);
        double r769986 = r769981 / r769985;
        double r769987 = r769978 * r769986;
        return r769987;
}

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)))))