Average Error: 0.2 → 0.0
Time: 11.7s
Precision: 64
\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}\]
\[\frac{x - 1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)} \cdot 6\]
\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}
\frac{x - 1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)} \cdot 6
double f(double x) {
        double r1119650 = 6.0;
        double r1119651 = x;
        double r1119652 = 1.0;
        double r1119653 = r1119651 - r1119652;
        double r1119654 = r1119650 * r1119653;
        double r1119655 = r1119651 + r1119652;
        double r1119656 = 4.0;
        double r1119657 = sqrt(r1119651);
        double r1119658 = r1119656 * r1119657;
        double r1119659 = r1119655 + r1119658;
        double r1119660 = r1119654 / r1119659;
        return r1119660;
}

double f(double x) {
        double r1119661 = x;
        double r1119662 = 1.0;
        double r1119663 = r1119661 - r1119662;
        double r1119664 = sqrt(r1119661);
        double r1119665 = 4.0;
        double r1119666 = r1119661 + r1119662;
        double r1119667 = fma(r1119664, r1119665, r1119666);
        double r1119668 = r1119663 / r1119667;
        double r1119669 = 6.0;
        double r1119670 = r1119668 * r1119669;
        return r1119670;
}

Error

Bits error versus x

Target

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

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

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

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

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

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

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

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

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

Reproduce

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