Average Error: 20.0 → 0.5
Time: 4.9s
Precision: binary64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{1 \cdot 1}{x + 1} \cdot \frac{\frac{1}{x}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{1 \cdot 1}{x + 1} \cdot \frac{\frac{1}{x}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}
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) (((double) (1.0 * 1.0)) / ((double) (x + 1.0)))) * ((double) (((double) (1.0 / x)) / ((double) (((double) (1.0 / ((double) sqrt(x)))) + ((double) (1.0 / ((double) sqrt(((double) (x + 1.0))))))))))));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 20.0

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

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

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

    \[\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-sub19.9

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

    \[\leadsto \frac{\frac{\color{blue}{\left(1 \cdot 1\right) \cdot \left(\left(x + 1\right) - x\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}}}\]
  9. Simplified19.4

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1}{x + 1} \cdot \frac{1}{x}}}{1 \cdot \left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right)}\]
  14. Applied times-frac0.5

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

    \[\leadsto \color{blue}{\frac{1 \cdot 1}{x + 1}} \cdot \frac{\frac{1}{x}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  16. Final simplification0.5

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

Reproduce

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