\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.0000000771282975:\\
\;\;\;\;\left(1 \cdot x + \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{1 + x}\right) + \log \left(\sqrt{1 + x}\right)\\
\end{array}double f(double x) {
double r63574 = 1.0;
double r63575 = x;
double r63576 = r63574 + r63575;
double r63577 = log(r63576);
return r63577;
}
double f(double x) {
double r63578 = 1.0;
double r63579 = x;
double r63580 = r63578 + r63579;
double r63581 = 1.0000000771282975;
bool r63582 = r63580 <= r63581;
double r63583 = r63578 * r63579;
double r63584 = log(r63578);
double r63585 = r63583 + r63584;
double r63586 = 0.5;
double r63587 = 2.0;
double r63588 = pow(r63579, r63587);
double r63589 = pow(r63578, r63587);
double r63590 = r63588 / r63589;
double r63591 = r63586 * r63590;
double r63592 = r63585 - r63591;
double r63593 = sqrt(r63580);
double r63594 = log(r63593);
double r63595 = r63594 + r63594;
double r63596 = r63582 ? r63592 : r63595;
return r63596;
}




Bits error versus x
Results
| Original | 38.5 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
if (+ 1.0 x) < 1.0000000771282975Initial program 59.2
Taylor expanded around 0 0.3
if 1.0000000771282975 < (+ 1.0 x) Initial program 0.2
rmApplied add-sqr-sqrt0.2
Applied log-prod0.2
Final simplification0.3
herbie shell --seed 2020060
(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)))