Average Error: 61.4 → 0.5
Time: 13.3s
Precision: binary64
Cost: 576
\[-1 < x \land x < 1\]
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
\[-1 - \left(x + \left(x \cdot x\right) \cdot 0.5\right)\]
\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}
-1 - \left(x + \left(x \cdot x\right) \cdot 0.5\right)
(FPCore (x) :precision binary64 (/ (log (- 1.0 x)) (log (+ 1.0 x))))
(FPCore (x) :precision binary64 (- -1.0 (+ x (* (* x x) 0.5))))
double code(double x) {
	return log(1.0 - x) / log(1.0 + x);
}
double code(double x) {
	return -1.0 - (x + ((x * x) * 0.5));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Alternatives

Alternative 1
Error61.4
Cost45888
\[\frac{1}{\sqrt[3]{\log \left(1 + x\right)} \cdot \sqrt[3]{\log \left(1 + x\right)}} \cdot \frac{\log \left(1 - x\right)}{\sqrt[3]{\log \left(1 + x\right)}}\]
Alternative 2
Error61.4
Cost45760
\[\frac{\frac{\log \left(1 - x\right)}{\sqrt[3]{\log \left(1 + x\right)} \cdot \sqrt[3]{\log \left(1 + x\right)}}}{\sqrt[3]{\log \left(1 + x\right)}}\]
Alternative 3
Error61.7
Cost32704
\[\frac{\log \left(1 - x\right)}{\log \left(\sqrt{1 + x}\right) + \log \left(\sqrt{1 + x}\right)}\]
Alternative 4
Error61.6
Cost32704
\[\frac{\log \left(\sqrt{1 - x}\right) + \log \left(\sqrt{1 - x}\right)}{\log \left(1 + x\right)}\]
Alternative 5
Error61.3
Cost26624
\[\frac{\log \left(1 - {x}^{3}\right) - \log \left(1 + \left(x + x \cdot x\right)\right)}{\log \left(1 + x\right)}\]
Alternative 6
Error61.3
Cost26624
\[\frac{\log \left(1 - x\right)}{\log \left(1 + {x}^{3}\right) - \log \left(1 + \left(x \cdot x - x\right)\right)}\]
Alternative 7
Error61.4
Cost26112
\[\frac{\sqrt[3]{{\log \left(1 - x\right)}^{3}}}{\log \left(1 + x\right)}\]
Alternative 8
Error61.3
Cost20032
\[\frac{\log \left(1 - x\right)}{\log \left(1 - x \cdot x\right) - \log \left(1 - x\right)}\]
Alternative 9
Error61.3
Cost20032
\[\frac{\log \left(1 - x \cdot x\right) - \log \left(1 + x\right)}{\log \left(1 + x\right)}\]
Alternative 10
Error61.3
Cost13504
\[-1 + \frac{\log \left(1 - x \cdot x\right)}{\log \left(1 + x\right)}\]
Alternative 11
Error61.4
Cost13248
\[\frac{\log \left(1 - x\right)}{\log \left(1 + x\right)}\]
Alternative 12
Error62.5
Cost7104
\[\frac{x \cdot \left(-1 + x \cdot -0.5\right)}{\log \left(1 + x\right)}\]
Alternative 13
Error62.7
Cost6784
\[\frac{-x}{\log \left(1 + x\right)}\]
Alternative 14
Error60.8
Cost6720
\[\frac{\log \left(1 - x\right)}{x}\]
Alternative 15
Error0.7
Cost192
\[-1 - x\]
Alternative 16
Error1.3
Cost64
\[-1\]
Alternative 17
Error63.0
Cost64
\[1\]
Alternative 18
Error62.0
Cost64
\[0\]

Error

Derivation

  1. Initial program 61.4

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

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

    \[\leadsto \color{blue}{-1 - \left(x + \left(x \cdot x\right) \cdot 0.5\right)}\]
  4. Simplified0.5

    \[\leadsto \color{blue}{-1 - \left(x + \left(x \cdot x\right) \cdot 0.5\right)}\]
  5. Final simplification0.5

    \[\leadsto -1 - \left(x + \left(x \cdot x\right) \cdot 0.5\right)\]

Reproduce

herbie shell --seed 2021042 
(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))))