Average Error: 0.2 → 0.1
Time: 4.5s
Precision: 64
\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}\]
\[\frac{\left(x - 1\right) \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}\right)\right)}{\frac{1}{6}}\]
\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}
\frac{\left(x - 1\right) \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}\right)\right)}{\frac{1}{6}}
double f(double x) {
        double r897277 = 6.0;
        double r897278 = x;
        double r897279 = 1.0;
        double r897280 = r897278 - r897279;
        double r897281 = r897277 * r897280;
        double r897282 = r897278 + r897279;
        double r897283 = 4.0;
        double r897284 = sqrt(r897278);
        double r897285 = r897283 * r897284;
        double r897286 = r897282 + r897285;
        double r897287 = r897281 / r897286;
        return r897287;
}

double f(double x) {
        double r897288 = x;
        double r897289 = 1.0;
        double r897290 = r897288 - r897289;
        double r897291 = 1.0;
        double r897292 = sqrt(r897288);
        double r897293 = 4.0;
        double r897294 = r897288 + r897289;
        double r897295 = fma(r897292, r897293, r897294);
        double r897296 = r897291 / r897295;
        double r897297 = log1p(r897296);
        double r897298 = expm1(r897297);
        double r897299 = r897290 * r897298;
        double r897300 = 6.0;
        double r897301 = r897291 / r897300;
        double r897302 = r897299 / r897301;
        return r897302;
}

Error

Bits error versus x

Target

Original0.2
Target0.1
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}{\frac{x - 1}{\frac{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}{6}}}\]
  3. Using strategy rm
  4. Applied div-inv0.2

    \[\leadsto \frac{x - 1}{\color{blue}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right) \cdot \frac{1}{6}}}\]
  5. Applied associate-/r*0.1

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

    \[\leadsto \frac{\color{blue}{\left(x - 1\right) \cdot \frac{1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}}}{\frac{1}{6}}\]
  8. Using strategy rm
  9. Applied expm1-log1p-u0.1

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

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

Reproduce

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