\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.0000019383723648:\\
\;\;\;\;\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \log \left(1 + x\right) + \left(\log \left(\sqrt{\sqrt{1 + x}}\right) + \log \left(\sqrt{\sqrt{1 + x}}\right)\right)\\
\end{array}double f(double x) {
double r68240 = 1.0;
double r68241 = x;
double r68242 = r68240 + r68241;
double r68243 = log(r68242);
return r68243;
}
double f(double x) {
double r68244 = 1.0;
double r68245 = x;
double r68246 = r68244 + r68245;
double r68247 = 1.0000019383723648;
bool r68248 = r68246 <= r68247;
double r68249 = log(r68244);
double r68250 = 0.5;
double r68251 = 2.0;
double r68252 = pow(r68245, r68251);
double r68253 = pow(r68244, r68251);
double r68254 = r68252 / r68253;
double r68255 = r68250 * r68254;
double r68256 = r68249 - r68255;
double r68257 = fma(r68245, r68244, r68256);
double r68258 = log(r68246);
double r68259 = r68250 * r68258;
double r68260 = sqrt(r68246);
double r68261 = sqrt(r68260);
double r68262 = log(r68261);
double r68263 = r68262 + r68262;
double r68264 = r68259 + r68263;
double r68265 = r68248 ? r68257 : r68264;
return r68265;
}




Bits error versus x
| Original | 39.3 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
if (+ 1.0 x) < 1.0000019383723648Initial program 59.1
Taylor expanded around 0 0.4
Simplified0.4
if 1.0000019383723648 < (+ 1.0 x) Initial program 0.1
rmApplied add-sqr-sqrt0.2
Applied log-prod0.2
rmApplied pow10.2
Applied sqrt-pow10.2
Applied log-pow0.2
rmApplied add-sqr-sqrt0.2
Applied sqrt-prod0.2
Applied log-prod0.2
Final simplification0.3
herbie shell --seed 2020081 +o rules:numerics
(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)))