\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.000000000000000666133814775093924254179:\\
\;\;\;\;\left(1 \cdot x + \log 1\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \log \left(1 + x\right) + \frac{1}{2} \cdot \log \left(1 + x\right)\\
\end{array}double f(double x) {
double r67268 = 1.0;
double r67269 = x;
double r67270 = r67268 + r67269;
double r67271 = log(r67270);
return r67271;
}
double f(double x) {
double r67272 = 1.0;
double r67273 = x;
double r67274 = r67272 + r67273;
double r67275 = 1.0000000000000007;
bool r67276 = r67274 <= r67275;
double r67277 = r67272 * r67273;
double r67278 = log(r67272);
double r67279 = r67277 + r67278;
double r67280 = 0.5;
double r67281 = 2.0;
double r67282 = pow(r67273, r67281);
double r67283 = pow(r67272, r67281);
double r67284 = r67282 / r67283;
double r67285 = r67280 * r67284;
double r67286 = r67279 - r67285;
double r67287 = 1.0;
double r67288 = r67287 / r67281;
double r67289 = log(r67274);
double r67290 = r67288 * r67289;
double r67291 = r67290 + r67290;
double r67292 = r67276 ? r67286 : r67291;
return r67292;
}




Bits error versus x
Results
| Original | 39.2 |
|---|---|
| Target | 0.3 |
| Herbie | 0.6 |
if (+ 1.0 x) < 1.0000000000000007Initial program 59.5
Taylor expanded around 0 0.3
if 1.0000000000000007 < (+ 1.0 x) Initial program 1.0
rmApplied add-sqr-sqrt1.1
Applied log-prod1.1
rmApplied pow11.1
Applied sqrt-pow11.1
Applied log-pow1.0
rmApplied pow11.0
Applied sqrt-pow11.0
Applied log-pow1.0
Final simplification0.6
herbie shell --seed 2019354
(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)))