\frac{x}{1 + \sqrt{x + 1}}\begin{array}{l}
\mathbf{if}\;x \leq 7.897555139426257 \cdot 10^{-06}:\\
\;\;\;\;\frac{x}{2 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x + 1} + -1\\
\end{array}(FPCore (x) :precision binary64 (/ x (+ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x) :precision binary64 (if (<= x 7.897555139426257e-06) (/ x (+ 2.0 (* x 0.5))) (+ (sqrt (+ x 1.0)) -1.0)))
double code(double x) {
return x / (1.0 + sqrt(x + 1.0));
}
double code(double x) {
double tmp;
if (x <= 7.897555139426257e-06) {
tmp = x / (2.0 + (x * 0.5));
} else {
tmp = sqrt(x + 1.0) + -1.0;
}
return tmp;
}







Bits error versus x
Results
| Alternative 1 | |
|---|---|
| Error | 0.2 |
| Cost | 6848 |
| Alternative 2 | |
|---|---|
| Error | 20.2 |
| Cost | 448 |
| Alternative 3 | |
|---|---|
| Error | 20.7 |
| Cost | 192 |
| Alternative 4 | |
|---|---|
| Error | 60.9 |
| Cost | 64 |

if x < 7.89755513942625704e-6Initial program 0.0
Taylor expanded around 0 0.3
Simplified0.3
Simplified0.3
if 7.89755513942625704e-6 < x Initial program 0.5
rmApplied flip-+_binary64_31210.6
Applied associate-/r/_binary64_30930.7
Simplified0.1
Simplified0.1
Final simplification0.2
herbie shell --seed 2021044
(FPCore (x)
:name "Numeric.Log:$clog1p from log-domain-0.10.2.1, B"
:precision binary64
(/ x (+ 1.0 (sqrt (+ x 1.0)))))