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











Bits error versus x
Results
| Original | 38.7 |
|---|---|
| Target | 0.2 |
| Herbie | 0.1 |
| Alternative 1 | |
|---|---|
| Error | 0.6 |
| Cost | 6785 |
| Alternative 2 | |
|---|---|
| Error | 18.8 |
| Cost | 1281 |
| Alternative 3 | |
|---|---|
| Error | 18.9 |
| Cost | 1025 |
| Alternative 4 | |
|---|---|
| Error | 18.9 |
| Cost | 1025 |
| Alternative 5 | |
|---|---|
| Error | 19.0 |
| Cost | 769 |
| Alternative 6 | |
|---|---|
| Error | 19.5 |
| Cost | 385 |
| Alternative 7 | |
|---|---|
| Error | 21.3 |
| Cost | 64 |


if (+.f64 1 x) < 1.0000076844218335Initial program 59.1
rmApplied pow1_binary64_116259.1
Applied log-pow_binary64_119059.1
Taylor expanded around 0 0.1
Simplified0.1
Simplified0.1
if 1.0000076844218335 < (+.f64 1 x) Initial program 0.1
rmApplied flip-+_binary64_107531.4
Applied log-div_binary64_118862.9
Simplified62.9
rmApplied add-sqr-sqrt_binary64_112362.9
Applied difference-of-squares_binary64_107063.0
Applied log-prod_binary64_118763.0
Applied associate--l+_binary64_103863.0
Simplified0.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2021065
(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)))