Average Error: 0.2 → 0.0
Time: 11.5s
Precision: 64
\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}\]
\[\frac{x - 1}{1 + \mathsf{fma}\left(4, \sqrt{x}, x\right)} \cdot 6\]
\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}
\frac{x - 1}{1 + \mathsf{fma}\left(4, \sqrt{x}, x\right)} \cdot 6
double f(double x) {
        double r613561 = 6.0;
        double r613562 = x;
        double r613563 = 1.0;
        double r613564 = r613562 - r613563;
        double r613565 = r613561 * r613564;
        double r613566 = r613562 + r613563;
        double r613567 = 4.0;
        double r613568 = sqrt(r613562);
        double r613569 = r613567 * r613568;
        double r613570 = r613566 + r613569;
        double r613571 = r613565 / r613570;
        return r613571;
}

double f(double x) {
        double r613572 = x;
        double r613573 = 1.0;
        double r613574 = r613572 - r613573;
        double r613575 = 4.0;
        double r613576 = sqrt(r613572);
        double r613577 = fma(r613575, r613576, r613572);
        double r613578 = r613573 + r613577;
        double r613579 = r613574 / r613578;
        double r613580 = 6.0;
        double r613581 = r613579 * r613580;
        return r613581;
}

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 clear-num0.1

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

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

    \[\leadsto 6 \cdot \frac{1}{\frac{\mathsf{fma}\left(\sqrt{x}, 4, x\right) + 1}{\color{blue}{1 \cdot \left(x - 1\right)}}}\]
  8. Applied *-un-lft-identity0.1

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

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

    \[\leadsto 6 \cdot \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{1}{1} \cdot \frac{\mathsf{fma}\left(\sqrt{x}, 4, x\right) + 1}{x - 1}}\]
  11. Applied times-frac0.1

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

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

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

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

Reproduce

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