Average Error: 61.0 → 0.0
Time: 22.1s
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 r4628639 = 1.0;
        double r4628640 = x;
        double r4628641 = r4628639 - r4628640;
        double r4628642 = log(r4628641);
        double r4628643 = r4628639 + r4628640;
        double r4628644 = log(r4628643);
        double r4628645 = r4628642 / r4628644;
        return r4628645;
}

double f(double x) {
        double r4628646 = x;
        double r4628647 = -r4628646;
        double r4628648 = log1p(r4628647);
        double r4628649 = log1p(r4628646);
        double r4628650 = r4628648 / r4628649;
        double r4628651 = expm1(r4628650);
        double r4628652 = log1p(r4628651);
        return r4628652;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original61.0
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.0

    \[\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 sub-neg60.1

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

    \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(-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 2019134 +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))))