Average Error: 9.9 → 0.1
Time: 1.4m
Precision: 64
Internal Precision: 128
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[2 \cdot \frac{\frac{1}{x}}{-1 + x \cdot x}\]

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 9.9

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

    \[\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-add25.0

    \[\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. Taylor expanded around inf 0.2

    \[\leadsto \frac{\color{blue}{2}}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}\]
  6. Using strategy rm
  7. Applied add-sqr-sqrt1.0

    \[\leadsto \frac{\color{blue}{\sqrt{2} \cdot \sqrt{2}}}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}\]
  8. Applied associate-/l*0.7

    \[\leadsto \color{blue}{\frac{\sqrt{2}}{\frac{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}{\sqrt{2}}}}\]
  9. Using strategy rm
  10. Applied div-inv0.8

    \[\leadsto \frac{\sqrt{2}}{\color{blue}{\left(\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)\right) \cdot \frac{1}{\sqrt{2}}}}\]
  11. Applied *-un-lft-identity0.8

    \[\leadsto \frac{\sqrt{\color{blue}{1 \cdot 2}}}{\left(\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)\right) \cdot \frac{1}{\sqrt{2}}}\]
  12. Applied sqrt-prod0.8

    \[\leadsto \frac{\color{blue}{\sqrt{1} \cdot \sqrt{2}}}{\left(\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)\right) \cdot \frac{1}{\sqrt{2}}}\]
  13. Applied times-frac1.0

    \[\leadsto \color{blue}{\frac{\sqrt{1}}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)} \cdot \frac{\sqrt{2}}{\frac{1}{\sqrt{2}}}}\]
  14. Simplified0.8

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

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

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

Reproduce

herbie shell --seed 2019090 
(FPCore (x)
  :name "3frac (problem 3.3.3)"

  :herbie-target
  (/ 2 (* x (- (* x x) 1)))

  (+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))