\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;x \leq 0.0001449948157992588:\\
\;\;\;\;x \cdot \left(1 + x \cdot \left(-0.5 + x \cdot 0.3333333333333333\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(x + 1\right)\\
\end{array}(FPCore (x) :precision binary64 (log (+ 1.0 x)))
(FPCore (x) :precision binary64 (if (<= x 0.0001449948157992588) (* x (+ 1.0 (* x (+ -0.5 (* x 0.3333333333333333))))) (log (+ x 1.0))))
double code(double x) {
return log(1.0 + x);
}
double code(double x) {
double tmp;
if (x <= 0.0001449948157992588) {
tmp = x * (1.0 + (x * (-0.5 + (x * 0.3333333333333333))));
} else {
tmp = log(x + 1.0);
}
return tmp;
}









Bits error versus x
Results
| Original | 39.1 |
|---|---|
| Target | 0.2 |
| Herbie | 0.2 |
| Alternative 1 | |
|---|---|
| Error | 0.7 |
| Cost | 6785 |
| Alternative 2 | |
|---|---|
| Error | 18.6 |
| Cost | 1025 |
| Alternative 3 | |
|---|---|
| Error | 18.7 |
| Cost | 769 |
| Alternative 4 | |
|---|---|
| Error | 19.2 |
| Cost | 385 |
| Alternative 5 | |
|---|---|
| Error | 59.4 |
| Cost | 64 |

if x < 1.44994815799258809e-4Initial program 59.0
Taylor expanded around 0 0.2
Simplified0.2
Simplified0.2
if 1.44994815799258809e-4 < x Initial program 0.1
Simplified0.1
Final simplification0.2
herbie shell --seed 2021044
(FPCore (x)
:name "ln(1 + x)"
:precision binary64
:herbie-target
(if (== (+ 1.0 x) 1.0) x (/ (* x (log (+ 1.0 x))) (- (+ 1.0 x) 1.0)))
(log (+ 1.0 x)))