\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\log 1 - \mathsf{fma}\left(1, x, \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}{\mathsf{fma}\left(\frac{-1}{2}, \frac{{x}^{2}}{{1}^{2}}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\right)\right)double f(double x) {
double r68476 = 1.0;
double r68477 = x;
double r68478 = r68476 - r68477;
double r68479 = log(r68478);
double r68480 = r68476 + r68477;
double r68481 = log(r68480);
double r68482 = r68479 / r68481;
return r68482;
}
double f(double x) {
double r68483 = 1.0;
double r68484 = log(r68483);
double r68485 = x;
double r68486 = 0.5;
double r68487 = 2.0;
double r68488 = pow(r68485, r68487);
double r68489 = pow(r68483, r68487);
double r68490 = r68488 / r68489;
double r68491 = r68486 * r68490;
double r68492 = fma(r68483, r68485, r68491);
double r68493 = r68484 - r68492;
double r68494 = -0.5;
double r68495 = fma(r68483, r68485, r68484);
double r68496 = fma(r68494, r68490, r68495);
double r68497 = r68493 / r68496;
double r68498 = expm1(r68497);
double r68499 = log1p(r68498);
return r68499;
}




Bits error versus x
| Original | 61.3 |
|---|---|
| Target | 0.3 |
| Herbie | 0.4 |
Initial program 61.3
Taylor expanded around 0 60.4
Simplified60.4
Taylor expanded around 0 0.4
Simplified0.4
rmApplied log1p-expm1-u0.4
Final simplification0.4
herbie shell --seed 2019303 +o rules:numerics
(FPCore (x)
:name "qlog (example 3.10)"
:precision binary64
:pre (and (< -1 x) (< x 1))
:herbie-target
(- (+ (+ (+ 1 x) (/ (* x x) 2)) (* 0.416666666666666685 (pow x 3))))
(/ (log (- 1 x)) (log (+ 1 x))))