Average Error: 9.8 → 0.1
Time: 4.4s
Precision: binary64
Cost: 576
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\frac{\frac{2}{x}}{x \cdot x + -1}\]
\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}
\frac{\frac{2}{x}}{x \cdot x + -1}
(FPCore (x)
 :precision binary64
 (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))
(FPCore (x) :precision binary64 (/ (/ 2.0 x) (+ (* x x) -1.0)))
double code(double x) {
	return ((1.0 / (x + 1.0)) - (2.0 / x)) + (1.0 / (x - 1.0));
}
double code(double x) {
	return (2.0 / x) / ((x * x) + -1.0);
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original9.8
Target0.3
Herbie0.1
\[\frac{2}{x \cdot \left(x \cdot x - 1\right)}\]

Alternatives

Alternative 1
Error10.6
Cost1218
\[\begin{array}{l} \mathbf{if}\;x \leq -0.9916973497488216:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 0.4982984274889607:\\ \;\;\;\;\frac{-2}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x + -1} + \frac{-1}{x}\\ \end{array}\]
Alternative 2
Error10.7
Cost834
\[\begin{array}{l} \mathbf{if}\;x \leq -0.9916973497488216:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.0048841710211733:\\ \;\;\;\;\frac{-2}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 3
Error41.6
Cost64
\[0\]
Alternative 4
Error61.9
Cost64
\[1\]

Error

Derivation

  1. Initial program 9.8

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
  2. Using strategy rm
  3. Applied frac-sub_binary64_111025.6

    \[\leadsto \color{blue}{\frac{1 \cdot x - \left(x + 1\right) \cdot 2}{\left(x + 1\right) \cdot x}} + \frac{1}{x - 1}\]
  4. Applied frac-add_binary64_110925.3

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

    \[\leadsto \frac{\color{blue}{\left(x - 1\right) \cdot \left(x - \left(1 + x\right) \cdot 2\right) + x \cdot \left(1 + x\right)}}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}\]
  6. Simplified25.3

    \[\leadsto \frac{\left(x - 1\right) \cdot \left(x - \left(1 + x\right) \cdot 2\right) + x \cdot \left(1 + x\right)}{\color{blue}{{x}^{3} - x}}\]
  7. Taylor expanded around 0 0.3

    \[\leadsto \frac{\color{blue}{2}}{{x}^{3} - x}\]
  8. Using strategy rm
  9. Applied *-un-lft-identity_binary64_11010.3

    \[\leadsto \frac{2}{{x}^{3} - \color{blue}{1 \cdot x}}\]
  10. Applied unpow3_binary64_11670.3

    \[\leadsto \frac{2}{\color{blue}{\left(x \cdot x\right) \cdot x} - 1 \cdot x}\]
  11. Applied distribute-rgt-out--_binary64_10550.3

    \[\leadsto \frac{2}{\color{blue}{x \cdot \left(x \cdot x - 1\right)}}\]
  12. Applied associate-/r*_binary64_10450.1

    \[\leadsto \color{blue}{\frac{\frac{2}{x}}{x \cdot x - 1}}\]
  13. Simplified0.1

    \[\leadsto \color{blue}{\frac{\frac{2}{x}}{x \cdot x + -1}}\]
  14. Final simplification0.1

    \[\leadsto \frac{\frac{2}{x}}{x \cdot x + -1}\]

Reproduce

herbie shell --seed 2021044 
(FPCore (x)
  :name "3frac (problem 3.3.3)"
  :precision binary64

  :herbie-target
  (/ 2.0 (* x (- (* x x) 1.0)))

  (+ (- (/ 1.0 (+ x 1.0)) (/ 2.0 x)) (/ 1.0 (- x 1.0))))