\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.00000000442313008:\\
\;\;\;\;\mathsf{fma}\left(-1, \mathsf{fma}\left(x, x, \frac{{x}^{3}}{{1}^{2}}\right), \mathsf{fma}\left(0.5, {x}^{2}, \mathsf{fma}\left(1, x, 1.33333333333333326 \cdot {x}^{3}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(1 + x\right)\\
\end{array}double f(double x) {
double r83571 = 1.0;
double r83572 = x;
double r83573 = r83571 + r83572;
double r83574 = log(r83573);
return r83574;
}
double f(double x) {
double r83575 = 1.0;
double r83576 = x;
double r83577 = r83575 + r83576;
double r83578 = 1.00000000442313;
bool r83579 = r83577 <= r83578;
double r83580 = -r83575;
double r83581 = 3.0;
double r83582 = pow(r83576, r83581);
double r83583 = 2.0;
double r83584 = pow(r83575, r83583);
double r83585 = r83582 / r83584;
double r83586 = fma(r83576, r83576, r83585);
double r83587 = 0.5;
double r83588 = pow(r83576, r83583);
double r83589 = 1.3333333333333333;
double r83590 = r83589 * r83582;
double r83591 = fma(r83575, r83576, r83590);
double r83592 = fma(r83587, r83588, r83591);
double r83593 = fma(r83580, r83586, r83592);
double r83594 = log(r83577);
double r83595 = r83579 ? r83593 : r83594;
return r83595;
}




Bits error versus x
| Original | 38.9 |
|---|---|
| Target | 0.3 |
| Herbie | 0.2 |
if (+ 1.0 x) < 1.00000000442313Initial program 59.3
rmApplied flip3-+59.4
Applied log-div59.3
Taylor expanded around 0 0.2
Simplified0.2
Taylor expanded around 0 0.2
Simplified0.2
if 1.00000000442313 < (+ 1.0 x) Initial program 0.3
Final simplification0.2
herbie shell --seed 2020083 +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)))