Average Error: 19.7 → 5.9
Time: 6.2s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\begin{array}{l} \mathbf{if}\;x \le 7117.86092887425093:\\ \;\;\;\;\frac{1}{\sqrt{x}} - \left(\sqrt[3]{\frac{1}{\sqrt{x + 1}}} \cdot \sqrt[3]{\frac{1}{\sqrt{x + 1}}}\right) \cdot \sqrt[3]{\frac{1}{\sqrt{x + 1}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 \cdot \left(\left(\frac{1}{{x}^{2}} + \frac{1}{{x}^{4}}\right) - \frac{1}{{x}^{3}}\right)}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\\ \end{array}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\begin{array}{l}
\mathbf{if}\;x \le 7117.86092887425093:\\
\;\;\;\;\frac{1}{\sqrt{x}} - \left(\sqrt[3]{\frac{1}{\sqrt{x + 1}}} \cdot \sqrt[3]{\frac{1}{\sqrt{x + 1}}}\right) \cdot \sqrt[3]{\frac{1}{\sqrt{x + 1}}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1 \cdot \left(\left(\frac{1}{{x}^{2}} + \frac{1}{{x}^{4}}\right) - \frac{1}{{x}^{3}}\right)}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\\

\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 <= 7117.860928874251)) {
		VAR = ((1.0 / sqrt(x)) - ((cbrt((1.0 / sqrt((x + 1.0)))) * cbrt((1.0 / sqrt((x + 1.0))))) * cbrt((1.0 / sqrt((x + 1.0))))));
	} else {
		VAR = ((1.0 * (((1.0 / pow(x, 2.0)) + (1.0 / pow(x, 4.0))) - (1.0 / pow(x, 3.0)))) / ((1.0 / sqrt(x)) + (1.0 / sqrt((x + 1.0)))));
	}
	return VAR;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

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

    1. Initial program 0.4

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
    2. Using strategy rm
    3. Applied add-cube-cbrt0.4

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

    if 7117.860928874251 < x

    1. Initial program 39.7

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

      \[\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. Taylor expanded around inf 11.6

      \[\leadsto \frac{\color{blue}{\left(1 \cdot \frac{1}{{x}^{2}} + 1 \cdot \frac{1}{{x}^{4}}\right) - 1 \cdot \frac{1}{{x}^{3}}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
    5. Simplified11.6

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\left(\frac{1}{{x}^{2}} + \frac{1}{{x}^{4}}\right) - \frac{1}{{x}^{3}}\right)}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le 7117.86092887425093:\\ \;\;\;\;\frac{1}{\sqrt{x}} - \left(\sqrt[3]{\frac{1}{\sqrt{x + 1}}} \cdot \sqrt[3]{\frac{1}{\sqrt{x + 1}}}\right) \cdot \sqrt[3]{\frac{1}{\sqrt{x + 1}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1 \cdot \left(\left(\frac{1}{{x}^{2}} + \frac{1}{{x}^{4}}\right) - \frac{1}{{x}^{3}}\right)}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\\ \end{array}\]

Reproduce

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