\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 r69107 = 1.0;
double r69108 = x;
double r69109 = r69107 - r69108;
double r69110 = log(r69109);
double r69111 = r69107 + r69108;
double r69112 = log(r69111);
double r69113 = r69110 / r69112;
return r69113;
}
double f(double x) {
double r69114 = 1.0;
double r69115 = log(r69114);
double r69116 = x;
double r69117 = 0.5;
double r69118 = 2.0;
double r69119 = pow(r69116, r69118);
double r69120 = pow(r69114, r69118);
double r69121 = r69119 / r69120;
double r69122 = r69117 * r69121;
double r69123 = fma(r69114, r69116, r69122);
double r69124 = r69115 - r69123;
double r69125 = -0.5;
double r69126 = fma(r69114, r69116, r69115);
double r69127 = fma(r69125, r69121, r69126);
double r69128 = r69124 / r69127;
double r69129 = expm1(r69128);
double r69130 = log1p(r69129);
return r69130;
}




Bits error versus x
| Original | 61.4 |
|---|---|
| Target | 0.3 |
| Herbie | 0.4 |
Initial program 61.4
Taylor expanded around 0 60.5
Simplified60.5
Taylor expanded around 0 0.4
Simplified0.4
rmApplied log1p-expm1-u0.4
Final simplification0.4
herbie shell --seed 2019325 +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.4166666666666667 (pow x 3))))
(/ (log (- 1 x)) (log (+ 1 x))))