Average Error: 19.4 → 0.4
Time: 4.1s
Precision: binary64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{1}{x} \cdot \frac{1}{\left(1 + x\right) \cdot \left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}\right)}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{1}{x} \cdot \frac{1}{\left(1 + x\right) \cdot \left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}\right)}
double code(double x) {
	return ((double) (((double) (1.0 / ((double) sqrt(x)))) - ((double) (1.0 / ((double) sqrt(((double) (x + 1.0))))))));
}
double code(double x) {
	return ((double) (((double) (1.0 / x)) * ((double) (1.0 / ((double) (((double) (1.0 + x)) * ((double) (((double) (1.0 / ((double) sqrt(x)))) + ((double) (1.0 / ((double) sqrt(((double) (1.0 + x))))))))))))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 19.4

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

    \[\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.4

    \[\leadsto \frac{\color{blue}{1 \cdot \left(\frac{1}{x} - \frac{1}{1 + x}\right)}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  5. Simplified19.4

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

    \[\leadsto \frac{1 \cdot \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. Applied associate-*r/18.7

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

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

    \[\leadsto \frac{1 \cdot \left(1 \cdot \left(1 + x\right) - x \cdot 1\right)}{\color{blue}{x \cdot \left(\left(1 + x\right) \cdot \left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}\right)\right)}}\]
  11. Taylor expanded around 0 0.8

    \[\leadsto \frac{1 \cdot \color{blue}{1}}{x \cdot \left(\left(1 + x\right) \cdot \left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}\right)\right)}\]
  12. Using strategy rm
  13. Applied times-frac0.4

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

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

Reproduce

herbie shell --seed 2020184 
(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)))))