Average Error: 20.4 → 20.3
Time: 3.3min
Precision: binary64
Cost: 13633
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\begin{array}{l} \mathbf{if}\;x \leq 2.3678566194252168 \cdot 10^{+91}:\\ \;\;\;\;{x}^{-0.5} - \frac{1}{\sqrt{x + 1}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\begin{array}{l}
\mathbf{if}\;x \leq 2.3678566194252168 \cdot 10^{+91}:\\
\;\;\;\;{x}^{-0.5} - \frac{1}{\sqrt{x + 1}}\\

\mathbf{else}:\\
\;\;\;\;0\\

\end{array}
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x)
 :precision binary64
 (if (<= x 2.3678566194252168e+91)
   (- (pow x -0.5) (/ 1.0 (sqrt (+ x 1.0))))
   0.0))
double code(double x) {
	return (1.0 / sqrt(x)) - (1.0 / sqrt(x + 1.0));
}
double code(double x) {
	double tmp;
	if (x <= 2.3678566194252168e+91) {
		tmp = pow(x, -0.5) - (1.0 / sqrt(x + 1.0));
	} else {
		tmp = 0.0;
	}
	return tmp;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.4
Target0.7
Herbie20.3
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Alternatives

Alternative 1
Error20.4
Cost13376
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
Alternative 2
Error20.4
Cost13633
\[\begin{array}{l} \mathbf{if}\;x \leq 9.117725950103936 \cdot 10^{+57}:\\ \;\;\;\;\frac{1}{\sqrt{x}} - {\left(x + 1\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 3
Error21.0
Cost7681
\[\begin{array}{l} \mathbf{if}\;x \leq 8.423173255108411 \cdot 10^{+122}:\\ \;\;\;\;\frac{1}{\sqrt{x}} - \frac{1}{1 + x \cdot \left(0.5 + x \cdot -0.125\right)}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 4
Error21.1
Cost7425
\[\begin{array}{l} \mathbf{if}\;x \leq 8.423173255108411 \cdot 10^{+122}:\\ \;\;\;\;\frac{1}{\sqrt{x}} - \frac{1}{1 + x \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 5
Error21.3
Cost7297
\[\begin{array}{l} \mathbf{if}\;x \leq 8.059265398421139 \cdot 10^{+76}:\\ \;\;\;\;\frac{1}{\sqrt{x}} - \left(1 - x \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 6
Error21.6
Cost6977
\[\begin{array}{l} \mathbf{if}\;x \leq 0.9934451274417744:\\ \;\;\;\;{x}^{-0.5} - 1\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 7
Error50.2
Cost385
\[\begin{array}{l} \mathbf{if}\;x \leq 2.6904587650047774 \cdot 10^{+102}:\\ \;\;\;\;1\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 8
Error60.3
Cost64
\[1\]

Error

Time

Derivation

  1. Split input into 2 regimes
  2. if x < 2.36785661942521678e91

    1. Initial program 13.5

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

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

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

      \[\leadsto {x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\]
    6. Simplified13.2

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

    if 2.36785661942521678e91 < x

    1. Initial program 33.2

      \[0\]
    2. Simplified33.2

      \[\leadsto \color{blue}{0}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification20.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.3678566194252168 \cdot 10^{+91}:\\ \;\;\;\;{x}^{-0.5} - \frac{1}{\sqrt{x + 1}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Reproduce

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