Average Error: 61.1 → 0.0
Time: 14.8s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\mathsf{log1p}\left(-x\right)}{\mathsf{log1p}\left(x\right)}\right)\right)\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\mathsf{log1p}\left(-x\right)}{\mathsf{log1p}\left(x\right)}\right)\right)
double f(double x) {
        double r1467724 = 1.0;
        double r1467725 = x;
        double r1467726 = r1467724 - r1467725;
        double r1467727 = log(r1467726);
        double r1467728 = r1467724 + r1467725;
        double r1467729 = log(r1467728);
        double r1467730 = r1467727 / r1467729;
        return r1467730;
}

double f(double x) {
        double r1467731 = x;
        double r1467732 = -r1467731;
        double r1467733 = log1p(r1467732);
        double r1467734 = log1p(r1467731);
        double r1467735 = r1467733 / r1467734;
        double r1467736 = expm1(r1467735);
        double r1467737 = log1p(r1467736);
        return r1467737;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original61.1
Target0.3
Herbie0.0
\[-\left(\left(\left(1 + x\right) + \frac{x \cdot x}{2}\right) + \frac{5}{12} \cdot {x}^{3}\right)\]

Derivation

  1. Initial program 61.1

    \[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
  2. Simplified60.1

    \[\leadsto \color{blue}{\frac{\log \left(1 - x\right)}{\mathsf{log1p}\left(x\right)}}\]
  3. Using strategy rm
  4. Applied log1p-expm1-u60.1

    \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(1 - x\right)\right)\right)}}{\mathsf{log1p}\left(x\right)}\]
  5. Simplified0.0

    \[\leadsto \frac{\mathsf{log1p}\left(\color{blue}{-x}\right)}{\mathsf{log1p}\left(x\right)}\]
  6. Using strategy rm
  7. Applied log1p-expm1-u0.0

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\mathsf{log1p}\left(-x\right)}{\mathsf{log1p}\left(x\right)}\right)\right)}\]
  8. Final simplification0.0

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\mathsf{log1p}\left(-x\right)}{\mathsf{log1p}\left(x\right)}\right)\right)\]

Reproduce

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

  :herbie-target
  (- (+ (+ (+ 1 x) (/ (* x x) 2)) (* 5/12 (pow x 3))))

  (/ (log (- 1 x)) (log (+ 1 x))))