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

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program Error: 19.9 bits

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
  2. Using strategy rm
  3. Applied flip--Error: 19.9 bits

    \[\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. SimplifiedError: 19.9 bits

    \[\leadsto \frac{\color{blue}{\frac{1}{\frac{x}{1}} - \frac{1}{\frac{1 + x}{1}}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  5. SimplifiedError: 19.9 bits

    \[\leadsto \frac{\frac{1}{\frac{x}{1}} - \frac{1}{\frac{1 + x}{1}}}{\color{blue}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}}}\]
  6. Using strategy rm
  7. Applied frac-subError: 19.3 bits

    \[\leadsto \frac{\color{blue}{\frac{1 \cdot \frac{1 + x}{1} - \frac{x}{1} \cdot 1}{\frac{x}{1} \cdot \frac{1 + x}{1}}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}}\]
  8. Applied associate-/l/Error: 19.3 bits

    \[\leadsto \color{blue}{\frac{1 \cdot \frac{1 + x}{1} - \frac{x}{1} \cdot 1}{\left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}\right) \cdot \left(\frac{x}{1} \cdot \frac{1 + x}{1}\right)}}\]
  9. SimplifiedError: 19.3 bits

    \[\leadsto \frac{1 \cdot \frac{1 + x}{1} - \frac{x}{1} \cdot 1}{\color{blue}{\frac{x}{1} \cdot \left(\frac{1 + x}{1} \cdot \left(\frac{1}{\sqrt{1 + x}} + \frac{1}{\sqrt{x}}\right)\right)}}\]
  10. Taylor expanded around 0 Error: 0.7 bits

    \[\leadsto \frac{\color{blue}{1}}{\frac{x}{1} \cdot \left(\frac{1 + x}{1} \cdot \left(\frac{1}{\sqrt{1 + x}} + \frac{1}{\sqrt{x}}\right)\right)}\]
  11. Using strategy rm
  12. Applied associate-/r*Error: 0.4 bits

    \[\leadsto \color{blue}{\frac{\frac{1}{\frac{x}{1}}}{\frac{1 + x}{1} \cdot \left(\frac{1}{\sqrt{1 + x}} + \frac{1}{\sqrt{x}}\right)}}\]
  13. SimplifiedError: 0.4 bits

    \[\leadsto \frac{\color{blue}{\frac{1}{x} \cdot 1}}{\frac{1 + x}{1} \cdot \left(\frac{1}{\sqrt{1 + x}} + \frac{1}{\sqrt{x}}\right)}\]
  14. Final simplificationError: 0.4 bits

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

Reproduce

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