Average Error: 19.6 → 10.5
Time: 8.9s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\begin{array}{l} \mathbf{if}\;x \le 7077.048346062627:\\ \;\;\;\;\frac{1}{\sqrt{x}} - \frac{\frac{1}{\sqrt{\sqrt{x + 1}}}}{\sqrt{\sqrt{x + 1}}}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}} - 0.375 \cdot \sqrt{\frac{1}{{x}^{5}}}\right) + \left(0.3125 \cdot 1\right) \cdot \sqrt{\frac{1}{{x}^{7}}}\\ \end{array}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\begin{array}{l}
\mathbf{if}\;x \le 7077.048346062627:\\
\;\;\;\;\frac{1}{\sqrt{x}} - \frac{\frac{1}{\sqrt{\sqrt{x + 1}}}}{\sqrt{\sqrt{x + 1}}}\\

\mathbf{else}:\\
\;\;\;\;1 \cdot \left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}} - 0.375 \cdot \sqrt{\frac{1}{{x}^{5}}}\right) + \left(0.3125 \cdot 1\right) \cdot \sqrt{\frac{1}{{x}^{7}}}\\

\end{array}
double code(double x) {
	return ((1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))));
}
double code(double x) {
	double VAR;
	if ((x <= 7077.048346062627)) {
		VAR = ((1.0 / sqrt(x)) - ((1.0 / sqrt(sqrt((x + 1.0)))) / sqrt(sqrt((x + 1.0)))));
	} else {
		VAR = ((1.0 * ((0.5 * sqrt((1.0 / pow(x, 3.0)))) - (0.375 * sqrt((1.0 / pow(x, 5.0)))))) + ((0.3125 * 1.0) * sqrt((1.0 / pow(x, 7.0)))));
	}
	return VAR;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.6
Target0.6
Herbie10.5
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < 7077.048346062627

    1. Initial program 0.3

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.3

      \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}}\]
    4. Applied sqrt-prod0.4

      \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\color{blue}{\sqrt{\sqrt{x + 1}} \cdot \sqrt{\sqrt{x + 1}}}}\]
    5. Applied associate-/r*0.4

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\frac{\frac{1}{\sqrt{\sqrt{x + 1}}}}{\sqrt{\sqrt{x + 1}}}}\]

    if 7077.048346062627 < x

    1. Initial program 39.5

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt39.5

      \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}}\]
    4. Applied sqrt-prod48.7

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

      \[\leadsto \frac{1}{\sqrt{x}} - \frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{\sqrt{\sqrt{x + 1}} \cdot \sqrt{\sqrt{x + 1}}}\]
    6. Applied times-frac51.8

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

      \[\leadsto \color{blue}{\sqrt{\frac{1}{\sqrt{x}}} \cdot \sqrt{\frac{1}{\sqrt{x}}}} - \frac{\sqrt{1}}{\sqrt{\sqrt{x + 1}}} \cdot \frac{\sqrt{1}}{\sqrt{\sqrt{x + 1}}}\]
    8. Applied difference-of-squares45.6

      \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{\sqrt{x}}} + \frac{\sqrt{1}}{\sqrt{\sqrt{x + 1}}}\right) \cdot \left(\sqrt{\frac{1}{\sqrt{x}}} - \frac{\sqrt{1}}{\sqrt{\sqrt{x + 1}}}\right)}\]
    9. Taylor expanded around inf 21.0

      \[\leadsto \color{blue}{\left(0.3125 \cdot \left(\sqrt{\frac{1}{{x}^{7}}} \cdot {\left(\sqrt{1}\right)}^{2}\right) + 0.5 \cdot \left(\sqrt{\frac{1}{{x}^{3}}} \cdot {\left(\sqrt{1}\right)}^{2}\right)\right) - 0.375 \cdot \left(\sqrt{\frac{1}{{x}^{5}}} \cdot {\left(\sqrt{1}\right)}^{2}\right)}\]
    10. Simplified21.0

      \[\leadsto \color{blue}{1 \cdot \left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}} - 0.375 \cdot \sqrt{\frac{1}{{x}^{5}}}\right) + \left(0.3125 \cdot 1\right) \cdot \sqrt{\frac{1}{{x}^{7}}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification10.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 7077.048346062627:\\ \;\;\;\;\frac{1}{\sqrt{x}} - \frac{\frac{1}{\sqrt{\sqrt{x + 1}}}}{\sqrt{\sqrt{x + 1}}}\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(0.5 \cdot \sqrt{\frac{1}{{x}^{3}}} - 0.375 \cdot \sqrt{\frac{1}{{x}^{5}}}\right) + \left(0.3125 \cdot 1\right) \cdot \sqrt{\frac{1}{{x}^{7}}}\\ \end{array}\]

Reproduce

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

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

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