\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}\frac{x}{\frac{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}{6}} - \frac{1}{\frac{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}{6}}double code(double x) {
return ((6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x))));
}
double code(double x) {
return ((x / (fma(sqrt(x), 4.0, (x + 1.0)) / 6.0)) - (1.0 / (fma(sqrt(x), 4.0, (x + 1.0)) / 6.0)));
}




Bits error versus x
Results
| Original | 0.2 |
|---|---|
| Target | 0.1 |
| Herbie | 0.1 |
Initial program 0.2
Simplified0.1
rmApplied div-sub0.1
Final simplification0.1
herbie shell --seed 2020102 +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)))))