?

Average Accuracy: 68.8% → 99.8%
Time: 13.0s
Precision: binary64
Cost: 27588

?

\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
\[\begin{array}{l} t_0 := \sqrt{1 + x}\\ \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 5 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{1}{t_0 + \sqrt{x}}}{\left(x + \left(0.5 + \frac{0.0625}{x \cdot x}\right)\right) - \frac{0.125}{x}}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} \cdot \left(1 - \sqrt{\frac{x}{1 + x}}\right)\\ \end{array} \]
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sqrt (+ 1.0 x))))
   (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 5e-7)
     (/
      (/ 1.0 (+ t_0 (sqrt x)))
      (- (+ x (+ 0.5 (/ 0.0625 (* x x)))) (/ 0.125 x)))
     (* (pow x -0.5) (- 1.0 (sqrt (/ x (+ 1.0 x))))))))
double code(double x) {
	return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
double code(double x) {
	double t_0 = sqrt((1.0 + x));
	double tmp;
	if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 5e-7) {
		tmp = (1.0 / (t_0 + sqrt(x))) / ((x + (0.5 + (0.0625 / (x * x)))) - (0.125 / x));
	} else {
		tmp = pow(x, -0.5) * (1.0 - sqrt((x / (1.0 + x))));
	}
	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 = sqrt((1.0d0 + x))
    if (((1.0d0 / sqrt(x)) + ((-1.0d0) / t_0)) <= 5d-7) then
        tmp = (1.0d0 / (t_0 + sqrt(x))) / ((x + (0.5d0 + (0.0625d0 / (x * x)))) - (0.125d0 / x))
    else
        tmp = (x ** (-0.5d0)) * (1.0d0 - sqrt((x / (1.0d0 + x))))
    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.sqrt((1.0 + x));
	double tmp;
	if (((1.0 / Math.sqrt(x)) + (-1.0 / t_0)) <= 5e-7) {
		tmp = (1.0 / (t_0 + Math.sqrt(x))) / ((x + (0.5 + (0.0625 / (x * x)))) - (0.125 / x));
	} else {
		tmp = Math.pow(x, -0.5) * (1.0 - Math.sqrt((x / (1.0 + x))));
	}
	return tmp;
}
def code(x):
	return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
def code(x):
	t_0 = math.sqrt((1.0 + x))
	tmp = 0
	if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 5e-7:
		tmp = (1.0 / (t_0 + math.sqrt(x))) / ((x + (0.5 + (0.0625 / (x * x)))) - (0.125 / x))
	else:
		tmp = math.pow(x, -0.5) * (1.0 - math.sqrt((x / (1.0 + x))))
	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 = sqrt(Float64(1.0 + x))
	tmp = 0.0
	if (Float64(Float64(1.0 / sqrt(x)) + Float64(-1.0 / t_0)) <= 5e-7)
		tmp = Float64(Float64(1.0 / Float64(t_0 + sqrt(x))) / Float64(Float64(x + Float64(0.5 + Float64(0.0625 / Float64(x * x)))) - Float64(0.125 / x)));
	else
		tmp = Float64((x ^ -0.5) * Float64(1.0 - sqrt(Float64(x / Float64(1.0 + x)))));
	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 = sqrt((1.0 + x));
	tmp = 0.0;
	if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 5e-7)
		tmp = (1.0 / (t_0 + sqrt(x))) / ((x + (0.5 + (0.0625 / (x * x)))) - (0.125 / x));
	else
		tmp = (x ^ -0.5) * (1.0 - sqrt((x / (1.0 + x))));
	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[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(-1.0 / t$95$0), $MachinePrecision]), $MachinePrecision], 5e-7], N[(N[(1.0 / N[(t$95$0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[(x + N[(0.5 + N[(0.0625 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(1.0 - N[Sqrt[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{1}{t_0 + \sqrt{x}}}{\left(x + \left(0.5 + \frac{0.0625}{x \cdot x}\right)\right) - \frac{0.125}{x}}\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original68.8%
Target98.9%
Herbie99.8%
\[\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.99999999999999977e-7

    1. Initial program 35.7%

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

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

      [Start]35.7

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

      frac-sub [=>]35.7

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

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

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

      +-commutative [=>]35.7

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

      *-rgt-identity [=>]35.7

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

      sqrt-unprod [=>]35.7

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

      +-commutative [=>]35.7

      \[ \frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(1 + x\right)}}} \]
    3. Applied egg-rr82.7%

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

      [Start]35.7

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

      flip-- [=>]35.8

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

      div-inv [=>]35.8

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

      add-sqr-sqrt [<=]36.7

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

      add-sqr-sqrt [<=]36.3

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

      associate--l+ [=>]82.7

      \[ \frac{\color{blue}{\left(1 + \left(x - x\right)\right)} \cdot \frac{1}{\sqrt{1 + x} + \sqrt{x}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    4. Simplified82.7%

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

      [Start]82.7

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

      +-inverses [=>]82.7

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

      metadata-eval [=>]82.7

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

      *-lft-identity [=>]82.7

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

      \[\leadsto \frac{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}{\color{blue}{\left(0.5 + \left(0.0625 \cdot \frac{1}{{x}^{2}} + x\right)\right) - 0.125 \cdot \frac{1}{x}}} \]
    6. Simplified99.6%

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

      [Start]99.6

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

      associate-+r+ [=>]99.6

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

      unpow2 [=>]99.6

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

      associate-*r/ [=>]99.6

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

      metadata-eval [=>]99.6

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

      associate-*r/ [=>]99.6

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

      metadata-eval [=>]99.6

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

    if 4.99999999999999977e-7 < (-.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.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.4

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

      frac-sub [=>]99.5

      \[ \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.5%

      \[\leadsto \color{blue}{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot \frac{-1}{\sqrt{x}}} \]
      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.8

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

      remove-double-neg [<=]99.8

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

      neg-mul-1 [=>]99.8

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

      *-commutative [=>]99.8

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

      times-frac [=>]99.8

      \[ \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{-\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{-1}} \]
    4. Applied egg-rr99.8%

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

      [Start]99.5

      \[ \left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot \frac{-1}{\sqrt{x}} \]

      *-commutative [=>]99.5

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

      sub-neg [=>]99.5

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

      neg-mul-1 [=>]99.5

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

      distribute-lft-in [=>]99.4

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

      div-inv [=>]99.4

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

      mul-1-neg [=>]99.4

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

      pow1/2 [=>]99.4

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

      pow-flip [=>]99.8

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

      metadata-eval [=>]99.8

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

      div-inv [=>]99.8

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

      mul-1-neg [=>]99.8

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

      pow1/2 [=>]99.8

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

      pow-flip [=>]99.8

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

      metadata-eval [=>]99.8

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

      associate-*r/ [=>]99.8

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

      neg-mul-1 [<=]99.8

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

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

      [Start]99.8

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

      distribute-lft-out [=>]99.8

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

      neg-mul-1 [=>]99.8

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

      *-commutative [=>]99.8

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

      associate-*l* [=>]99.8

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

      neg-mul-1 [<=]99.8

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

      distribute-neg-in [=>]99.8

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

      metadata-eval [=>]99.8

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

      unsub-neg [=>]99.8

      \[ {x}^{-0.5} \cdot \color{blue}{\left(1 - \sqrt{\frac{x}{x + 1}}\right)} \]
  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^{-7}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}{\left(x + \left(0.5 + \frac{0.0625}{x \cdot x}\right)\right) - \frac{0.125}{x}}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} \cdot \left(1 - \sqrt{\frac{x}{1 + x}}\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy99.5%
Cost52224
\[\begin{array}{l} t_0 := {\left(\sqrt{1 + x} + \sqrt{x}\right)}^{-0.5}\\ t_0 \cdot \frac{t_0}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \end{array} \]
Alternative 2
Accuracy99.3%
Cost26756
\[\begin{array}{l} t_0 := \frac{-1}{\sqrt{1 + x}}\\ \mathbf{if}\;\frac{1}{\sqrt{x}} + t_0 \leq 5 \cdot 10^{-19}:\\ \;\;\;\;\frac{\frac{0.5}{x} - \frac{0.375}{x \cdot x}}{\sqrt{x}}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} + t_0\\ \end{array} \]
Alternative 3
Accuracy98.9%
Cost26240
\[\frac{1}{\left(\sqrt{1 + x} + \sqrt{x}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)} \]
Alternative 4
Accuracy99.8%
Cost13892
\[\begin{array}{l} \mathbf{if}\;x \leq 7300:\\ \;\;\;\;{x}^{-0.5} \cdot \left(1 - \sqrt{\frac{x}{1 + x}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}{\left(x + 0.5\right) + \frac{-0.125}{x}}\\ \end{array} \]
Alternative 5
Accuracy99.7%
Cost13572
\[\begin{array}{l} \mathbf{if}\;x \leq 470000:\\ \;\;\;\;{x}^{-0.5} \cdot \left(1 - \sqrt{\frac{x}{1 + x}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0.5}{x} - \frac{0.375}{x \cdot x}}{\sqrt{x}}\\ \end{array} \]
Alternative 6
Accuracy99.7%
Cost13380
\[\begin{array}{l} \mathbf{if}\;x \leq 205000:\\ \;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0.5}{x} - \frac{0.375}{x \cdot x}}{\sqrt{x}}\\ \end{array} \]
Alternative 7
Accuracy98.9%
Cost7236
\[\begin{array}{l} \mathbf{if}\;x \leq 1.1:\\ \;\;\;\;{x}^{-0.5} - \left(1 + x \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0.5}{x} - \frac{0.375}{x \cdot x}}{\sqrt{x}}\\ \end{array} \]
Alternative 8
Accuracy98.5%
Cost7044
\[\begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;{x}^{-0.5} - \left(1 + x \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{x}}\\ \end{array} \]
Alternative 9
Accuracy98.2%
Cost6852
\[\begin{array}{l} \mathbf{if}\;x \leq 0.68:\\ \;\;\;\;{x}^{-0.5} + -1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{x}}\\ \end{array} \]
Alternative 10
Accuracy52.8%
Cost6788
\[\begin{array}{l} \mathbf{if}\;x \leq 0.16:\\ \;\;\;\;{x}^{-0.5} + -1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x + 0.5}\\ \end{array} \]
Alternative 11
Accuracy50.3%
Cost6528
\[{x}^{-0.5} \]
Alternative 12
Accuracy7.4%
Cost320
\[\frac{1}{x + 0.5} \]
Alternative 13
Accuracy7.4%
Cost192
\[\frac{1}{x} \]
Alternative 14
Accuracy1.9%
Cost64
\[-1 \]

Error

Reproduce?

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