Average Error: 19.6 → 0.3
Time: 8.8s
Precision: binary64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{\frac{1}{1 + x}}{\sqrt{x} \cdot \left(1 + \frac{\sqrt{x}}{\sqrt{1 + x}}\right)}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{\frac{1}{1 + x}}{\sqrt{x} \cdot \left(1 + \frac{\sqrt{x}}{\sqrt{1 + x}}\right)}
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x)
 :precision binary64
 (/ (/ 1.0 (+ 1.0 x)) (* (sqrt x) (+ 1.0 (/ (sqrt x) (sqrt (+ 1.0 x)))))))
double code(double x) {
	return (1.0 / sqrt(x)) - (1.0 / sqrt(x + 1.0));
}
double code(double x) {
	return (1.0 / (1.0 + x)) / (sqrt(x) * (1.0 + (sqrt(x) / sqrt(1.0 + x))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.6
Target0.7
Herbie0.3
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Initial program 19.6

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

    \[\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. Simplified19.6

    \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{1}{1 + x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  5. Simplified19.6

    \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\color{blue}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}}}\]
  6. Using strategy rm
  7. Applied frac-sub_binary6419.0

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

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

    \[\leadsto \frac{\frac{1}{\color{blue}{x + x \cdot x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}}\]
  10. Using strategy rm
  11. Applied distribute-rgt1-in_binary645.7

    \[\leadsto \frac{\frac{1}{\color{blue}{\left(x + 1\right) \cdot x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}}\]
  12. Applied *-un-lft-identity_binary645.7

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

    \[\leadsto \frac{\color{blue}{\frac{1}{x + 1} \cdot \frac{1}{x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}}\]
  14. Applied associate-/l*_binary640.4

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

    \[\leadsto \frac{\frac{1}{x + 1}}{\color{blue}{\frac{x}{\sqrt{x}} + \frac{x}{\sqrt{1 + x}}}}\]
  16. Using strategy rm
  17. Applied *-un-lft-identity_binary640.4

    \[\leadsto \frac{\frac{1}{x + 1}}{\frac{x}{\sqrt{x}} + \frac{x}{\color{blue}{1 \cdot \sqrt{1 + x}}}}\]
  18. Applied add-sqr-sqrt_binary640.3

    \[\leadsto \frac{\frac{1}{x + 1}}{\frac{x}{\sqrt{x}} + \frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{1 \cdot \sqrt{1 + x}}}\]
  19. Applied times-frac_binary640.3

    \[\leadsto \frac{\frac{1}{x + 1}}{\frac{x}{\sqrt{x}} + \color{blue}{\frac{\sqrt{x}}{1} \cdot \frac{\sqrt{x}}{\sqrt{1 + x}}}}\]
  20. Applied *-un-lft-identity_binary640.3

    \[\leadsto \frac{\frac{1}{x + 1}}{\frac{x}{\color{blue}{1 \cdot \sqrt{x}}} + \frac{\sqrt{x}}{1} \cdot \frac{\sqrt{x}}{\sqrt{1 + x}}}\]
  21. Applied add-sqr-sqrt_binary640.3

    \[\leadsto \frac{\frac{1}{x + 1}}{\frac{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{1 \cdot \sqrt{x}} + \frac{\sqrt{x}}{1} \cdot \frac{\sqrt{x}}{\sqrt{1 + x}}}\]
  22. Applied times-frac_binary640.3

    \[\leadsto \frac{\frac{1}{x + 1}}{\color{blue}{\frac{\sqrt{x}}{1} \cdot \frac{\sqrt{x}}{\sqrt{x}}} + \frac{\sqrt{x}}{1} \cdot \frac{\sqrt{x}}{\sqrt{1 + x}}}\]
  23. Applied distribute-lft-out_binary640.3

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

    \[\leadsto \frac{\frac{1}{x + 1}}{\frac{\sqrt{x}}{1} \cdot \color{blue}{\left(1 + \frac{\sqrt{x}}{\sqrt{x + 1}}\right)}}\]
  25. Final simplification0.3

    \[\leadsto \frac{\frac{1}{1 + x}}{\sqrt{x} \cdot \left(1 + \frac{\sqrt{x}}{\sqrt{1 + x}}\right)}\]

Alternatives

Reproduce

herbie shell --seed 2021110 
(FPCore (x)
  :name "2isqrt (example 3.6)"
  :precision binary64

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

  (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))