\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \leq 1.0001177917014636:\\
\;\;\;\;x \cdot \left(1 + \log \left(e^{x \cdot \left(x \cdot 0.3333333333333333 + -0.5\right)}\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.0001177917014636) (* x (+ 1.0 (log (exp (* x (+ (* x 0.3333333333333333) -0.5)))))) (log (+ 1.0 x))))
double code(double x) {
return log(1.0 + x);
}
double code(double x) {
double tmp;
if ((1.0 + x) <= 1.0001177917014636) {
tmp = x * (1.0 + log(exp(x * ((x * 0.3333333333333333) + -0.5))));
} else {
tmp = log(1.0 + x);
}
return tmp;
}






Bits error versus x
Results
| Original | 39.5 |
|---|---|
| Target | 0.2 |
| Herbie | 0.2 |
| Alternative 1 | |
|---|---|
| Accuracy | 20.8 |
| Cost | 704 |
| Alternative 2 | |
|---|---|
| Accuracy | 20.8 |
| Cost | 1216 |
if (+.f64 1 x) < 1.00011779170146364Initial program 58.9
Taylor expanded around 0 0.2
Simplified0.2
rmApplied add-log-exp_binary64_21630.2
Simplified0.2
if 1.00011779170146364 < (+.f64 1 x) Initial program 0.1
Final simplification0.2
herbie shell --seed 2020322
(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)))