\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.0000020999504917:\\
\;\;\;\;\frac{\left(\left(\frac{1}{3} \cdot {x}^{3}\right) \cdot {1}^{2} + {1}^{3} \cdot \left(\frac{1}{2} \cdot {x}^{2}\right)\right) \cdot \left(1 + 1 \cdot x\right) + \left({1}^{3} \cdot {1}^{2}\right) \cdot \left(x \cdot \left(1 \cdot 1 - \left(1 \cdot x\right) \cdot \left(1 \cdot x\right)\right)\right)}{\left({1}^{3} \cdot {1}^{2}\right) \cdot \left(1 + 1 \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}double code(double x) {
return log((1.0 + x));
}
double code(double x) {
double VAR;
if (((1.0 + x) <= 1.0000020999504917)) {
VAR = ((((((0.3333333333333333 * pow(x, 3.0)) * pow(1.0, 2.0)) + (pow(1.0, 3.0) * (0.5 * pow(x, 2.0)))) * (1.0 + (1.0 * x))) + ((pow(1.0, 3.0) * pow(1.0, 2.0)) * (x * ((1.0 * 1.0) - ((1.0 * x) * (1.0 * x)))))) / ((pow(1.0, 3.0) * pow(1.0, 2.0)) * (1.0 + (1.0 * x))));
} else {
VAR = log((1.0 + x));
}
return VAR;
}




Bits error versus x
Results
| Original | 39.4 |
|---|---|
| Target | 0.2 |
| Herbie | 0.2 |
if (+ 1.0 x) < 1.0000020999504917Initial program 59.2
rmApplied flip-+59.2
Applied log-div59.2
Taylor expanded around 0 0.2
Simplified0.2
rmApplied flip--0.2
Applied associate-*r/0.2
Applied associate-*r/0.2
Applied associate-*r/0.2
Applied frac-add0.2
Applied frac-add0.2
if 1.0000020999504917 < (+ 1.0 x) Initial program 0.2
Final simplification0.2
herbie shell --seed 2020092
(FPCore (x)
:name "ln(1 + x)"
:precision binary64
:herbie-target
(if (== (+ 1 x) 1) x (/ (* x (log (+ 1 x))) (- (+ 1 x) 1)))
(log (+ 1 x)))