?

Average Accuracy: 68.6% → 99.7%
Time: 13.1s
Precision: binary64
Cost: 28484

?

\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
\[\begin{array}{l} t_0 := {\left(\frac{-1}{\frac{-1}{x}}\right)}^{-0.5}\\ \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 5 \cdot 10^{-8}:\\ \;\;\;\;\frac{t_0}{x} \cdot \left(0.5 + \frac{-0.375}{x}\right) + \frac{t_0}{x \cdot x} \cdot \left(\frac{0.3125}{x} + \frac{-0.2734375}{x \cdot x}\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\ \end{array} \]
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (pow (/ -1.0 (/ -1.0 x)) -0.5)))
   (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 (sqrt (+ 1.0 x)))) 5e-8)
     (+
      (* (/ t_0 x) (+ 0.5 (/ -0.375 x)))
      (* (/ t_0 (* x x)) (+ (/ 0.3125 x) (/ -0.2734375 (* x x)))))
     (- (pow x -0.5) (pow (+ 1.0 x) -0.5)))))
double code(double x) {
	return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
double code(double x) {
	double t_0 = pow((-1.0 / (-1.0 / x)), -0.5);
	double tmp;
	if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 5e-8) {
		tmp = ((t_0 / x) * (0.5 + (-0.375 / x))) + ((t_0 / (x * x)) * ((0.3125 / x) + (-0.2734375 / (x * x))));
	} else {
		tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((-1.0d0) / ((-1.0d0) / x)) ** (-0.5d0)
    if (((1.0d0 / sqrt(x)) + ((-1.0d0) / sqrt((1.0d0 + x)))) <= 5d-8) then
        tmp = ((t_0 / x) * (0.5d0 + ((-0.375d0) / x))) + ((t_0 / (x * x)) * ((0.3125d0 / x) + ((-0.2734375d0) / (x * x))))
    else
        tmp = (x ** (-0.5d0)) - ((1.0d0 + x) ** (-0.5d0))
    end if
    code = tmp
end function
public static double code(double x) {
	return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
public static double code(double x) {
	double t_0 = Math.pow((-1.0 / (-1.0 / x)), -0.5);
	double tmp;
	if (((1.0 / Math.sqrt(x)) + (-1.0 / Math.sqrt((1.0 + x)))) <= 5e-8) {
		tmp = ((t_0 / x) * (0.5 + (-0.375 / x))) + ((t_0 / (x * x)) * ((0.3125 / x) + (-0.2734375 / (x * x))));
	} else {
		tmp = Math.pow(x, -0.5) - Math.pow((1.0 + x), -0.5);
	}
	return tmp;
}
def code(x):
	return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
def code(x):
	t_0 = math.pow((-1.0 / (-1.0 / x)), -0.5)
	tmp = 0
	if ((1.0 / math.sqrt(x)) + (-1.0 / math.sqrt((1.0 + x)))) <= 5e-8:
		tmp = ((t_0 / x) * (0.5 + (-0.375 / x))) + ((t_0 / (x * x)) * ((0.3125 / x) + (-0.2734375 / (x * x))))
	else:
		tmp = math.pow(x, -0.5) - math.pow((1.0 + x), -0.5)
	return tmp
function code(x)
	return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0))))
end
function code(x)
	t_0 = Float64(-1.0 / Float64(-1.0 / x)) ^ -0.5
	tmp = 0.0
	if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / sqrt(Float64(1.0 + x)))) <= 5e-8)
		tmp = Float64(Float64(Float64(t_0 / x) * Float64(0.5 + Float64(-0.375 / x))) + Float64(Float64(t_0 / Float64(x * x)) * Float64(Float64(0.3125 / x) + Float64(-0.2734375 / Float64(x * x)))));
	else
		tmp = Float64((x ^ -0.5) - (Float64(1.0 + x) ^ -0.5));
	end
	return tmp
end
function tmp = code(x)
	tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
end
function tmp_2 = code(x)
	t_0 = (-1.0 / (-1.0 / x)) ^ -0.5;
	tmp = 0.0;
	if (((1.0 / sqrt(x)) + (-1.0 / sqrt((1.0 + x)))) <= 5e-8)
		tmp = ((t_0 / x) * (0.5 + (-0.375 / x))) + ((t_0 / (x * x)) * ((0.3125 / x) + (-0.2734375 / (x * x))));
	else
		tmp = (x ^ -0.5) - ((1.0 + x) ^ -0.5);
	end
	tmp_2 = 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_] := Block[{t$95$0 = N[Power[N[(-1.0 / N[(-1.0 / x), $MachinePrecision]), $MachinePrecision], -0.5], $MachinePrecision]}, 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-8], N[(N[(N[(t$95$0 / x), $MachinePrecision] * N[(0.5 + N[(-0.375 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(t$95$0 / N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(N[(0.3125 / x), $MachinePrecision] + N[(-0.2734375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\begin{array}{l}
t_0 := {\left(\frac{-1}{\frac{-1}{x}}\right)}^{-0.5}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 5 \cdot 10^{-8}:\\
\;\;\;\;\frac{t_0}{x} \cdot \left(0.5 + \frac{-0.375}{x}\right) + \frac{t_0}{x \cdot x} \cdot \left(\frac{0.3125}{x} + \frac{-0.2734375}{x \cdot x}\right)\\

\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original68.6%
Target98.9%
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)))) < 4.9999999999999998e-8

    1. Initial program 37.9%

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

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

      [Start]37.9

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

      inv-pow [=>]37.9

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

      pow1/2 [=>]37.9

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

      pow-pow [=>]29.3

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

      add-exp-log [=>]6.2

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

      pow-exp [=>]6.1

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

      metadata-eval [=>]6.1

      \[ e^{\log x \cdot \color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}} \]
    3. Applied egg-rr37.9%

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

      [Start]6.1

      \[ e^{\log x \cdot -0.5} - \frac{1}{\sqrt{x + 1}} \]

      add-sqr-sqrt [=>]6.2

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

      clear-num [=>]6.2

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

      associate-/r/ [=>]6.2

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

      prod-diff [=>]6.1

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

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

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

      fma-neg [<=]6.2

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

      add-sqr-sqrt [<=]6.1

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

      exp-to-pow [=>]29.3

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

      pow1/2 [=>]29.3

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

      pow-flip [=>]37.9

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

      metadata-eval [=>]37.9

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

      \[\leadsto \color{blue}{{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}} \]
      Proof

      [Start]37.9

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

      fma-udef [=>]37.9

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

      neg-mul-1 [<=]37.9

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

      rem-log-exp [<=]6.0

      \[ \left({x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\right) + \left(\color{blue}{\log \left(e^{-{\left(x + 1\right)}^{-0.5}}\right)} + {\left(x + 1\right)}^{-0.5}\right) \]

      rec-exp [<=]6.0

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

      +-commutative [=>]6.0

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

      rec-exp [=>]6.0

      \[ \left({x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\right) + \left({\left(x + 1\right)}^{-0.5} + \log \color{blue}{\left(e^{-{\left(x + 1\right)}^{-0.5}}\right)}\right) \]

      rem-log-exp [=>]37.9

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

      sub-neg [<=]37.9

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

      +-inverses [=>]37.9

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

      +-rgt-identity [=>]37.9

      \[ \color{blue}{{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}} \]
    5. Taylor expanded in x around -inf 0.0%

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

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

      [Start]0.0

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

      +-commutative [=>]0.0

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

      +-commutative [=>]0.0

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

      associate-+l+ [=>]0.0

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

    if 4.9999999999999998e-8 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1))))

    1. Initial program 99.4%

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

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

      [Start]99.4

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

      *-un-lft-identity [=>]99.4

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

      clear-num [=>]99.4

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

      associate-/r/ [=>]99.4

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

      prod-diff [=>]99.4

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

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

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

      fma-neg [<=]99.4

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

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

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

      inv-pow [=>]99.4

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

      sqrt-pow2 [=>]99.8

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

      metadata-eval [=>]99.8

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

      pow1/2 [=>]99.8

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

      pow-flip [=>]99.8

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

      +-commutative [=>]99.8

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

      metadata-eval [=>]99.8

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

      \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
      Proof

      [Start]99.8

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

      fma-udef [=>]99.8

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

      distribute-lft1-in [=>]99.8

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

      metadata-eval [=>]99.8

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

      mul0-lft [=>]99.8

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

      +-rgt-identity [=>]99.8

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

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

Alternatives

Alternative 1
Accuracy99.7%
Cost27332
\[\begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 5 \cdot 10^{-8}:\\ \;\;\;\;{x}^{-0.5} \cdot \left(\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \frac{0.375}{x \cdot x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\ \end{array} \]
Alternative 2
Accuracy99.6%
Cost27268
\[\begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 10^{-11}:\\ \;\;\;\;\frac{{\left(\frac{-1}{\frac{-1}{x}}\right)}^{-0.5}}{x} \cdot \left(0.5 + \frac{-0.375}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} \cdot \left(1 - \sqrt{\frac{x}{1 - x \cdot x} \cdot \left(1 - x\right)}\right)\\ \end{array} \]
Alternative 3
Accuracy99.6%
Cost26884
\[\begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 10^{-11}:\\ \;\;\;\;\frac{{\left(\frac{-1}{\frac{-1}{x}}\right)}^{-0.5}}{x} \cdot \left(0.5 + \frac{-0.375}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} \cdot \left(1 - \sqrt{\frac{x}{1 + x}}\right)\\ \end{array} \]
Alternative 4
Accuracy99.6%
Cost26692
\[\begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 10^{-11}:\\ \;\;\;\;\frac{{\left(\frac{-1}{\frac{-1}{x}}\right)}^{-0.5}}{x} \cdot \left(0.5 + \frac{-0.375}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\ \end{array} \]
Alternative 5
Accuracy98.9%
Cost7428
\[\begin{array}{l} \mathbf{if}\;x \leq 1.1:\\ \;\;\;\;-1 + \left({x}^{-0.5} + x \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\frac{-1}{\frac{-1}{x}}\right)}^{-0.5}}{x} \cdot \left(0.5 + \frac{-0.375}{x}\right)\\ \end{array} \]
Alternative 6
Accuracy98.9%
Cost7300
\[\begin{array}{l} \mathbf{if}\;x \leq 1.1:\\ \;\;\;\;-1 + \left({x}^{-0.5} + 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 7
Accuracy98.9%
Cost7172
\[\begin{array}{l} \mathbf{if}\;x \leq 1.1:\\ \;\;\;\;-1 + \left({x}^{-0.5} + x \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} \cdot \frac{0.5 - \frac{0.375}{x}}{x}\\ \end{array} \]
Alternative 8
Accuracy98.5%
Cost7044
\[\begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;-1 + \left({x}^{-0.5} + x \cdot 0.5\right)\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {x}^{-1.5}\\ \end{array} \]
Alternative 9
Accuracy97.1%
Cost6788
\[\begin{array}{l} \mathbf{if}\;x \leq 0.5:\\ \;\;\;\;{x}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {x}^{-1.5}\\ \end{array} \]
Alternative 10
Accuracy98.3%
Cost6788
\[\begin{array}{l} \mathbf{if}\;x \leq 0.66:\\ \;\;\;\;-1 + {x}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot {x}^{-1.5}\\ \end{array} \]
Alternative 11
Accuracy50.2%
Cost6528
\[{x}^{-0.5} \]
Alternative 12
Accuracy2.4%
Cost320
\[-1 + x \cdot 0.5 \]
Alternative 13
Accuracy1.9%
Cost64
\[-1 \]

Error

Reproduce?

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