Average Error: 60.9 → 0.0
Time: 15.6s
Precision: 64
\[-1 \lt x \land x \lt 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[\frac{\mathsf{log1p}\left(\left(-x\right)\right)}{\mathsf{log1p}\left(x\right)}\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
\frac{\mathsf{log1p}\left(\left(-x\right)\right)}{\mathsf{log1p}\left(x\right)}
double f(double x) {
        double r2302449 = 1.0;
        double r2302450 = x;
        double r2302451 = r2302449 - r2302450;
        double r2302452 = log(r2302451);
        double r2302453 = r2302449 + r2302450;
        double r2302454 = log(r2302453);
        double r2302455 = r2302452 / r2302454;
        return r2302455;
}

double f(double x) {
        double r2302456 = x;
        double r2302457 = -r2302456;
        double r2302458 = log1p(r2302457);
        double r2302459 = log1p(r2302456);
        double r2302460 = r2302458 / r2302459;
        return r2302460;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original60.9
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 60.9

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

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

    \[\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(\left(-x\right)\right)}}{\mathsf{log1p}\left(x\right)}\]
  6. Using strategy rm
  7. Applied expm1-log1p-u0.0

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

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

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

Reproduce

herbie shell --seed 2019130 +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))))