Average Error: 61.6 → 0.4
Time: 20.7s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\frac{\log 1 - \mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{1}{2}, 1 \cdot x\right)}{\mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\frac{\log 1 - \mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{1}{2}, 1 \cdot x\right)}{\mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(1, x, \log 1\right)\right)}
double f(double x) {
        double r4312811 = 1.0;
        double r4312812 = x;
        double r4312813 = r4312811 - r4312812;
        double r4312814 = log(r4312813);
        double r4312815 = r4312811 + r4312812;
        double r4312816 = log(r4312815);
        double r4312817 = r4312814 / r4312816;
        return r4312817;
}

double f(double x) {
        double r4312818 = 1.0;
        double r4312819 = log(r4312818);
        double r4312820 = x;
        double r4312821 = r4312820 / r4312818;
        double r4312822 = r4312821 * r4312821;
        double r4312823 = 0.5;
        double r4312824 = r4312818 * r4312820;
        double r4312825 = fma(r4312822, r4312823, r4312824);
        double r4312826 = r4312819 - r4312825;
        double r4312827 = -0.5;
        double r4312828 = fma(r4312818, r4312820, r4312819);
        double r4312829 = fma(r4312822, r4312827, r4312828);
        double r4312830 = r4312826 / r4312829;
        return r4312830;
}

Error

Bits error versus x

Target

Original61.6
Target0.3
Herbie0.4
\[-\left(\left(\left(1 + x\right) + \frac{x \cdot x}{2}\right) + 0.4166666666666666851703837437526090070605 \cdot {x}^{3}\right)\]

Derivation

  1. Initial program 61.6

    \[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
  2. Taylor expanded around 0 60.5

    \[\leadsto \frac{\log \left(1 - x\right)}{\color{blue}{\left(\log 1 + 1 \cdot x\right) - \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}}}\]
  3. Simplified60.5

    \[\leadsto \frac{\log \left(1 - x\right)}{\color{blue}{\mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(1, x, \log 1\right)\right)}}\]
  4. Taylor expanded around 0 0.4

    \[\leadsto \frac{\color{blue}{\log 1 - \left(1 \cdot x + \frac{1}{2} \cdot \frac{{x}^{2}}{{1}^{2}}\right)}}{\mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\]
  5. Simplified0.4

    \[\leadsto \frac{\color{blue}{\log 1 - \mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{1}{2}, 1 \cdot x\right)}}{\mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\]
  6. Final simplification0.4

    \[\leadsto \frac{\log 1 - \mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{1}{2}, 1 \cdot x\right)}{\mathsf{fma}\left(\frac{x}{1} \cdot \frac{x}{1}, \frac{-1}{2}, \mathsf{fma}\left(1, x, \log 1\right)\right)}\]

Reproduce

herbie shell --seed 2019169 +o rules:numerics
(FPCore (x)
  :name "qlog (example 3.10)"
  :pre (and (< -1.0 x) (< x 1.0))

  :herbie-target
  (- (+ (+ (+ 1.0 x) (/ (* x x) 2.0)) (* 0.4166666666666667 (pow x 3.0))))

  (/ (log (- 1.0 x)) (log (+ 1.0 x))))