\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.0000000771282975:\\
\;\;\;\;\mathsf{fma}\left(x, 1, \log 1 - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{1 + x}\right) + \log \left(\sqrt{1 + x}\right)\\
\end{array}double f(double x) {
double r74114 = 1.0;
double r74115 = x;
double r74116 = r74114 + r74115;
double r74117 = log(r74116);
return r74117;
}
double f(double x) {
double r74118 = 1.0;
double r74119 = x;
double r74120 = r74118 + r74119;
double r74121 = 1.0000000771282975;
bool r74122 = r74120 <= r74121;
double r74123 = log(r74118);
double r74124 = 0.5;
double r74125 = 2.0;
double r74126 = pow(r74119, r74125);
double r74127 = pow(r74118, r74125);
double r74128 = r74126 / r74127;
double r74129 = r74124 * r74128;
double r74130 = r74123 - r74129;
double r74131 = fma(r74119, r74118, r74130);
double r74132 = sqrt(r74120);
double r74133 = log(r74132);
double r74134 = r74133 + r74133;
double r74135 = r74122 ? r74131 : r74134;
return r74135;
}




Bits error versus x
| Original | 38.5 |
|---|---|
| Target | 0.3 |
| Herbie | 0.3 |
if (+ 1.0 x) < 1.0000000771282975Initial program 59.2
Taylor expanded around 0 0.3
Simplified0.3
if 1.0000000771282975 < (+ 1.0 x) Initial program 0.2
rmApplied add-sqr-sqrt0.2
Applied log-prod0.2
Final simplification0.3
herbie shell --seed 2020060 +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)))