\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.000000154584223865938952258147764950991:\\
\;\;\;\;\mathsf{fma}\left(\frac{{x}^{2}}{{1}^{2}}, \frac{-1}{2}, \mathsf{fma}\left(1, x, \log 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\sqrt{1 + x}\right) + \log \left(\left|\sqrt[3]{1 + x}\right| \cdot \sqrt{\sqrt[3]{1 + x}}\right)\\
\end{array}double f(double x) {
double r75046 = 1.0;
double r75047 = x;
double r75048 = r75046 + r75047;
double r75049 = log(r75048);
return r75049;
}
double f(double x) {
double r75050 = 1.0;
double r75051 = x;
double r75052 = r75050 + r75051;
double r75053 = 1.0000001545842239;
bool r75054 = r75052 <= r75053;
double r75055 = 2.0;
double r75056 = pow(r75051, r75055);
double r75057 = pow(r75050, r75055);
double r75058 = r75056 / r75057;
double r75059 = -0.5;
double r75060 = log(r75050);
double r75061 = fma(r75050, r75051, r75060);
double r75062 = fma(r75058, r75059, r75061);
double r75063 = sqrt(r75052);
double r75064 = log(r75063);
double r75065 = cbrt(r75052);
double r75066 = fabs(r75065);
double r75067 = sqrt(r75065);
double r75068 = r75066 * r75067;
double r75069 = log(r75068);
double r75070 = r75064 + r75069;
double r75071 = r75054 ? r75062 : r75070;
return r75071;
}




Bits error versus x
| Original | 39.4 |
|---|---|
| Target | 0.2 |
| Herbie | 0.3 |
if (+ 1.0 x) < 1.0000001545842239Initial program 59.1
Taylor expanded around 0 0.4
Simplified0.4
if 1.0000001545842239 < (+ 1.0 x) Initial program 0.2
rmApplied add-sqr-sqrt0.2
Applied log-prod0.2
rmApplied add-cube-cbrt0.2
Applied sqrt-prod0.2
Simplified0.2
Final simplification0.3
herbie shell --seed 2019305 +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)))