\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \leq 1.000000000011955:\\
\;\;\;\;\left(x + \left(x \cdot \left(0.3333333333333333 + x \cdot -0.25\right)\right) \cdot \left(x \cdot x\right)\right) + \left(x \cdot x\right) \cdot -0.5\\
\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.000000000011955)
(+
(+ x (* (* x (+ 0.3333333333333333 (* x -0.25))) (* x x)))
(* (* x x) -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.000000000011955) {
tmp = (x + ((x * (0.3333333333333333 + (x * -0.25))) * (x * x))) + ((x * x) * -0.5);
} else {
tmp = log(1.0 + x);
}
return tmp;
}




Bits error versus x
Results
| Original | 38.9 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
if (+.f64 1 x) < 1.0000000000119551Initial program 59.2
Taylor expanded around 0 0.2
Simplified0.2
rmApplied distribute-rgt-in_binary64_10510.2
Applied associate-+r+_binary64_10330.2
if 1.0000000000119551 < (+.f64 1 x) Initial program 0.6
Final simplification0.3
herbie shell --seed 2021045
(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)))