\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.00000000000000333:\\
\;\;\;\;\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 r69464 = 1.0;
double r69465 = x;
double r69466 = r69464 + r69465;
double r69467 = log(r69466);
return r69467;
}
double f(double x) {
double r69468 = 1.0;
double r69469 = x;
double r69470 = r69468 + r69469;
double r69471 = 1.0000000000000033;
bool r69472 = r69470 <= r69471;
double r69473 = r69468 * r69469;
double r69474 = log(r69468);
double r69475 = r69473 + r69474;
double r69476 = 0.5;
double r69477 = 2.0;
double r69478 = pow(r69469, r69477);
double r69479 = pow(r69468, r69477);
double r69480 = r69478 / r69479;
double r69481 = r69476 * r69480;
double r69482 = r69475 - r69481;
double r69483 = sqrt(r69470);
double r69484 = log(r69483);
double r69485 = r69484 + r69484;
double r69486 = r69472 ? r69482 : r69485;
return r69486;
}




Bits error versus x
Results
| Original | 38.8 |
|---|---|
| Target | 0.2 |
| Herbie | 0.5 |
if (+ 1.0 x) < 1.0000000000000033Initial program 59.6
Taylor expanded around 0 0.3
if 1.0000000000000033 < (+ 1.0 x) Initial program 0.9
rmApplied add-sqr-sqrt1.0
Applied log-prod1.0
Final simplification0.5
herbie shell --seed 2020047
(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)))