\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 r68341 = 1.0;
double r68342 = x;
double r68343 = r68341 + r68342;
double r68344 = log(r68343);
return r68344;
}
double f(double x) {
double r68345 = 1.0;
double r68346 = x;
double r68347 = r68345 + r68346;
double r68348 = 1.0000000000000033;
bool r68349 = r68347 <= r68348;
double r68350 = r68345 * r68346;
double r68351 = log(r68345);
double r68352 = r68350 + r68351;
double r68353 = 0.5;
double r68354 = 2.0;
double r68355 = pow(r68346, r68354);
double r68356 = pow(r68345, r68354);
double r68357 = r68355 / r68356;
double r68358 = r68353 * r68357;
double r68359 = r68352 - r68358;
double r68360 = sqrt(r68347);
double r68361 = log(r68360);
double r68362 = r68361 + r68361;
double r68363 = r68349 ? r68359 : r68362;
return r68363;
}




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)))