\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 r56330 = 1.0;
double r56331 = x;
double r56332 = r56330 + r56331;
double r56333 = log(r56332);
return r56333;
}
double f(double x) {
double r56334 = 1.0;
double r56335 = x;
double r56336 = r56334 + r56335;
double r56337 = 1.0000000000000033;
bool r56338 = r56336 <= r56337;
double r56339 = r56334 * r56335;
double r56340 = log(r56334);
double r56341 = r56339 + r56340;
double r56342 = 0.5;
double r56343 = 2.0;
double r56344 = pow(r56335, r56343);
double r56345 = pow(r56334, r56343);
double r56346 = r56344 / r56345;
double r56347 = r56342 * r56346;
double r56348 = r56341 - r56347;
double r56349 = sqrt(r56336);
double r56350 = log(r56349);
double r56351 = r56350 + r56350;
double r56352 = r56338 ? r56348 : r56351;
return r56352;
}




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