Average Error: 61.3 → 0.3
Time: 10.5s
Precision: binary64
\[-1 < x \land x < 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[-1 + \left(\log \left(1 - {\left(x + {x}^{3} \cdot 0.08333333333333333\right)}^{3}\right) - \log \left(1 + \left(\left(x + {x}^{3} \cdot 0.08333333333333333\right) + \left(x + {x}^{3} \cdot 0.08333333333333333\right) \cdot \left(x + {x}^{3} \cdot 0.08333333333333333\right)\right)\right)\right)\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
-1 + \left(\log \left(1 - {\left(x + {x}^{3} \cdot 0.08333333333333333\right)}^{3}\right) - \log \left(1 + \left(\left(x + {x}^{3} \cdot 0.08333333333333333\right) + \left(x + {x}^{3} \cdot 0.08333333333333333\right) \cdot \left(x + {x}^{3} \cdot 0.08333333333333333\right)\right)\right)\right)
(FPCore (x) :precision binary64 (/ (log (- 1.0 x)) (log (+ 1.0 x))))
(FPCore (x)
 :precision binary64
 (+
  -1.0
  (-
   (log (- 1.0 (pow (+ x (* (pow x 3.0) 0.08333333333333333)) 3.0)))
   (log
    (+
     1.0
     (+
      (+ x (* (pow x 3.0) 0.08333333333333333))
      (*
       (+ x (* (pow x 3.0) 0.08333333333333333))
       (+ x (* (pow x 3.0) 0.08333333333333333)))))))))
double code(double x) {
	return log(1.0 - x) / log(1.0 + x);
}
double code(double x) {
	return -1.0 + (log(1.0 - pow((x + (pow(x, 3.0) * 0.08333333333333333)), 3.0)) - log(1.0 + ((x + (pow(x, 3.0) * 0.08333333333333333)) + ((x + (pow(x, 3.0) * 0.08333333333333333)) * (x + (pow(x, 3.0) * 0.08333333333333333))))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 61.3

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

    \[\leadsto \color{blue}{-\left(x + \left(0.5 \cdot {x}^{2} + \left(0.4166666666666667 \cdot {x}^{3} + 1\right)\right)\right)}\]
  3. Simplified0.3

    \[\leadsto \color{blue}{-1 + x \cdot \left(-1 - x \cdot \left(0.5 + x \cdot 0.4166666666666667\right)\right)}\]
  4. Using strategy rm
  5. Applied add-log-exp_binary64_4580.3

    \[\leadsto -1 + \color{blue}{\log \left(e^{x \cdot \left(-1 - x \cdot \left(0.5 + x \cdot 0.4166666666666667\right)\right)}\right)}\]
  6. Simplified0.3

    \[\leadsto -1 + \log \color{blue}{\left({\left(e^{x}\right)}^{\left(-1 - x \cdot \left(0.4166666666666667 \cdot x + 0.5\right)\right)}\right)}\]
  7. Taylor expanded around 0 0.3

    \[\leadsto -1 + \log \color{blue}{\left(1 - \left(x + 0.08333333333333333 \cdot {x}^{3}\right)\right)}\]
  8. Simplified0.3

    \[\leadsto -1 + \log \color{blue}{\left(1 - \left(x + {x}^{3} \cdot 0.08333333333333333\right)\right)}\]
  9. Using strategy rm
  10. Applied flip3--_binary64_4230.3

    \[\leadsto -1 + \log \color{blue}{\left(\frac{{1}^{3} - {\left(x + {x}^{3} \cdot 0.08333333333333333\right)}^{3}}{1 \cdot 1 + \left(\left(x + {x}^{3} \cdot 0.08333333333333333\right) \cdot \left(x + {x}^{3} \cdot 0.08333333333333333\right) + 1 \cdot \left(x + {x}^{3} \cdot 0.08333333333333333\right)\right)}\right)}\]
  11. Applied log-div_binary64_5060.3

    \[\leadsto -1 + \color{blue}{\left(\log \left({1}^{3} - {\left(x + {x}^{3} \cdot 0.08333333333333333\right)}^{3}\right) - \log \left(1 \cdot 1 + \left(\left(x + {x}^{3} \cdot 0.08333333333333333\right) \cdot \left(x + {x}^{3} \cdot 0.08333333333333333\right) + 1 \cdot \left(x + {x}^{3} \cdot 0.08333333333333333\right)\right)\right)\right)}\]
  12. Final simplification0.3

    \[\leadsto -1 + \left(\log \left(1 - {\left(x + {x}^{3} \cdot 0.08333333333333333\right)}^{3}\right) - \log \left(1 + \left(\left(x + {x}^{3} \cdot 0.08333333333333333\right) + \left(x + {x}^{3} \cdot 0.08333333333333333\right) \cdot \left(x + {x}^{3} \cdot 0.08333333333333333\right)\right)\right)\right)\]

Reproduce

herbie shell --seed 2021044 
(FPCore (x)
  :name "qlog (example 3.10)"
  :precision binary64
  :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))))