\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 r69827 = 1.0;
double r69828 = x;
double r69829 = r69827 - r69828;
double r69830 = log(r69829);
double r69831 = r69827 + r69828;
double r69832 = log(r69831);
double r69833 = r69830 / r69832;
return r69833;
}
double f(double x) {
double r69834 = 1.0;
double r69835 = log(r69834);
double r69836 = x;
double r69837 = 0.5;
double r69838 = 2.0;
double r69839 = pow(r69836, r69838);
double r69840 = pow(r69834, r69838);
double r69841 = r69839 / r69840;
double r69842 = r69837 * r69841;
double r69843 = fma(r69834, r69836, r69842);
double r69844 = r69835 - r69843;
double r69845 = -0.5;
double r69846 = fma(r69834, r69836, r69835);
double r69847 = fma(r69845, r69841, r69846);
double r69848 = r69844 / r69847;
double r69849 = expm1(r69848);
double r69850 = log1p(r69849);
return r69850;
}




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 2019304 +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))))