Average Error: 29.6 → 0.2
Time: 26.3s
Precision: 64
Internal Precision: 128
\[\sqrt{x + 1} - \sqrt{x}\]
\[\frac{1}{\sqrt{\left(\sqrt{x}\right)^2 + 1^2}^* + \sqrt{x}}\]

Error

Bits error versus x

Target

Original29.6
Target0.2
Herbie0.2
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}}\]

Derivation

  1. Initial program 29.6

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

    \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}}\]
  4. Taylor expanded around inf 0.2

    \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}}\]
  5. Using strategy rm
  6. Applied *-un-lft-identity0.2

    \[\leadsto \frac{1}{\sqrt{x + \color{blue}{1 \cdot 1}} + \sqrt{x}}\]
  7. Applied add-sqr-sqrt0.2

    \[\leadsto \frac{1}{\sqrt{\color{blue}{\sqrt{x} \cdot \sqrt{x}} + 1 \cdot 1} + \sqrt{x}}\]
  8. Applied hypot-def0.2

    \[\leadsto \frac{1}{\color{blue}{\sqrt{\left(\sqrt{x}\right)^2 + 1^2}^*} + \sqrt{x}}\]
  9. Final simplification0.2

    \[\leadsto \frac{1}{\sqrt{\left(\sqrt{x}\right)^2 + 1^2}^* + \sqrt{x}}\]

Reproduce

herbie shell --seed 2019094 +o rules:numerics
(FPCore (x)
  :name "2sqrt (example 3.1)"

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

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