Average Error: 20.5 → 0.4
Time: 47.5s
Precision: 64
Internal Precision: 128
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{\frac{1}{x}}{\sqrt{x + 1} + \frac{x + 1}{\sqrt{x}}}\]

Error

Bits error versus x

Target

Original20.5
Target0.6
Herbie0.4
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Initial program 20.5

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
  2. Using strategy rm
  3. Applied flip--20.5

    \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}}\]
  4. Using strategy rm
  5. Applied frac-times25.5

    \[\leadsto \frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1 \cdot 1}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  6. Applied frac-times20.6

    \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1}{\sqrt{x} \cdot \sqrt{x}}} - \frac{1 \cdot 1}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  7. Applied frac-sub20.3

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

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

    \[\leadsto \frac{\color{blue}{1}}{\left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right) \cdot \left(\left(\sqrt{x} \cdot \sqrt{x}\right) \cdot \left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right)\right)}\]
  10. Using strategy rm
  11. Applied pow15.8

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

    \[\leadsto \frac{1}{\left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right) \cdot \left(\left(\sqrt{x} \cdot \color{blue}{{\left(\sqrt{x}\right)}^{1}}\right) \cdot {\left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right)}^{1}\right)}\]
  13. Applied pow15.8

    \[\leadsto \frac{1}{\left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right) \cdot \left(\left(\color{blue}{{\left(\sqrt{x}\right)}^{1}} \cdot {\left(\sqrt{x}\right)}^{1}\right) \cdot {\left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right)}^{1}\right)}\]
  14. Applied pow-prod-down5.8

    \[\leadsto \frac{1}{\left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right) \cdot \left(\color{blue}{{\left(\sqrt{x} \cdot \sqrt{x}\right)}^{1}} \cdot {\left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right)}^{1}\right)}\]
  15. Applied pow-prod-down5.8

    \[\leadsto \frac{1}{\left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right) \cdot \color{blue}{{\left(\left(\sqrt{x} \cdot \sqrt{x}\right) \cdot \left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right)\right)}^{1}}}\]
  16. Applied pow15.8

    \[\leadsto \frac{1}{\color{blue}{{\left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right)}^{1}} \cdot {\left(\left(\sqrt{x} \cdot \sqrt{x}\right) \cdot \left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right)\right)}^{1}}\]
  17. Applied pow-prod-down5.8

    \[\leadsto \frac{1}{\color{blue}{{\left(\left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right) \cdot \left(\left(\sqrt{x} \cdot \sqrt{x}\right) \cdot \left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right)\right)\right)}^{1}}}\]
  18. Simplified0.7

    \[\leadsto \frac{1}{{\color{blue}{\left(x \cdot \left(\sqrt{x + 1} + \frac{x + 1}{\sqrt{x}}\right)\right)}}^{1}}\]
  19. Using strategy rm
  20. Applied unpow-prod-down0.7

    \[\leadsto \frac{1}{\color{blue}{{x}^{1} \cdot {\left(\sqrt{x + 1} + \frac{x + 1}{\sqrt{x}}\right)}^{1}}}\]
  21. Applied associate-/r*0.4

    \[\leadsto \color{blue}{\frac{\frac{1}{{x}^{1}}}{{\left(\sqrt{x + 1} + \frac{x + 1}{\sqrt{x}}\right)}^{1}}}\]
  22. Simplified0.4

    \[\leadsto \frac{\frac{1}{{x}^{1}}}{\color{blue}{\sqrt{1 + x} + \frac{1 + x}{\sqrt{x}}}}\]
  23. Final simplification0.4

    \[\leadsto \frac{\frac{1}{x}}{\sqrt{x + 1} + \frac{x + 1}{\sqrt{x}}}\]

Reproduce

herbie shell --seed 2019089 
(FPCore (x)
  :name "2isqrt (example 3.6)"

  :herbie-target
  (/ 1 (+ (* (+ x 1) (sqrt x)) (* x (sqrt (+ x 1)))))

  (- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))