\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.00000000000000333:\\
\;\;\;\;\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(\sqrt{1 + x}\right)\\
\end{array}double f(double x) {
double r79138 = 1.0;
double r79139 = x;
double r79140 = r79138 + r79139;
double r79141 = log(r79140);
return r79141;
}
double f(double x) {
double r79142 = 1.0;
double r79143 = x;
double r79144 = r79142 + r79143;
double r79145 = 1.0000000000000033;
bool r79146 = r79144 <= r79145;
double r79147 = 2.0;
double r79148 = pow(r79143, r79147);
double r79149 = pow(r79142, r79147);
double r79150 = r79148 / r79149;
double r79151 = -0.5;
double r79152 = log(r79142);
double r79153 = fma(r79142, r79143, r79152);
double r79154 = fma(r79150, r79151, r79153);
double r79155 = sqrt(r79144);
double r79156 = log(r79155);
double r79157 = r79156 + r79156;
double r79158 = r79146 ? r79154 : r79157;
return r79158;
}




Bits error versus x
| Original | 38.8 |
|---|---|
| Target | 0.2 |
| Herbie | 0.5 |
if (+ 1.0 x) < 1.0000000000000033Initial program 59.6
Taylor expanded around 0 0.3
Simplified0.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 +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)))