2isqrt (example 3.6)

?

Percentage Accurate: 69.3% → 99.7%
Time: 13.3s
Precision: binary64
Cost: 39684

?

\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
\[\begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 5 \cdot 10^{-10}:\\ \;\;\;\;\left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \frac{0.375}{x \cdot x}\right)\right) \cdot {x}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} \cdot \mathsf{fma}\left(\sqrt{x}, -{\left(1 + x\right)}^{-0.5}, 1\right)\\ \end{array} \]
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x)
 :precision binary64
 (if (<= (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ 1.0 x)))) 5e-10)
   (* (+ (/ 0.5 x) (- (/ 0.3125 (pow x 3.0)) (/ 0.375 (* x x)))) (pow x -0.5))
   (* (pow x -0.5) (fma (sqrt x) (- (pow (+ 1.0 x) -0.5)) 1.0))))
double code(double x) {
	return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
double code(double x) {
	double tmp;
	if (((1.0 / sqrt(x)) - (1.0 / sqrt((1.0 + x)))) <= 5e-10) {
		tmp = ((0.5 / x) + ((0.3125 / pow(x, 3.0)) - (0.375 / (x * x)))) * pow(x, -0.5);
	} else {
		tmp = pow(x, -0.5) * fma(sqrt(x), -pow((1.0 + x), -0.5), 1.0);
	}
	return tmp;
}
function code(x)
	return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0))))
end
function code(x)
	tmp = 0.0
	if (Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(1.0 + x)))) <= 5e-10)
		tmp = Float64(Float64(Float64(0.5 / x) + Float64(Float64(0.3125 / (x ^ 3.0)) - Float64(0.375 / Float64(x * x)))) * (x ^ -0.5));
	else
		tmp = Float64((x ^ -0.5) * fma(sqrt(x), Float64(-(Float64(1.0 + x) ^ -0.5)), 1.0));
	end
	return tmp
end
code[x_] := N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e-10], N[(N[(N[(0.5 / x), $MachinePrecision] + N[(N[(0.3125 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(N[Sqrt[x], $MachinePrecision] * (-N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]) + 1.0), $MachinePrecision]), $MachinePrecision]]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 5 \cdot 10^{-10}:\\
\;\;\;\;\left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \frac{0.375}{x \cdot x}\right)\right) \cdot {x}^{-0.5}\\

\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \mathsf{fma}\left(\sqrt{x}, -{\left(1 + x\right)}^{-0.5}, 1\right)\\


\end{array}

Local Percentage Accuracy?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Herbie found 12 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each of Herbie's proposed alternatives. Up and to the right is better. Each dot represents an alternative program; the red square represents the initial program.

Bogosity?

Bogosity

Target

Original69.3%
Target99.1%
Herbie99.7%
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}} \]

Derivation?

  1. Split input into 2 regimes
  2. if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 5.00000000000000031e-10

    1. Initial program 37.8%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Applied egg-rr37.8%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{-0.5}}{\sqrt{1 + x}}} \]
      Step-by-step derivation

      [Start]37.8

      \[ \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]

      frac-sub [=>]37.8

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

      div-inv [=>]37.8

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

      *-un-lft-identity [<=]37.8

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

      +-commutative [=>]37.8

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

      *-rgt-identity [=>]37.8

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

      metadata-eval [<=]37.8

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

      frac-times [<=]37.8

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

      un-div-inv [=>]37.8

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

      pow1/2 [=>]37.8

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

      pow-flip [=>]37.8

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

      metadata-eval [=>]37.8

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

      +-commutative [=>]37.8

      \[ \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{-0.5}}{\sqrt{\color{blue}{1 + x}}} \]
    3. Simplified37.8%

      \[\leadsto \color{blue}{\left(1 - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot {x}^{-0.5}} \]
      Step-by-step derivation

      [Start]37.8

      \[ \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{-0.5}}{\sqrt{1 + x}} \]

      associate-*r/ [=>]37.8

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

      *-rgt-identity [<=]37.8

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

      times-frac [=>]37.8

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

      div-sub [=>]37.8

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

      *-inverses [=>]37.8

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

      /-rgt-identity [=>]37.8

      \[ \left(1 - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot \color{blue}{{x}^{-0.5}} \]
    4. Taylor expanded in x around inf 99.6%

      \[\leadsto \color{blue}{\left(\left(0.5 \cdot \frac{1}{x} + 0.3125 \cdot \frac{1}{{x}^{3}}\right) - 0.375 \cdot \frac{1}{{x}^{2}}\right)} \cdot {x}^{-0.5} \]
    5. Simplified99.6%

      \[\leadsto \color{blue}{\left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \frac{0.375}{x \cdot x}\right)\right)} \cdot {x}^{-0.5} \]
      Step-by-step derivation

      [Start]99.6

      \[ \left(\left(0.5 \cdot \frac{1}{x} + 0.3125 \cdot \frac{1}{{x}^{3}}\right) - 0.375 \cdot \frac{1}{{x}^{2}}\right) \cdot {x}^{-0.5} \]

      associate--l+ [=>]99.6

      \[ \color{blue}{\left(0.5 \cdot \frac{1}{x} + \left(0.3125 \cdot \frac{1}{{x}^{3}} - 0.375 \cdot \frac{1}{{x}^{2}}\right)\right)} \cdot {x}^{-0.5} \]

      associate-*r/ [=>]99.6

      \[ \left(\color{blue}{\frac{0.5 \cdot 1}{x}} + \left(0.3125 \cdot \frac{1}{{x}^{3}} - 0.375 \cdot \frac{1}{{x}^{2}}\right)\right) \cdot {x}^{-0.5} \]

      metadata-eval [=>]99.6

      \[ \left(\frac{\color{blue}{0.5}}{x} + \left(0.3125 \cdot \frac{1}{{x}^{3}} - 0.375 \cdot \frac{1}{{x}^{2}}\right)\right) \cdot {x}^{-0.5} \]

      associate-*r/ [=>]99.6

      \[ \left(\frac{0.5}{x} + \left(\color{blue}{\frac{0.3125 \cdot 1}{{x}^{3}}} - 0.375 \cdot \frac{1}{{x}^{2}}\right)\right) \cdot {x}^{-0.5} \]

      metadata-eval [=>]99.6

      \[ \left(\frac{0.5}{x} + \left(\frac{\color{blue}{0.3125}}{{x}^{3}} - 0.375 \cdot \frac{1}{{x}^{2}}\right)\right) \cdot {x}^{-0.5} \]

      associate-*r/ [=>]99.6

      \[ \left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \color{blue}{\frac{0.375 \cdot 1}{{x}^{2}}}\right)\right) \cdot {x}^{-0.5} \]

      metadata-eval [=>]99.6

      \[ \left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \frac{\color{blue}{0.375}}{{x}^{2}}\right)\right) \cdot {x}^{-0.5} \]

      unpow2 [=>]99.6

      \[ \left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \frac{0.375}{\color{blue}{x \cdot x}}\right)\right) \cdot {x}^{-0.5} \]

    if 5.00000000000000031e-10 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1))))

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{-0.5}}{\sqrt{1 + x}}} \]
      Step-by-step derivation

      [Start]99.6

      \[ \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]

      frac-sub [=>]99.6

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

      div-inv [=>]99.5

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

      *-un-lft-identity [<=]99.5

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

      +-commutative [=>]99.5

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

      *-rgt-identity [=>]99.5

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

      metadata-eval [<=]99.5

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

      frac-times [<=]99.5

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

      un-div-inv [=>]99.5

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

      pow1/2 [=>]99.5

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

      pow-flip [=>]99.9

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

      metadata-eval [=>]99.9

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

      +-commutative [=>]99.9

      \[ \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{-0.5}}{\sqrt{\color{blue}{1 + x}}} \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{\left(1 - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot {x}^{-0.5}} \]
      Step-by-step derivation

      [Start]99.9

      \[ \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{-0.5}}{\sqrt{1 + x}} \]

      associate-*r/ [=>]99.9

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

      *-rgt-identity [<=]99.9

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

      times-frac [=>]99.9

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

      div-sub [=>]99.9

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

      *-inverses [=>]99.9

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

      /-rgt-identity [=>]99.9

      \[ \left(1 - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot \color{blue}{{x}^{-0.5}} \]
    4. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{x}, -{\left(1 + x\right)}^{-0.5}, 1\right)} \cdot {x}^{-0.5} \]
      Step-by-step derivation

      [Start]99.9

      \[ \left(1 - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot {x}^{-0.5} \]

      sub-neg [=>]99.9

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

      +-commutative [=>]99.9

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

      div-inv [=>]99.9

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

      distribute-rgt-neg-in [=>]99.9

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

      fma-def [=>]99.9

      \[ \color{blue}{\mathsf{fma}\left(\sqrt{x}, -\frac{1}{\sqrt{1 + x}}, 1\right)} \cdot {x}^{-0.5} \]

      pow1/2 [=>]99.9

      \[ \mathsf{fma}\left(\sqrt{x}, -\frac{1}{\color{blue}{{\left(1 + x\right)}^{0.5}}}, 1\right) \cdot {x}^{-0.5} \]

      pow-flip [=>]99.9

      \[ \mathsf{fma}\left(\sqrt{x}, -\color{blue}{{\left(1 + x\right)}^{\left(-0.5\right)}}, 1\right) \cdot {x}^{-0.5} \]

      metadata-eval [=>]99.9

      \[ \mathsf{fma}\left(\sqrt{x}, -{\left(1 + x\right)}^{\color{blue}{-0.5}}, 1\right) \cdot {x}^{-0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.8%

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

Alternatives

Alternative 1
Accuracy99.7%
Cost33092
\[\begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 5 \cdot 10^{-10}:\\ \;\;\;\;\left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \frac{0.375}{x \cdot x}\right)\right) \cdot {x}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} - \sqrt[3]{{\left(1 + x\right)}^{-1.5}}\\ \end{array} \]
Alternative 2
Accuracy99.7%
Cost33028
\[\begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 5 \cdot 10^{-10}:\\ \;\;\;\;\left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \frac{0.375}{x \cdot x}\right)\right) \cdot {x}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} - e^{-0.5 \cdot \mathsf{log1p}\left(x\right)}\\ \end{array} \]
Alternative 3
Accuracy99.7%
Cost27332
\[\begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 5 \cdot 10^{-10}:\\ \;\;\;\;\left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \frac{0.375}{x \cdot x}\right)\right) \cdot {x}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\ \end{array} \]
Alternative 4
Accuracy99.6%
Cost26692
\[\begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 5 \cdot 10^{-10}:\\ \;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} - \frac{0.375}{x \cdot x}\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\ \end{array} \]
Alternative 5
Accuracy98.9%
Cost7300
\[\begin{array}{l} \mathbf{if}\;x \leq 1.1:\\ \;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} - \frac{0.375}{x \cdot x}\right)\\ \end{array} \]
Alternative 6
Accuracy98.9%
Cost7236
\[\begin{array}{l} \mathbf{if}\;x \leq 1.1:\\ \;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} \cdot \frac{\left(--0.5\right) - \frac{0.375}{x}}{x}\\ \end{array} \]
Alternative 7
Accuracy98.3%
Cost7044
\[\begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{x} \cdot {x}^{-0.5}\\ \end{array} \]
Alternative 8
Accuracy98.1%
Cost6916
\[\begin{array}{l} \mathbf{if}\;x \leq 0.68:\\ \;\;\;\;{x}^{-0.5} + -1\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{x} \cdot {x}^{-0.5}\\ \end{array} \]
Alternative 9
Accuracy51.3%
Cost6528
\[{x}^{-0.5} \]
Alternative 10
Accuracy3.9%
Cost192
\[x \cdot 0.5 \]
Alternative 11
Accuracy1.9%
Cost64
\[-1 \]

Reproduce?

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