Average Error: 9.9 → 0.3
Time: 1.0m
Precision: 64
Internal Precision: 1088
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\frac{2}{\left(x + -1\right) \cdot (x \cdot x + x)_*}\]

Error

Bits error versus x

Target

Original9.9
Target0.3
Herbie0.3
\[\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 add-sqr-sqrt25.4

    \[\leadsto \left(\color{blue}{\sqrt{\frac{1}{x + 1}} \cdot \sqrt{\frac{1}{x + 1}}} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
  4. Using strategy rm
  5. Applied sqrt-div24.7

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

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

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

    \[\leadsto \color{blue}{\frac{\left(\sqrt{1} \cdot \sqrt{1}\right) \cdot x - \left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right) \cdot 2}{\left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right) \cdot x}} + \frac{1}{x - 1}\]
  9. Applied frac-add28.7

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

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

    \[\leadsto \frac{(\left(x - (x \cdot 2 + 2)_*\right) \cdot \left(x + -1\right) + \left((x \cdot x + x)_*\right))_*}{\color{blue}{(x \cdot x + x)_* \cdot \left(x + -1\right)}}\]
  12. Taylor expanded around -inf 0.3

    \[\leadsto \frac{\color{blue}{2}}{(x \cdot x + x)_* \cdot \left(x + -1\right)}\]
  13. Final simplification0.3

    \[\leadsto \frac{2}{\left(x + -1\right) \cdot (x \cdot x + x)_*}\]

Runtime

Time bar (total: 1.0m)Debug logProfile

herbie shell --seed 2018248 +o rules:numerics
(FPCore (x)
  :name "3frac (problem 3.3.3)"

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

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