Average Error: 19.9 → 19.9
Time: 4.4s
Precision: binary64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\begin{array}{l} \mathbf{if}\;x \leq 5.641413807697915 \cdot 10^{+96}:\\ \;\;\;\;{x}^{-0.5} - \frac{\frac{1}{\left|\sqrt[3]{x + 1}\right|}}{\sqrt{\sqrt[3]{x + 1}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{{x}^{1.5}} + \frac{-1}{{\left(\sqrt{x + 1}\right)}^{3}}}{\frac{1}{x} + \left(\frac{1}{x + 1} + \frac{\frac{1}{\sqrt{x}}}{\sqrt{x + 1}}\right)}\\ \end{array}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\begin{array}{l}
\mathbf{if}\;x \leq 5.641413807697915 \cdot 10^{+96}:\\
\;\;\;\;{x}^{-0.5} - \frac{\frac{1}{\left|\sqrt[3]{x + 1}\right|}}{\sqrt{\sqrt[3]{x + 1}}}\\

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

\end{array}
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x)
 :precision binary64
 (if (<= x 5.641413807697915e+96)
   (- (pow x -0.5) (/ (/ 1.0 (fabs (cbrt (+ x 1.0)))) (sqrt (cbrt (+ x 1.0)))))
   (/
    (+ (/ 1.0 (pow x 1.5)) (/ -1.0 (pow (sqrt (+ x 1.0)) 3.0)))
    (+
     (/ 1.0 x)
     (+ (/ 1.0 (+ x 1.0)) (/ (/ 1.0 (sqrt x)) (sqrt (+ x 1.0))))))))
double code(double x) {
	return (1.0 / sqrt(x)) - (1.0 / sqrt(x + 1.0));
}
double code(double x) {
	double tmp;
	if (x <= 5.641413807697915e+96) {
		tmp = pow(x, -0.5) - ((1.0 / fabs(cbrt(x + 1.0))) / sqrt(cbrt(x + 1.0)));
	} else {
		tmp = ((1.0 / pow(x, 1.5)) + (-1.0 / pow(sqrt(x + 1.0), 3.0))) / ((1.0 / x) + ((1.0 / (x + 1.0)) + ((1.0 / sqrt(x)) / sqrt(x + 1.0))));
	}
	return tmp;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.9
Target0.6
Herbie19.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 < 5.64141380769791462e96

    1. Initial program 14.2

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
    2. Using strategy rm
    3. Applied pow1/2_binary6414.2

      \[\leadsto \frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}\]
    4. Applied pow-flip_binary6414.0

      \[\leadsto \color{blue}{{x}^{\left(-0.5\right)}} - \frac{1}{\sqrt{x + 1}}\]
    5. Simplified14.0

      \[\leadsto {x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt_binary6413.9

      \[\leadsto {x}^{-0.5} - \frac{1}{\sqrt{\color{blue}{\left(\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}\right) \cdot \sqrt[3]{x + 1}}}}\]
    8. Applied sqrt-prod_binary6413.9

      \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}} \cdot \sqrt{\sqrt[3]{x + 1}}}}\]
    9. Applied associate-/r*_binary6413.9

      \[\leadsto {x}^{-0.5} - \color{blue}{\frac{\frac{1}{\sqrt{\sqrt[3]{x + 1} \cdot \sqrt[3]{x + 1}}}}{\sqrt{\sqrt[3]{x + 1}}}}\]
    10. Simplified13.9

      \[\leadsto {x}^{-0.5} - \frac{\color{blue}{\frac{1}{\left|\sqrt[3]{x + 1}\right|}}}{\sqrt{\sqrt[3]{x + 1}}}\]

    if 5.64141380769791462e96 < x

    1. Initial program 31.3

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{\sqrt{x}}}}{\sqrt{\sqrt{x}}}} - \frac{1}{\sqrt{x + 1}}\]
    5. Using strategy rm
    6. Applied flip3--_binary6431.7

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5.641413807697915 \cdot 10^{+96}:\\ \;\;\;\;{x}^{-0.5} - \frac{\frac{1}{\left|\sqrt[3]{x + 1}\right|}}{\sqrt{\sqrt[3]{x + 1}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{{x}^{1.5}} + \frac{-1}{{\left(\sqrt{x + 1}\right)}^{3}}}{\frac{1}{x} + \left(\frac{1}{x + 1} + \frac{\frac{1}{\sqrt{x}}}{\sqrt{x + 1}}\right)}\\ \end{array}\]

Reproduce

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