Average Error: 0.2 → 0.0
Time: 12.2s
Precision: 64
\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}\]
\[6 \cdot \frac{x - 1}{1 + \mathsf{fma}\left(\sqrt{x}, 4, x\right)}\]
\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}
6 \cdot \frac{x - 1}{1 + \mathsf{fma}\left(\sqrt{x}, 4, x\right)}
double f(double x) {
        double r23935681 = 6.0;
        double r23935682 = x;
        double r23935683 = 1.0;
        double r23935684 = r23935682 - r23935683;
        double r23935685 = r23935681 * r23935684;
        double r23935686 = r23935682 + r23935683;
        double r23935687 = 4.0;
        double r23935688 = sqrt(r23935682);
        double r23935689 = r23935687 * r23935688;
        double r23935690 = r23935686 + r23935689;
        double r23935691 = r23935685 / r23935690;
        return r23935691;
}

double f(double x) {
        double r23935692 = 6.0;
        double r23935693 = x;
        double r23935694 = 1.0;
        double r23935695 = r23935693 - r23935694;
        double r23935696 = sqrt(r23935693);
        double r23935697 = 4.0;
        double r23935698 = fma(r23935696, r23935697, r23935693);
        double r23935699 = r23935694 + r23935698;
        double r23935700 = r23935695 / r23935699;
        double r23935701 = r23935692 * r23935700;
        return r23935701;
}

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}{6 \cdot \frac{x - 1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}}\]
  3. Using strategy rm
  4. Applied add-log-exp0.1

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

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

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

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

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

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

Reproduce

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