Average Error: 0.2 → 0.0
Time: 13.8s
Precision: 64
\[\frac{6.0 \cdot \left(x - 1.0\right)}{\left(x + 1.0\right) + 4.0 \cdot \sqrt{x}}\]
\[6.0 \cdot \frac{x - 1.0}{1.0 + \mathsf{fma}\left(4.0, \sqrt{x}, x\right)}\]
\frac{6.0 \cdot \left(x - 1.0\right)}{\left(x + 1.0\right) + 4.0 \cdot \sqrt{x}}
6.0 \cdot \frac{x - 1.0}{1.0 + \mathsf{fma}\left(4.0, \sqrt{x}, x\right)}
double f(double x) {
        double r34364453 = 6.0;
        double r34364454 = x;
        double r34364455 = 1.0;
        double r34364456 = r34364454 - r34364455;
        double r34364457 = r34364453 * r34364456;
        double r34364458 = r34364454 + r34364455;
        double r34364459 = 4.0;
        double r34364460 = sqrt(r34364454);
        double r34364461 = r34364459 * r34364460;
        double r34364462 = r34364458 + r34364461;
        double r34364463 = r34364457 / r34364462;
        return r34364463;
}

double f(double x) {
        double r34364464 = 6.0;
        double r34364465 = x;
        double r34364466 = 1.0;
        double r34364467 = r34364465 - r34364466;
        double r34364468 = 4.0;
        double r34364469 = sqrt(r34364465);
        double r34364470 = fma(r34364468, r34364469, r34364465);
        double r34364471 = r34364466 + r34364470;
        double r34364472 = r34364467 / r34364471;
        double r34364473 = r34364464 * r34364472;
        return r34364473;
}

Error

Bits error versus x

Target

Original0.2
Target0.1
Herbie0.0
\[\frac{6.0}{\frac{\left(x + 1.0\right) + 4.0 \cdot \sqrt{x}}{x - 1.0}}\]

Derivation

  1. Initial program 0.2

    \[\frac{6.0 \cdot \left(x - 1.0\right)}{\left(x + 1.0\right) + 4.0 \cdot \sqrt{x}}\]
  2. Simplified0.1

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

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

    \[\leadsto 6.0 \cdot \color{blue}{\frac{x - 1.0}{\mathsf{fma}\left(4.0, \sqrt{x}, x + 1.0\right)}}\]
  6. Using strategy rm
  7. Applied add-cbrt-cube20.3

    \[\leadsto 6.0 \cdot \frac{x - 1.0}{\color{blue}{\sqrt[3]{\left(\mathsf{fma}\left(4.0, \sqrt{x}, x + 1.0\right) \cdot \mathsf{fma}\left(4.0, \sqrt{x}, x + 1.0\right)\right) \cdot \mathsf{fma}\left(4.0, \sqrt{x}, x + 1.0\right)}}}\]
  8. Applied add-cbrt-cube20.2

    \[\leadsto 6.0 \cdot \frac{\color{blue}{\sqrt[3]{\left(\left(x - 1.0\right) \cdot \left(x - 1.0\right)\right) \cdot \left(x - 1.0\right)}}}{\sqrt[3]{\left(\mathsf{fma}\left(4.0, \sqrt{x}, x + 1.0\right) \cdot \mathsf{fma}\left(4.0, \sqrt{x}, x + 1.0\right)\right) \cdot \mathsf{fma}\left(4.0, \sqrt{x}, x + 1.0\right)}}\]
  9. Applied cbrt-undiv20.2

    \[\leadsto 6.0 \cdot \color{blue}{\sqrt[3]{\frac{\left(\left(x - 1.0\right) \cdot \left(x - 1.0\right)\right) \cdot \left(x - 1.0\right)}{\left(\mathsf{fma}\left(4.0, \sqrt{x}, x + 1.0\right) \cdot \mathsf{fma}\left(4.0, \sqrt{x}, x + 1.0\right)\right) \cdot \mathsf{fma}\left(4.0, \sqrt{x}, x + 1.0\right)}}}\]
  10. Simplified0.1

    \[\leadsto 6.0 \cdot \sqrt[3]{\color{blue}{\left(\frac{x - 1.0}{\mathsf{fma}\left(4.0, \sqrt{x}, 1.0 + x\right)} \cdot \frac{x - 1.0}{\mathsf{fma}\left(4.0, \sqrt{x}, 1.0 + x\right)}\right) \cdot \frac{x - 1.0}{\mathsf{fma}\left(4.0, \sqrt{x}, 1.0 + x\right)}}}\]
  11. Using strategy rm
  12. Applied frac-times15.0

    \[\leadsto 6.0 \cdot \sqrt[3]{\color{blue}{\frac{\left(x - 1.0\right) \cdot \left(x - 1.0\right)}{\mathsf{fma}\left(4.0, \sqrt{x}, 1.0 + x\right) \cdot \mathsf{fma}\left(4.0, \sqrt{x}, 1.0 + x\right)}} \cdot \frac{x - 1.0}{\mathsf{fma}\left(4.0, \sqrt{x}, 1.0 + x\right)}}\]
  13. Applied frac-times20.2

    \[\leadsto 6.0 \cdot \sqrt[3]{\color{blue}{\frac{\left(\left(x - 1.0\right) \cdot \left(x - 1.0\right)\right) \cdot \left(x - 1.0\right)}{\left(\mathsf{fma}\left(4.0, \sqrt{x}, 1.0 + x\right) \cdot \mathsf{fma}\left(4.0, \sqrt{x}, 1.0 + x\right)\right) \cdot \mathsf{fma}\left(4.0, \sqrt{x}, 1.0 + x\right)}}}\]
  14. Applied cbrt-div20.2

    \[\leadsto 6.0 \cdot \color{blue}{\frac{\sqrt[3]{\left(\left(x - 1.0\right) \cdot \left(x - 1.0\right)\right) \cdot \left(x - 1.0\right)}}{\sqrt[3]{\left(\mathsf{fma}\left(4.0, \sqrt{x}, 1.0 + x\right) \cdot \mathsf{fma}\left(4.0, \sqrt{x}, 1.0 + x\right)\right) \cdot \mathsf{fma}\left(4.0, \sqrt{x}, 1.0 + x\right)}}}\]
  15. Simplified20.3

    \[\leadsto 6.0 \cdot \frac{\color{blue}{x - 1.0}}{\sqrt[3]{\left(\mathsf{fma}\left(4.0, \sqrt{x}, 1.0 + x\right) \cdot \mathsf{fma}\left(4.0, \sqrt{x}, 1.0 + x\right)\right) \cdot \mathsf{fma}\left(4.0, \sqrt{x}, 1.0 + x\right)}}\]
  16. Simplified0.0

    \[\leadsto 6.0 \cdot \frac{x - 1.0}{\color{blue}{\mathsf{fma}\left(4.0, \sqrt{x}, x\right) + 1.0}}\]
  17. Final simplification0.0

    \[\leadsto 6.0 \cdot \frac{x - 1.0}{1.0 + \mathsf{fma}\left(4.0, \sqrt{x}, x\right)}\]

Reproduce

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