2isqrt (example 3.6)

Percentage Accurate: 69.4% → 99.8%
Time: 9.8s
Alternatives: 11
Speedup: 2.0×

Specification

?
\[\begin{array}{l} \\ \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \end{array} \]
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
	return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
public static double code(double x) {
	return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
def code(x):
	return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
function code(x)
	return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0))))
end
function tmp = code(x)
	tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
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]
\begin{array}{l}

\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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.

Accuracy vs Speed?

Herbie found 11 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 69.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \end{array} \]
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
double code(double x) {
	return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
public static double code(double x) {
	return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
def code(x):
	return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
function code(x)
	return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0))))
end
function tmp = code(x)
	tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
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]
\begin{array}{l}

\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\end{array}

Alternative 1: 99.8% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 10^{-6}:\\
\;\;\;\;\frac{\left(\frac{0.5}{x} + \frac{0.3125}{{x}^{3}}\right) - \left(\frac{0.375}{x \cdot x} + \frac{0.2734375}{{x}^{4}}\right)}{\sqrt{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 9.99999999999999955e-7

    1. Initial program 33.1%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. frac-sub33.1%

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. div-inv33.1%

        \[\leadsto \color{blue}{\left(1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      3. *-un-lft-identity33.1%

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

        \[\leadsto \left(\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      5. *-rgt-identity33.1%

        \[\leadsto \left(\sqrt{1 + x} - \color{blue}{\sqrt{x}}\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      6. metadata-eval33.1%

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

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      8. un-div-inv33.1%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\frac{\frac{1}{\sqrt{x}}}{\sqrt{x + 1}}} \]
      9. pow1/233.1%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{\frac{1}{\color{blue}{{x}^{0.5}}}}{\sqrt{x + 1}} \]
      10. pow-flip33.1%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{\color{blue}{{x}^{\left(-0.5\right)}}}{\sqrt{x + 1}} \]
      11. metadata-eval33.1%

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

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

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{-0.5}}{\sqrt{1 + x}}} \]
    4. Step-by-step derivation
      1. associate-*r/33.1%

        \[\leadsto \color{blue}{\frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\sqrt{1 + x}}} \]
      2. remove-double-neg33.1%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{-\left(-\sqrt{1 + x}\right)}} \]
      3. neg-mul-133.1%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{-1 \cdot \left(-\sqrt{1 + x}\right)}} \]
      4. *-commutative33.1%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{\left(-\sqrt{1 + x}\right) \cdot -1}} \]
      5. times-frac33.1%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{-\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{-1}} \]
    5. Simplified33.1%

      \[\leadsto \color{blue}{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot \frac{-1}{\sqrt{x}}} \]
    6. Step-by-step derivation
      1. associate-*r/33.1%

        \[\leadsto \color{blue}{\frac{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot -1}{\sqrt{x}}} \]
      2. clear-num33.1%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x}}{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot -1}}} \]
      3. *-commutative33.1%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{\color{blue}{-1 \cdot \left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right)}}} \]
      4. sub-neg33.1%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \color{blue}{\left(-1 + \left(-\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right)\right)}}} \]
      5. distribute-neg-frac33.1%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\frac{-\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      6. add-sqr-sqrt0.0%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{-\mathsf{hypot}\left(1, \sqrt{x}\right)} \cdot \sqrt{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      7. sqrt-unprod5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{\left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right) \cdot \left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right)}}}\right)}} \]
      8. sqr-neg5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\sqrt{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right) \cdot \mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      9. sqrt-prod5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{\mathsf{hypot}\left(1, \sqrt{x}\right)} \cdot \sqrt{\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      10. add-sqr-sqrt5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      11. remove-double-neg5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{-\left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right)}}\right)}} \]
      12. frac-2neg5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      13. add-sqr-sqrt0.0%

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r/33.3%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{x}} \cdot \left(-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)} \]
      2. associate-*l/33.3%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)}{\sqrt{x}}} \]
      3. neg-mul-133.3%

        \[\leadsto \frac{1 \cdot \color{blue}{\left(-\left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)}}{\sqrt{x}} \]
      4. distribute-rgt-neg-in33.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      5. *-lft-identity33.3%

        \[\leadsto \frac{-\color{blue}{\left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      6. distribute-neg-in33.3%

        \[\leadsto \frac{\color{blue}{\left(--1\right) + \left(-\sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      7. metadata-eval33.3%

        \[\leadsto \frac{\color{blue}{1} + \left(-\sqrt{\frac{x}{x + 1}}\right)}{\sqrt{x}} \]
      8. unsub-neg33.3%

        \[\leadsto \frac{\color{blue}{1 - \sqrt{\frac{x}{x + 1}}}}{\sqrt{x}} \]
    9. Simplified33.3%

      \[\leadsto \color{blue}{\frac{1 - \sqrt{\frac{x}{x + 1}}}{\sqrt{x}}} \]
    10. Taylor expanded in x around inf 99.6%

      \[\leadsto \frac{\color{blue}{\left(0.5 \cdot \frac{1}{x} + 0.3125 \cdot \frac{1}{{x}^{3}}\right) - \left(0.2734375 \cdot \frac{1}{{x}^{4}} + 0.375 \cdot \frac{1}{{x}^{2}}\right)}}{\sqrt{x}} \]
    11. Step-by-step derivation
      1. associate-*r/99.6%

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

        \[\leadsto \frac{\left(\frac{\color{blue}{0.5}}{x} + 0.3125 \cdot \frac{1}{{x}^{3}}\right) - \left(0.2734375 \cdot \frac{1}{{x}^{4}} + 0.375 \cdot \frac{1}{{x}^{2}}\right)}{\sqrt{x}} \]
      3. associate-*r/99.6%

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

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

        \[\leadsto \frac{\left(\frac{0.5}{x} + \frac{0.3125}{{x}^{3}}\right) - \color{blue}{\left(0.375 \cdot \frac{1}{{x}^{2}} + 0.2734375 \cdot \frac{1}{{x}^{4}}\right)}}{\sqrt{x}} \]
      6. associate-*r/99.6%

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

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

        \[\leadsto \frac{\left(\frac{0.5}{x} + \frac{0.3125}{{x}^{3}}\right) - \left(\frac{0.375}{\color{blue}{x \cdot x}} + 0.2734375 \cdot \frac{1}{{x}^{4}}\right)}{\sqrt{x}} \]
      9. associate-*r/99.6%

        \[\leadsto \frac{\left(\frac{0.5}{x} + \frac{0.3125}{{x}^{3}}\right) - \left(\frac{0.375}{x \cdot x} + \color{blue}{\frac{0.2734375 \cdot 1}{{x}^{4}}}\right)}{\sqrt{x}} \]
      10. metadata-eval99.6%

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

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

    if 9.99999999999999955e-7 < (-.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. Step-by-step derivation
      1. *-un-lft-identity99.6%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.6%

        \[\leadsto \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)} \]
      5. *-un-lft-identity99.6%

        \[\leadsto \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) \]
      6. fma-neg99.6%

        \[\leadsto \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) \]
      7. *-un-lft-identity99.6%

        \[\leadsto \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) \]
      8. inv-pow99.6%

        \[\leadsto \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) \]
      9. sqrt-pow2100.0%

        \[\leadsto \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) \]
      10. metadata-eval100.0%

        \[\leadsto \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) \]
      11. pow1/2100.0%

        \[\leadsto \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) \]
      12. pow-flip100.0%

        \[\leadsto \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) \]
      13. +-commutative100.0%

        \[\leadsto \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) \]
      14. metadata-eval100.0%

        \[\leadsto \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. Applied egg-rr100.0%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-udef100.0%

        \[\leadsto \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)} \]
      2. distribute-lft1-in100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}} \]
      3. metadata-eval100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} \]
      4. mul0-lft100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \]
      5. +-rgt-identity100.0%

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

      \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-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 10^{-6}:\\ \;\;\;\;\frac{\left(\frac{0.5}{x} + \frac{0.3125}{{x}^{3}}\right) - \left(\frac{0.375}{x \cdot x} + \frac{0.2734375}{{x}^{4}}\right)}{\sqrt{x}}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\ \end{array} \]

Alternative 2: 99.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 10^{-6}:\\
\;\;\;\;\frac{\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \frac{0.375}{x \cdot x}\right)}{\sqrt{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 9.99999999999999955e-7

    1. Initial program 33.1%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. frac-sub33.1%

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. div-inv33.1%

        \[\leadsto \color{blue}{\left(1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      3. *-un-lft-identity33.1%

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

        \[\leadsto \left(\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      5. *-rgt-identity33.1%

        \[\leadsto \left(\sqrt{1 + x} - \color{blue}{\sqrt{x}}\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      6. metadata-eval33.1%

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

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      8. un-div-inv33.1%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\frac{\frac{1}{\sqrt{x}}}{\sqrt{x + 1}}} \]
      9. pow1/233.1%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{\frac{1}{\color{blue}{{x}^{0.5}}}}{\sqrt{x + 1}} \]
      10. pow-flip33.1%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{\color{blue}{{x}^{\left(-0.5\right)}}}{\sqrt{x + 1}} \]
      11. metadata-eval33.1%

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

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

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{-0.5}}{\sqrt{1 + x}}} \]
    4. Step-by-step derivation
      1. associate-*r/33.1%

        \[\leadsto \color{blue}{\frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\sqrt{1 + x}}} \]
      2. remove-double-neg33.1%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{-\left(-\sqrt{1 + x}\right)}} \]
      3. neg-mul-133.1%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{-1 \cdot \left(-\sqrt{1 + x}\right)}} \]
      4. *-commutative33.1%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{\left(-\sqrt{1 + x}\right) \cdot -1}} \]
      5. times-frac33.1%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{-\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{-1}} \]
    5. Simplified33.1%

      \[\leadsto \color{blue}{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot \frac{-1}{\sqrt{x}}} \]
    6. Step-by-step derivation
      1. associate-*r/33.1%

        \[\leadsto \color{blue}{\frac{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot -1}{\sqrt{x}}} \]
      2. clear-num33.1%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x}}{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot -1}}} \]
      3. *-commutative33.1%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{\color{blue}{-1 \cdot \left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right)}}} \]
      4. sub-neg33.1%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \color{blue}{\left(-1 + \left(-\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right)\right)}}} \]
      5. distribute-neg-frac33.1%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\frac{-\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      6. add-sqr-sqrt0.0%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{-\mathsf{hypot}\left(1, \sqrt{x}\right)} \cdot \sqrt{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      7. sqrt-unprod5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{\left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right) \cdot \left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right)}}}\right)}} \]
      8. sqr-neg5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\sqrt{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right) \cdot \mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      9. sqrt-prod5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{\mathsf{hypot}\left(1, \sqrt{x}\right)} \cdot \sqrt{\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      10. add-sqr-sqrt5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      11. remove-double-neg5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{-\left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right)}}\right)}} \]
      12. frac-2neg5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      13. add-sqr-sqrt0.0%

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r/33.3%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{x}} \cdot \left(-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)} \]
      2. associate-*l/33.3%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)}{\sqrt{x}}} \]
      3. neg-mul-133.3%

        \[\leadsto \frac{1 \cdot \color{blue}{\left(-\left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)}}{\sqrt{x}} \]
      4. distribute-rgt-neg-in33.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      5. *-lft-identity33.3%

        \[\leadsto \frac{-\color{blue}{\left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      6. distribute-neg-in33.3%

        \[\leadsto \frac{\color{blue}{\left(--1\right) + \left(-\sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      7. metadata-eval33.3%

        \[\leadsto \frac{\color{blue}{1} + \left(-\sqrt{\frac{x}{x + 1}}\right)}{\sqrt{x}} \]
      8. unsub-neg33.3%

        \[\leadsto \frac{\color{blue}{1 - \sqrt{\frac{x}{x + 1}}}}{\sqrt{x}} \]
    9. Simplified33.3%

      \[\leadsto \color{blue}{\frac{1 - \sqrt{\frac{x}{x + 1}}}{\sqrt{x}}} \]
    10. Taylor expanded in x around inf 99.5%

      \[\leadsto \frac{\color{blue}{\left(0.5 \cdot \frac{1}{x} + 0.3125 \cdot \frac{1}{{x}^{3}}\right) - 0.375 \cdot \frac{1}{{x}^{2}}}}{\sqrt{x}} \]
    11. Step-by-step derivation
      1. associate--l+99.5%

        \[\leadsto \frac{\color{blue}{0.5 \cdot \frac{1}{x} + \left(0.3125 \cdot \frac{1}{{x}^{3}} - 0.375 \cdot \frac{1}{{x}^{2}}\right)}}{\sqrt{x}} \]
      2. associate-*r/99.5%

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

        \[\leadsto \frac{\frac{\color{blue}{0.5}}{x} + \left(0.3125 \cdot \frac{1}{{x}^{3}} - 0.375 \cdot \frac{1}{{x}^{2}}\right)}{\sqrt{x}} \]
      4. associate-*r/99.5%

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

        \[\leadsto \frac{\frac{0.5}{x} + \left(\frac{\color{blue}{0.3125}}{{x}^{3}} - 0.375 \cdot \frac{1}{{x}^{2}}\right)}{\sqrt{x}} \]
      6. associate-*r/99.5%

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

        \[\leadsto \frac{\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \frac{\color{blue}{0.375}}{{x}^{2}}\right)}{\sqrt{x}} \]
      8. unpow299.5%

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

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

    if 9.99999999999999955e-7 < (-.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. Step-by-step derivation
      1. *-un-lft-identity99.6%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.6%

        \[\leadsto \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)} \]
      5. *-un-lft-identity99.6%

        \[\leadsto \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) \]
      6. fma-neg99.6%

        \[\leadsto \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) \]
      7. *-un-lft-identity99.6%

        \[\leadsto \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) \]
      8. inv-pow99.6%

        \[\leadsto \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) \]
      9. sqrt-pow2100.0%

        \[\leadsto \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) \]
      10. metadata-eval100.0%

        \[\leadsto \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) \]
      11. pow1/2100.0%

        \[\leadsto \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) \]
      12. pow-flip100.0%

        \[\leadsto \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) \]
      13. +-commutative100.0%

        \[\leadsto \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) \]
      14. metadata-eval100.0%

        \[\leadsto \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. Applied egg-rr100.0%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-udef100.0%

        \[\leadsto \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)} \]
      2. distribute-lft1-in100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}} \]
      3. metadata-eval100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} \]
      4. mul0-lft100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \]
      5. +-rgt-identity100.0%

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

      \[\leadsto \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 10^{-6}:\\ \;\;\;\;\frac{\frac{0.5}{x} + \left(\frac{0.3125}{{x}^{3}} - \frac{0.375}{x \cdot x}\right)}{\sqrt{x}}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\ \end{array} \]

Alternative 3: 99.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\frac{0.5}{x} - \frac{0.375}{x \cdot x}}{\sqrt{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 2.00000000000000012e-9

    1. Initial program 32.7%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. frac-sub32.7%

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. div-inv32.7%

        \[\leadsto \color{blue}{\left(1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      3. *-un-lft-identity32.7%

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

        \[\leadsto \left(\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      5. *-rgt-identity32.7%

        \[\leadsto \left(\sqrt{1 + x} - \color{blue}{\sqrt{x}}\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      6. metadata-eval32.7%

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

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      8. un-div-inv32.7%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\frac{\frac{1}{\sqrt{x}}}{\sqrt{x + 1}}} \]
      9. pow1/232.7%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{\frac{1}{\color{blue}{{x}^{0.5}}}}{\sqrt{x + 1}} \]
      10. pow-flip32.7%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{\color{blue}{{x}^{\left(-0.5\right)}}}{\sqrt{x + 1}} \]
      11. metadata-eval32.7%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{\color{blue}{-0.5}}}{\sqrt{x + 1}} \]
      12. +-commutative32.7%

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

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{-0.5}}{\sqrt{1 + x}}} \]
    4. Step-by-step derivation
      1. associate-*r/32.7%

        \[\leadsto \color{blue}{\frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\sqrt{1 + x}}} \]
      2. remove-double-neg32.7%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{-\left(-\sqrt{1 + x}\right)}} \]
      3. neg-mul-132.7%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{-1 \cdot \left(-\sqrt{1 + x}\right)}} \]
      4. *-commutative32.7%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{\left(-\sqrt{1 + x}\right) \cdot -1}} \]
      5. times-frac32.7%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{-\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{-1}} \]
    5. Simplified32.7%

      \[\leadsto \color{blue}{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot \frac{-1}{\sqrt{x}}} \]
    6. Step-by-step derivation
      1. associate-*r/32.7%

        \[\leadsto \color{blue}{\frac{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot -1}{\sqrt{x}}} \]
      2. clear-num32.7%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x}}{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot -1}}} \]
      3. *-commutative32.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{\color{blue}{-1 \cdot \left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right)}}} \]
      4. sub-neg32.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \color{blue}{\left(-1 + \left(-\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right)\right)}}} \]
      5. distribute-neg-frac32.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\frac{-\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      6. add-sqr-sqrt0.0%

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

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{\left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right) \cdot \left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right)}}}\right)}} \]
      8. sqr-neg5.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\sqrt{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right) \cdot \mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      9. sqrt-prod5.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{\mathsf{hypot}\left(1, \sqrt{x}\right)} \cdot \sqrt{\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      10. add-sqr-sqrt5.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      11. remove-double-neg5.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{-\left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right)}}\right)}} \]
      12. frac-2neg5.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      13. add-sqr-sqrt0.0%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\sqrt{\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}} \cdot \sqrt{\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      14. sqrt-unprod32.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\sqrt{\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)} \cdot \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
    7. Applied egg-rr32.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r/32.8%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{x}} \cdot \left(-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)} \]
      2. associate-*l/32.8%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)}{\sqrt{x}}} \]
      3. neg-mul-132.8%

        \[\leadsto \frac{1 \cdot \color{blue}{\left(-\left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)}}{\sqrt{x}} \]
      4. distribute-rgt-neg-in32.8%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      5. *-lft-identity32.8%

        \[\leadsto \frac{-\color{blue}{\left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      6. distribute-neg-in32.8%

        \[\leadsto \frac{\color{blue}{\left(--1\right) + \left(-\sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      7. metadata-eval32.8%

        \[\leadsto \frac{\color{blue}{1} + \left(-\sqrt{\frac{x}{x + 1}}\right)}{\sqrt{x}} \]
      8. unsub-neg32.8%

        \[\leadsto \frac{\color{blue}{1 - \sqrt{\frac{x}{x + 1}}}}{\sqrt{x}} \]
    9. Simplified32.8%

      \[\leadsto \color{blue}{\frac{1 - \sqrt{\frac{x}{x + 1}}}{\sqrt{x}}} \]
    10. Taylor expanded in x around inf 99.4%

      \[\leadsto \frac{\color{blue}{0.5 \cdot \frac{1}{x} - 0.375 \cdot \frac{1}{{x}^{2}}}}{\sqrt{x}} \]
    11. Step-by-step derivation
      1. associate-*r/99.4%

        \[\leadsto \frac{\color{blue}{\frac{0.5 \cdot 1}{x}} - 0.375 \cdot \frac{1}{{x}^{2}}}{\sqrt{x}} \]
      2. metadata-eval99.4%

        \[\leadsto \frac{\frac{\color{blue}{0.5}}{x} - 0.375 \cdot \frac{1}{{x}^{2}}}{\sqrt{x}} \]
      3. associate-*r/99.4%

        \[\leadsto \frac{\frac{0.5}{x} - \color{blue}{\frac{0.375 \cdot 1}{{x}^{2}}}}{\sqrt{x}} \]
      4. metadata-eval99.4%

        \[\leadsto \frac{\frac{0.5}{x} - \frac{\color{blue}{0.375}}{{x}^{2}}}{\sqrt{x}} \]
      5. unpow299.4%

        \[\leadsto \frac{\frac{0.5}{x} - \frac{0.375}{\color{blue}{x \cdot x}}}{\sqrt{x}} \]
    12. Simplified99.4%

      \[\leadsto \frac{\color{blue}{\frac{0.5}{x} - \frac{0.375}{x \cdot x}}}{\sqrt{x}} \]

    if 2.00000000000000012e-9 < (-.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. Step-by-step derivation
      1. *-un-lft-identity99.4%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num99.4%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/99.4%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.4%

        \[\leadsto \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)} \]
      5. *-un-lft-identity99.4%

        \[\leadsto \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) \]
      6. fma-neg99.4%

        \[\leadsto \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) \]
      7. *-un-lft-identity99.4%

        \[\leadsto \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) \]
      8. inv-pow99.4%

        \[\leadsto \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) \]
      9. sqrt-pow299.8%

        \[\leadsto \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) \]
      10. metadata-eval99.8%

        \[\leadsto \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) \]
      11. pow1/299.8%

        \[\leadsto \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) \]
      12. pow-flip99.8%

        \[\leadsto \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) \]
      13. +-commutative99.8%

        \[\leadsto \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) \]
      14. metadata-eval99.8%

        \[\leadsto \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. 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)} \]
    4. Step-by-step derivation
      1. fma-udef99.8%

        \[\leadsto \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)} \]
      2. distribute-lft1-in99.8%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}} \]
      3. metadata-eval99.8%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} \]
      4. mul0-lft99.8%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \]
      5. +-rgt-identity99.8%

        \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    5. Simplified99.8%

      \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    6. Step-by-step derivation
      1. pow-to-exp99.8%

        \[\leadsto {x}^{-0.5} - \color{blue}{e^{\log \left(1 + x\right) \cdot -0.5}} \]
      2. log1p-udef99.8%

        \[\leadsto {x}^{-0.5} - e^{\color{blue}{\mathsf{log1p}\left(x\right)} \cdot -0.5} \]
    7. Applied egg-rr99.8%

      \[\leadsto {x}^{-0.5} - \color{blue}{e^{\mathsf{log1p}\left(x\right) \cdot -0.5}} \]
    8. Applied egg-rr99.8%

      \[\leadsto {x}^{-0.5} - \color{blue}{\frac{0 - \frac{-1}{x + 1}}{{\left(x + 1\right)}^{-0.5}}} \]
    9. Step-by-step derivation
      1. sub0-neg99.8%

        \[\leadsto {x}^{-0.5} - \frac{\color{blue}{-\frac{-1}{x + 1}}}{{\left(x + 1\right)}^{-0.5}} \]
      2. distribute-neg-frac99.8%

        \[\leadsto {x}^{-0.5} - \frac{\color{blue}{\frac{--1}{x + 1}}}{{\left(x + 1\right)}^{-0.5}} \]
      3. metadata-eval99.8%

        \[\leadsto {x}^{-0.5} - \frac{\frac{\color{blue}{1}}{x + 1}}{{\left(x + 1\right)}^{-0.5}} \]
    10. Simplified99.8%

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

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

Alternative 4: 99.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 2 \cdot 10^{-9}:\\
\;\;\;\;\frac{\frac{0.5}{x} - \frac{0.375}{x \cdot x}}{\sqrt{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1)))) < 2.00000000000000012e-9

    1. Initial program 32.7%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. frac-sub32.7%

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. div-inv32.7%

        \[\leadsto \color{blue}{\left(1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      3. *-un-lft-identity32.7%

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

        \[\leadsto \left(\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      5. *-rgt-identity32.7%

        \[\leadsto \left(\sqrt{1 + x} - \color{blue}{\sqrt{x}}\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      6. metadata-eval32.7%

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

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      8. un-div-inv32.7%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\frac{\frac{1}{\sqrt{x}}}{\sqrt{x + 1}}} \]
      9. pow1/232.7%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{\frac{1}{\color{blue}{{x}^{0.5}}}}{\sqrt{x + 1}} \]
      10. pow-flip32.7%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{\color{blue}{{x}^{\left(-0.5\right)}}}{\sqrt{x + 1}} \]
      11. metadata-eval32.7%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{\color{blue}{-0.5}}}{\sqrt{x + 1}} \]
      12. +-commutative32.7%

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

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{-0.5}}{\sqrt{1 + x}}} \]
    4. Step-by-step derivation
      1. associate-*r/32.7%

        \[\leadsto \color{blue}{\frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\sqrt{1 + x}}} \]
      2. remove-double-neg32.7%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{-\left(-\sqrt{1 + x}\right)}} \]
      3. neg-mul-132.7%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{-1 \cdot \left(-\sqrt{1 + x}\right)}} \]
      4. *-commutative32.7%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{\left(-\sqrt{1 + x}\right) \cdot -1}} \]
      5. times-frac32.7%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{-\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{-1}} \]
    5. Simplified32.7%

      \[\leadsto \color{blue}{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot \frac{-1}{\sqrt{x}}} \]
    6. Step-by-step derivation
      1. associate-*r/32.7%

        \[\leadsto \color{blue}{\frac{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot -1}{\sqrt{x}}} \]
      2. clear-num32.7%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x}}{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot -1}}} \]
      3. *-commutative32.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{\color{blue}{-1 \cdot \left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right)}}} \]
      4. sub-neg32.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \color{blue}{\left(-1 + \left(-\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right)\right)}}} \]
      5. distribute-neg-frac32.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\frac{-\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      6. add-sqr-sqrt0.0%

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

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{\left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right) \cdot \left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right)}}}\right)}} \]
      8. sqr-neg5.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\sqrt{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right) \cdot \mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      9. sqrt-prod5.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{\mathsf{hypot}\left(1, \sqrt{x}\right)} \cdot \sqrt{\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      10. add-sqr-sqrt5.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      11. remove-double-neg5.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{-\left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right)}}\right)}} \]
      12. frac-2neg5.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      13. add-sqr-sqrt0.0%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\sqrt{\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}} \cdot \sqrt{\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      14. sqrt-unprod32.7%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\sqrt{\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)} \cdot \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
    7. Applied egg-rr32.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r/32.8%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{x}} \cdot \left(-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)} \]
      2. associate-*l/32.8%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)}{\sqrt{x}}} \]
      3. neg-mul-132.8%

        \[\leadsto \frac{1 \cdot \color{blue}{\left(-\left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)}}{\sqrt{x}} \]
      4. distribute-rgt-neg-in32.8%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      5. *-lft-identity32.8%

        \[\leadsto \frac{-\color{blue}{\left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      6. distribute-neg-in32.8%

        \[\leadsto \frac{\color{blue}{\left(--1\right) + \left(-\sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      7. metadata-eval32.8%

        \[\leadsto \frac{\color{blue}{1} + \left(-\sqrt{\frac{x}{x + 1}}\right)}{\sqrt{x}} \]
      8. unsub-neg32.8%

        \[\leadsto \frac{\color{blue}{1 - \sqrt{\frac{x}{x + 1}}}}{\sqrt{x}} \]
    9. Simplified32.8%

      \[\leadsto \color{blue}{\frac{1 - \sqrt{\frac{x}{x + 1}}}{\sqrt{x}}} \]
    10. Taylor expanded in x around inf 99.4%

      \[\leadsto \frac{\color{blue}{0.5 \cdot \frac{1}{x} - 0.375 \cdot \frac{1}{{x}^{2}}}}{\sqrt{x}} \]
    11. Step-by-step derivation
      1. associate-*r/99.4%

        \[\leadsto \frac{\color{blue}{\frac{0.5 \cdot 1}{x}} - 0.375 \cdot \frac{1}{{x}^{2}}}{\sqrt{x}} \]
      2. metadata-eval99.4%

        \[\leadsto \frac{\frac{\color{blue}{0.5}}{x} - 0.375 \cdot \frac{1}{{x}^{2}}}{\sqrt{x}} \]
      3. associate-*r/99.4%

        \[\leadsto \frac{\frac{0.5}{x} - \color{blue}{\frac{0.375 \cdot 1}{{x}^{2}}}}{\sqrt{x}} \]
      4. metadata-eval99.4%

        \[\leadsto \frac{\frac{0.5}{x} - \frac{\color{blue}{0.375}}{{x}^{2}}}{\sqrt{x}} \]
      5. unpow299.4%

        \[\leadsto \frac{\frac{0.5}{x} - \frac{0.375}{\color{blue}{x \cdot x}}}{\sqrt{x}} \]
    12. Simplified99.4%

      \[\leadsto \frac{\color{blue}{\frac{0.5}{x} - \frac{0.375}{x \cdot x}}}{\sqrt{x}} \]

    if 2.00000000000000012e-9 < (-.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. Step-by-step derivation
      1. *-un-lft-identity99.4%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num99.4%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/99.4%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.4%

        \[\leadsto \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)} \]
      5. *-un-lft-identity99.4%

        \[\leadsto \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) \]
      6. fma-neg99.4%

        \[\leadsto \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) \]
      7. *-un-lft-identity99.4%

        \[\leadsto \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) \]
      8. inv-pow99.4%

        \[\leadsto \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) \]
      9. sqrt-pow299.8%

        \[\leadsto \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) \]
      10. metadata-eval99.8%

        \[\leadsto \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) \]
      11. pow1/299.8%

        \[\leadsto \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) \]
      12. pow-flip99.8%

        \[\leadsto \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) \]
      13. +-commutative99.8%

        \[\leadsto \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) \]
      14. metadata-eval99.8%

        \[\leadsto \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. 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)} \]
    4. Step-by-step derivation
      1. fma-udef99.8%

        \[\leadsto \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)} \]
      2. distribute-lft1-in99.8%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}} \]
      3. metadata-eval99.8%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} \]
      4. mul0-lft99.8%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \]
      5. +-rgt-identity99.8%

        \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    5. Simplified99.8%

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

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

Alternative 5: 99.0% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \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} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 1.1)
   (+ (pow x -0.5) (- -1.0 (* x -0.5)))
   (/ (- (/ 0.5 x) (/ 0.375 (* x x))) (sqrt x))))
double code(double x) {
	double tmp;
	if (x <= 1.1) {
		tmp = pow(x, -0.5) + (-1.0 - (x * -0.5));
	} else {
		tmp = ((0.5 / x) - (0.375 / (x * x))) / sqrt(x);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 1.1d0) then
        tmp = (x ** (-0.5d0)) + ((-1.0d0) - (x * (-0.5d0)))
    else
        tmp = ((0.5d0 / x) - (0.375d0 / (x * x))) / sqrt(x)
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 1.1) {
		tmp = Math.pow(x, -0.5) + (-1.0 - (x * -0.5));
	} else {
		tmp = ((0.5 / x) - (0.375 / (x * x))) / Math.sqrt(x);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 1.1:
		tmp = math.pow(x, -0.5) + (-1.0 - (x * -0.5))
	else:
		tmp = ((0.5 / x) - (0.375 / (x * x))) / math.sqrt(x)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 1.1)
		tmp = Float64((x ^ -0.5) + Float64(-1.0 - Float64(x * -0.5)));
	else
		tmp = Float64(Float64(Float64(0.5 / x) - Float64(0.375 / Float64(x * x))) / sqrt(x));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 1.1)
		tmp = (x ^ -0.5) + (-1.0 - (x * -0.5));
	else
		tmp = ((0.5 / x) - (0.375 / (x * x))) / sqrt(x);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 1.1], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 - N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(0.5 / x), $MachinePrecision] - N[(0.375 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\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}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.1000000000000001

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity99.6%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.6%

        \[\leadsto \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)} \]
      5. *-un-lft-identity99.6%

        \[\leadsto \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) \]
      6. fma-neg99.6%

        \[\leadsto \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) \]
      7. *-un-lft-identity99.6%

        \[\leadsto \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) \]
      8. inv-pow99.6%

        \[\leadsto \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) \]
      9. sqrt-pow2100.0%

        \[\leadsto \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) \]
      10. metadata-eval100.0%

        \[\leadsto \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) \]
      11. pow1/2100.0%

        \[\leadsto \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) \]
      12. pow-flip100.0%

        \[\leadsto \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) \]
      13. +-commutative100.0%

        \[\leadsto \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) \]
      14. metadata-eval100.0%

        \[\leadsto \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. Applied egg-rr100.0%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-udef100.0%

        \[\leadsto \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)} \]
      2. distribute-lft1-in100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}} \]
      3. metadata-eval100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} \]
      4. mul0-lft100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \]
      5. +-rgt-identity100.0%

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

      \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    6. Taylor expanded in x around 0 97.2%

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

    if 1.1000000000000001 < x

    1. Initial program 33.1%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. frac-sub33.1%

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. div-inv33.1%

        \[\leadsto \color{blue}{\left(1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      3. *-un-lft-identity33.1%

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

        \[\leadsto \left(\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      5. *-rgt-identity33.1%

        \[\leadsto \left(\sqrt{1 + x} - \color{blue}{\sqrt{x}}\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      6. metadata-eval33.1%

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

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      8. un-div-inv33.1%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\frac{\frac{1}{\sqrt{x}}}{\sqrt{x + 1}}} \]
      9. pow1/233.1%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{\frac{1}{\color{blue}{{x}^{0.5}}}}{\sqrt{x + 1}} \]
      10. pow-flip33.1%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{\color{blue}{{x}^{\left(-0.5\right)}}}{\sqrt{x + 1}} \]
      11. metadata-eval33.1%

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

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

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{-0.5}}{\sqrt{1 + x}}} \]
    4. Step-by-step derivation
      1. associate-*r/33.1%

        \[\leadsto \color{blue}{\frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\sqrt{1 + x}}} \]
      2. remove-double-neg33.1%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{-\left(-\sqrt{1 + x}\right)}} \]
      3. neg-mul-133.1%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{-1 \cdot \left(-\sqrt{1 + x}\right)}} \]
      4. *-commutative33.1%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{\left(-\sqrt{1 + x}\right) \cdot -1}} \]
      5. times-frac33.1%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{-\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{-1}} \]
    5. Simplified33.1%

      \[\leadsto \color{blue}{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot \frac{-1}{\sqrt{x}}} \]
    6. Step-by-step derivation
      1. associate-*r/33.1%

        \[\leadsto \color{blue}{\frac{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot -1}{\sqrt{x}}} \]
      2. clear-num33.1%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x}}{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot -1}}} \]
      3. *-commutative33.1%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{\color{blue}{-1 \cdot \left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right)}}} \]
      4. sub-neg33.1%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \color{blue}{\left(-1 + \left(-\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right)\right)}}} \]
      5. distribute-neg-frac33.1%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\frac{-\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      6. add-sqr-sqrt0.0%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{-\mathsf{hypot}\left(1, \sqrt{x}\right)} \cdot \sqrt{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      7. sqrt-unprod5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{\left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right) \cdot \left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right)}}}\right)}} \]
      8. sqr-neg5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\sqrt{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right) \cdot \mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      9. sqrt-prod5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{\mathsf{hypot}\left(1, \sqrt{x}\right)} \cdot \sqrt{\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      10. add-sqr-sqrt5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      11. remove-double-neg5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{-\left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right)}}\right)}} \]
      12. frac-2neg5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      13. add-sqr-sqrt0.0%

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r/33.3%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{x}} \cdot \left(-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)} \]
      2. associate-*l/33.3%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)}{\sqrt{x}}} \]
      3. neg-mul-133.3%

        \[\leadsto \frac{1 \cdot \color{blue}{\left(-\left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)}}{\sqrt{x}} \]
      4. distribute-rgt-neg-in33.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      5. *-lft-identity33.3%

        \[\leadsto \frac{-\color{blue}{\left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      6. distribute-neg-in33.3%

        \[\leadsto \frac{\color{blue}{\left(--1\right) + \left(-\sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      7. metadata-eval33.3%

        \[\leadsto \frac{\color{blue}{1} + \left(-\sqrt{\frac{x}{x + 1}}\right)}{\sqrt{x}} \]
      8. unsub-neg33.3%

        \[\leadsto \frac{\color{blue}{1 - \sqrt{\frac{x}{x + 1}}}}{\sqrt{x}} \]
    9. Simplified33.3%

      \[\leadsto \color{blue}{\frac{1 - \sqrt{\frac{x}{x + 1}}}{\sqrt{x}}} \]
    10. Taylor expanded in x around inf 99.1%

      \[\leadsto \frac{\color{blue}{0.5 \cdot \frac{1}{x} - 0.375 \cdot \frac{1}{{x}^{2}}}}{\sqrt{x}} \]
    11. Step-by-step derivation
      1. associate-*r/99.1%

        \[\leadsto \frac{\color{blue}{\frac{0.5 \cdot 1}{x}} - 0.375 \cdot \frac{1}{{x}^{2}}}{\sqrt{x}} \]
      2. metadata-eval99.1%

        \[\leadsto \frac{\frac{\color{blue}{0.5}}{x} - 0.375 \cdot \frac{1}{{x}^{2}}}{\sqrt{x}} \]
      3. associate-*r/99.1%

        \[\leadsto \frac{\frac{0.5}{x} - \color{blue}{\frac{0.375 \cdot 1}{{x}^{2}}}}{\sqrt{x}} \]
      4. metadata-eval99.1%

        \[\leadsto \frac{\frac{0.5}{x} - \frac{\color{blue}{0.375}}{{x}^{2}}}{\sqrt{x}} \]
      5. unpow299.1%

        \[\leadsto \frac{\frac{0.5}{x} - \frac{0.375}{\color{blue}{x \cdot x}}}{\sqrt{x}} \]
    12. Simplified99.1%

      \[\leadsto \frac{\color{blue}{\frac{0.5}{x} - \frac{0.375}{x \cdot x}}}{\sqrt{x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.1%

    \[\leadsto \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 6: 98.5% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \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} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 1.0) (+ (pow x -0.5) (- -1.0 (* x -0.5))) (/ (/ 0.5 x) (sqrt x))))
double code(double x) {
	double tmp;
	if (x <= 1.0) {
		tmp = pow(x, -0.5) + (-1.0 - (x * -0.5));
	} else {
		tmp = (0.5 / x) / sqrt(x);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 1.0d0) then
        tmp = (x ** (-0.5d0)) + ((-1.0d0) - (x * (-0.5d0)))
    else
        tmp = (0.5d0 / x) / sqrt(x)
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 1.0) {
		tmp = Math.pow(x, -0.5) + (-1.0 - (x * -0.5));
	} else {
		tmp = (0.5 / x) / Math.sqrt(x);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 1.0:
		tmp = math.pow(x, -0.5) + (-1.0 - (x * -0.5))
	else:
		tmp = (0.5 / x) / math.sqrt(x)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 1.0)
		tmp = Float64((x ^ -0.5) + Float64(-1.0 - Float64(x * -0.5)));
	else
		tmp = Float64(Float64(0.5 / x) / sqrt(x));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 1.0)
		tmp = (x ^ -0.5) + (-1.0 - (x * -0.5));
	else
		tmp = (0.5 / x) / sqrt(x);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 1.0], N[(N[Power[x, -0.5], $MachinePrecision] + N[(-1.0 - N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\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}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity99.6%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.6%

        \[\leadsto \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)} \]
      5. *-un-lft-identity99.6%

        \[\leadsto \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) \]
      6. fma-neg99.6%

        \[\leadsto \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) \]
      7. *-un-lft-identity99.6%

        \[\leadsto \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) \]
      8. inv-pow99.6%

        \[\leadsto \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) \]
      9. sqrt-pow2100.0%

        \[\leadsto \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) \]
      10. metadata-eval100.0%

        \[\leadsto \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) \]
      11. pow1/2100.0%

        \[\leadsto \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) \]
      12. pow-flip100.0%

        \[\leadsto \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) \]
      13. +-commutative100.0%

        \[\leadsto \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) \]
      14. metadata-eval100.0%

        \[\leadsto \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. Applied egg-rr100.0%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-udef100.0%

        \[\leadsto \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)} \]
      2. distribute-lft1-in100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}} \]
      3. metadata-eval100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} \]
      4. mul0-lft100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \]
      5. +-rgt-identity100.0%

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

      \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    6. Taylor expanded in x around 0 97.2%

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

    if 1 < x

    1. Initial program 33.1%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. frac-sub33.1%

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. div-inv33.1%

        \[\leadsto \color{blue}{\left(1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      3. *-un-lft-identity33.1%

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

        \[\leadsto \left(\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      5. *-rgt-identity33.1%

        \[\leadsto \left(\sqrt{1 + x} - \color{blue}{\sqrt{x}}\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      6. metadata-eval33.1%

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

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      8. un-div-inv33.1%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\frac{\frac{1}{\sqrt{x}}}{\sqrt{x + 1}}} \]
      9. pow1/233.1%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{\frac{1}{\color{blue}{{x}^{0.5}}}}{\sqrt{x + 1}} \]
      10. pow-flip33.1%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{\color{blue}{{x}^{\left(-0.5\right)}}}{\sqrt{x + 1}} \]
      11. metadata-eval33.1%

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

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

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{-0.5}}{\sqrt{1 + x}}} \]
    4. Step-by-step derivation
      1. associate-*r/33.1%

        \[\leadsto \color{blue}{\frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\sqrt{1 + x}}} \]
      2. remove-double-neg33.1%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{-\left(-\sqrt{1 + x}\right)}} \]
      3. neg-mul-133.1%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{-1 \cdot \left(-\sqrt{1 + x}\right)}} \]
      4. *-commutative33.1%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{\left(-\sqrt{1 + x}\right) \cdot -1}} \]
      5. times-frac33.1%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{-\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{-1}} \]
    5. Simplified33.1%

      \[\leadsto \color{blue}{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot \frac{-1}{\sqrt{x}}} \]
    6. Step-by-step derivation
      1. associate-*r/33.1%

        \[\leadsto \color{blue}{\frac{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot -1}{\sqrt{x}}} \]
      2. clear-num33.1%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x}}{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot -1}}} \]
      3. *-commutative33.1%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{\color{blue}{-1 \cdot \left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right)}}} \]
      4. sub-neg33.1%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \color{blue}{\left(-1 + \left(-\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right)\right)}}} \]
      5. distribute-neg-frac33.1%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\frac{-\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      6. add-sqr-sqrt0.0%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{-\mathsf{hypot}\left(1, \sqrt{x}\right)} \cdot \sqrt{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      7. sqrt-unprod5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{\left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right) \cdot \left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right)}}}\right)}} \]
      8. sqr-neg5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\sqrt{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right) \cdot \mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      9. sqrt-prod5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{\mathsf{hypot}\left(1, \sqrt{x}\right)} \cdot \sqrt{\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      10. add-sqr-sqrt5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      11. remove-double-neg5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{-\left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right)}}\right)}} \]
      12. frac-2neg5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      13. add-sqr-sqrt0.0%

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r/33.3%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{x}} \cdot \left(-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)} \]
      2. associate-*l/33.3%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)}{\sqrt{x}}} \]
      3. neg-mul-133.3%

        \[\leadsto \frac{1 \cdot \color{blue}{\left(-\left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)}}{\sqrt{x}} \]
      4. distribute-rgt-neg-in33.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      5. *-lft-identity33.3%

        \[\leadsto \frac{-\color{blue}{\left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      6. distribute-neg-in33.3%

        \[\leadsto \frac{\color{blue}{\left(--1\right) + \left(-\sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      7. metadata-eval33.3%

        \[\leadsto \frac{\color{blue}{1} + \left(-\sqrt{\frac{x}{x + 1}}\right)}{\sqrt{x}} \]
      8. unsub-neg33.3%

        \[\leadsto \frac{\color{blue}{1 - \sqrt{\frac{x}{x + 1}}}}{\sqrt{x}} \]
    9. Simplified33.3%

      \[\leadsto \color{blue}{\frac{1 - \sqrt{\frac{x}{x + 1}}}{\sqrt{x}}} \]
    10. Taylor expanded in x around inf 98.6%

      \[\leadsto \frac{\color{blue}{\frac{0.5}{x}}}{\sqrt{x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.9%

    \[\leadsto \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 7: 98.2% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.66:\\ \;\;\;\;{x}^{-0.5} + -1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{x}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.66) (+ (pow x -0.5) -1.0) (/ (/ 0.5 x) (sqrt x))))
double code(double x) {
	double tmp;
	if (x <= 0.66) {
		tmp = pow(x, -0.5) + -1.0;
	} else {
		tmp = (0.5 / x) / sqrt(x);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 0.66d0) then
        tmp = (x ** (-0.5d0)) + (-1.0d0)
    else
        tmp = (0.5d0 / x) / sqrt(x)
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 0.66) {
		tmp = Math.pow(x, -0.5) + -1.0;
	} else {
		tmp = (0.5 / x) / Math.sqrt(x);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 0.66:
		tmp = math.pow(x, -0.5) + -1.0
	else:
		tmp = (0.5 / x) / math.sqrt(x)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 0.66)
		tmp = Float64((x ^ -0.5) + -1.0);
	else
		tmp = Float64(Float64(0.5 / x) / sqrt(x));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 0.66)
		tmp = (x ^ -0.5) + -1.0;
	else
		tmp = (0.5 / x) / sqrt(x);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 0.66], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], N[(N[(0.5 / x), $MachinePrecision] / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.66:\\
\;\;\;\;{x}^{-0.5} + -1\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 0.660000000000000031

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity99.6%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.6%

        \[\leadsto \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)} \]
      5. *-un-lft-identity99.6%

        \[\leadsto \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) \]
      6. fma-neg99.6%

        \[\leadsto \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) \]
      7. *-un-lft-identity99.6%

        \[\leadsto \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) \]
      8. inv-pow99.6%

        \[\leadsto \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) \]
      9. sqrt-pow2100.0%

        \[\leadsto \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) \]
      10. metadata-eval100.0%

        \[\leadsto \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) \]
      11. pow1/2100.0%

        \[\leadsto \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) \]
      12. pow-flip100.0%

        \[\leadsto \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) \]
      13. +-commutative100.0%

        \[\leadsto \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) \]
      14. metadata-eval100.0%

        \[\leadsto \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. Applied egg-rr100.0%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-udef100.0%

        \[\leadsto \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)} \]
      2. distribute-lft1-in100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}} \]
      3. metadata-eval100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} \]
      4. mul0-lft100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \]
      5. +-rgt-identity100.0%

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

      \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    6. Taylor expanded in x around 0 95.7%

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

    if 0.660000000000000031 < x

    1. Initial program 33.1%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. frac-sub33.1%

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. div-inv33.1%

        \[\leadsto \color{blue}{\left(1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      3. *-un-lft-identity33.1%

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

        \[\leadsto \left(\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      5. *-rgt-identity33.1%

        \[\leadsto \left(\sqrt{1 + x} - \color{blue}{\sqrt{x}}\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      6. metadata-eval33.1%

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

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      8. un-div-inv33.1%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\frac{\frac{1}{\sqrt{x}}}{\sqrt{x + 1}}} \]
      9. pow1/233.1%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{\frac{1}{\color{blue}{{x}^{0.5}}}}{\sqrt{x + 1}} \]
      10. pow-flip33.1%

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{\color{blue}{{x}^{\left(-0.5\right)}}}{\sqrt{x + 1}} \]
      11. metadata-eval33.1%

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

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

      \[\leadsto \color{blue}{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{-0.5}}{\sqrt{1 + x}}} \]
    4. Step-by-step derivation
      1. associate-*r/33.1%

        \[\leadsto \color{blue}{\frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\sqrt{1 + x}}} \]
      2. remove-double-neg33.1%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{-\left(-\sqrt{1 + x}\right)}} \]
      3. neg-mul-133.1%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{-1 \cdot \left(-\sqrt{1 + x}\right)}} \]
      4. *-commutative33.1%

        \[\leadsto \frac{\left(\sqrt{1 + x} - \sqrt{x}\right) \cdot {x}^{-0.5}}{\color{blue}{\left(-\sqrt{1 + x}\right) \cdot -1}} \]
      5. times-frac33.1%

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{-\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{-1}} \]
    5. Simplified33.1%

      \[\leadsto \color{blue}{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot \frac{-1}{\sqrt{x}}} \]
    6. Step-by-step derivation
      1. associate-*r/33.1%

        \[\leadsto \color{blue}{\frac{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot -1}{\sqrt{x}}} \]
      2. clear-num33.1%

        \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x}}{\left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right) \cdot -1}}} \]
      3. *-commutative33.1%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{\color{blue}{-1 \cdot \left(-1 - \frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right)}}} \]
      4. sub-neg33.1%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \color{blue}{\left(-1 + \left(-\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}\right)\right)}}} \]
      5. distribute-neg-frac33.1%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\frac{-\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      6. add-sqr-sqrt0.0%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{-\mathsf{hypot}\left(1, \sqrt{x}\right)} \cdot \sqrt{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      7. sqrt-unprod5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{\left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right) \cdot \left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right)}}}\right)}} \]
      8. sqr-neg5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\sqrt{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right) \cdot \mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      9. sqrt-prod5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\sqrt{\mathsf{hypot}\left(1, \sqrt{x}\right)} \cdot \sqrt{\mathsf{hypot}\left(1, \sqrt{x}\right)}}}\right)}} \]
      10. add-sqr-sqrt5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      11. remove-double-neg5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \frac{-\sqrt{x}}{\color{blue}{-\left(-\mathsf{hypot}\left(1, \sqrt{x}\right)\right)}}\right)}} \]
      12. frac-2neg5.8%

        \[\leadsto \frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \color{blue}{\frac{\sqrt{x}}{-\mathsf{hypot}\left(1, \sqrt{x}\right)}}\right)}} \]
      13. add-sqr-sqrt0.0%

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{\sqrt{x}}{-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}} \]
    8. Step-by-step derivation
      1. associate-/r/33.3%

        \[\leadsto \color{blue}{\frac{1}{\sqrt{x}} \cdot \left(-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)} \]
      2. associate-*l/33.3%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)}{\sqrt{x}}} \]
      3. neg-mul-133.3%

        \[\leadsto \frac{1 \cdot \color{blue}{\left(-\left(-1 + \sqrt{\frac{x}{x + 1}}\right)\right)}}{\sqrt{x}} \]
      4. distribute-rgt-neg-in33.3%

        \[\leadsto \frac{\color{blue}{-1 \cdot \left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      5. *-lft-identity33.3%

        \[\leadsto \frac{-\color{blue}{\left(-1 + \sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      6. distribute-neg-in33.3%

        \[\leadsto \frac{\color{blue}{\left(--1\right) + \left(-\sqrt{\frac{x}{x + 1}}\right)}}{\sqrt{x}} \]
      7. metadata-eval33.3%

        \[\leadsto \frac{\color{blue}{1} + \left(-\sqrt{\frac{x}{x + 1}}\right)}{\sqrt{x}} \]
      8. unsub-neg33.3%

        \[\leadsto \frac{\color{blue}{1 - \sqrt{\frac{x}{x + 1}}}}{\sqrt{x}} \]
    9. Simplified33.3%

      \[\leadsto \color{blue}{\frac{1 - \sqrt{\frac{x}{x + 1}}}{\sqrt{x}}} \]
    10. Taylor expanded in x around inf 98.6%

      \[\leadsto \frac{\color{blue}{\frac{0.5}{x}}}{\sqrt{x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.1%

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

Alternative 8: 67.5% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;{x}^{-0.5} + -1\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x) :precision binary64 (if (<= x 1.0) (+ (pow x -0.5) -1.0) 0.0))
double code(double x) {
	double tmp;
	if (x <= 1.0) {
		tmp = pow(x, -0.5) + -1.0;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 1.0d0) then
        tmp = (x ** (-0.5d0)) + (-1.0d0)
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 1.0) {
		tmp = Math.pow(x, -0.5) + -1.0;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 1.0:
		tmp = math.pow(x, -0.5) + -1.0
	else:
		tmp = 0.0
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 1.0)
		tmp = Float64((x ^ -0.5) + -1.0);
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 1.0)
		tmp = (x ^ -0.5) + -1.0;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 1.0], N[(N[Power[x, -0.5], $MachinePrecision] + -1.0), $MachinePrecision], 0.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;{x}^{-0.5} + -1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity99.6%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/99.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.6%

        \[\leadsto \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)} \]
      5. *-un-lft-identity99.6%

        \[\leadsto \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) \]
      6. fma-neg99.6%

        \[\leadsto \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) \]
      7. *-un-lft-identity99.6%

        \[\leadsto \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) \]
      8. inv-pow99.6%

        \[\leadsto \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) \]
      9. sqrt-pow2100.0%

        \[\leadsto \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) \]
      10. metadata-eval100.0%

        \[\leadsto \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) \]
      11. pow1/2100.0%

        \[\leadsto \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) \]
      12. pow-flip100.0%

        \[\leadsto \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) \]
      13. +-commutative100.0%

        \[\leadsto \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) \]
      14. metadata-eval100.0%

        \[\leadsto \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. Applied egg-rr100.0%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-udef100.0%

        \[\leadsto \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)} \]
      2. distribute-lft1-in100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}} \]
      3. metadata-eval100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} \]
      4. mul0-lft100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \]
      5. +-rgt-identity100.0%

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

      \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    6. Taylor expanded in x around 0 95.7%

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

    if 1 < x

    1. Initial program 33.1%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity33.1%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num33.1%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/33.1%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff33.1%

        \[\leadsto \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)} \]
      5. *-un-lft-identity33.1%

        \[\leadsto \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) \]
      6. fma-neg33.1%

        \[\leadsto \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) \]
      7. *-un-lft-identity33.1%

        \[\leadsto \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) \]
      8. inv-pow33.1%

        \[\leadsto \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) \]
      9. sqrt-pow224.6%

        \[\leadsto \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) \]
      10. metadata-eval24.6%

        \[\leadsto \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) \]
      11. pow1/224.6%

        \[\leadsto \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) \]
      12. pow-flip33.2%

        \[\leadsto \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) \]
      13. +-commutative33.2%

        \[\leadsto \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) \]
      14. metadata-eval33.2%

        \[\leadsto \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. Applied egg-rr33.2%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-udef33.2%

        \[\leadsto \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)} \]
      2. distribute-lft1-in33.2%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}} \]
      3. metadata-eval33.2%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} \]
      4. mul0-lft33.2%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \]
      5. +-rgt-identity33.2%

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

      \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    6. Step-by-step derivation
      1. sqr-pow19.4%

        \[\leadsto \color{blue}{{x}^{\left(\frac{-0.5}{2}\right)} \cdot {x}^{\left(\frac{-0.5}{2}\right)}} - {\left(1 + x\right)}^{-0.5} \]
      2. fma-neg6.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left({x}^{\left(\frac{-0.5}{2}\right)}, {x}^{\left(\frac{-0.5}{2}\right)}, -{\left(1 + x\right)}^{-0.5}\right)} \]
      3. metadata-eval6.0%

        \[\leadsto \mathsf{fma}\left({x}^{\color{blue}{-0.25}}, {x}^{\left(\frac{-0.5}{2}\right)}, -{\left(1 + x\right)}^{-0.5}\right) \]
      4. metadata-eval6.0%

        \[\leadsto \mathsf{fma}\left({x}^{-0.25}, {x}^{\color{blue}{-0.25}}, -{\left(1 + x\right)}^{-0.5}\right) \]
      5. +-commutative6.0%

        \[\leadsto \mathsf{fma}\left({x}^{-0.25}, {x}^{-0.25}, -{\color{blue}{\left(x + 1\right)}}^{-0.5}\right) \]
    7. Applied egg-rr6.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left({x}^{-0.25}, {x}^{-0.25}, -{\left(x + 1\right)}^{-0.5}\right)} \]
    8. Taylor expanded in x around inf 31.7%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}} - {\left(\frac{1}{x}\right)}^{0.5}} \]
    9. Step-by-step derivation
      1. unpow1/231.7%

        \[\leadsto \sqrt{\frac{1}{x}} - \color{blue}{\sqrt{\frac{1}{x}}} \]
      2. +-inverses31.7%

        \[\leadsto \color{blue}{0} \]
    10. Simplified31.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;{x}^{-0.5} + -1\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]

Alternative 9: 66.8% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 8.5 \cdot 10^{+122}:\\ \;\;\;\;\sqrt{\frac{1}{x}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x) :precision binary64 (if (<= x 8.5e+122) (sqrt (/ 1.0 x)) 0.0))
double code(double x) {
	double tmp;
	if (x <= 8.5e+122) {
		tmp = sqrt((1.0 / x));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 8.5d+122) then
        tmp = sqrt((1.0d0 / x))
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 8.5e+122) {
		tmp = Math.sqrt((1.0 / x));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 8.5e+122:
		tmp = math.sqrt((1.0 / x))
	else:
		tmp = 0.0
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 8.5e+122)
		tmp = sqrt(Float64(1.0 / x));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 8.5e+122)
		tmp = sqrt((1.0 / x));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 8.5e+122], N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision], 0.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.5 \cdot 10^{+122}:\\
\;\;\;\;\sqrt{\frac{1}{x}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 8.50000000000000003e122

    1. Initial program 71.3%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity71.3%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num71.3%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/71.3%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff71.3%

        \[\leadsto \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)} \]
      5. *-un-lft-identity71.3%

        \[\leadsto \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) \]
      6. fma-neg71.3%

        \[\leadsto \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) \]
      7. *-un-lft-identity71.3%

        \[\leadsto \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) \]
      8. inv-pow71.3%

        \[\leadsto \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) \]
      9. sqrt-pow271.5%

        \[\leadsto \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) \]
      10. metadata-eval71.5%

        \[\leadsto \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) \]
      11. pow1/271.5%

        \[\leadsto \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) \]
      12. pow-flip71.6%

        \[\leadsto \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) \]
      13. +-commutative71.6%

        \[\leadsto \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) \]
      14. metadata-eval71.6%

        \[\leadsto \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. Applied egg-rr71.6%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-udef71.6%

        \[\leadsto \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)} \]
      2. distribute-lft1-in71.6%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}} \]
      3. metadata-eval71.6%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} \]
      4. mul0-lft71.6%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \]
      5. +-rgt-identity71.6%

        \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    5. Simplified71.6%

      \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    6. Step-by-step derivation
      1. pow-to-exp71.8%

        \[\leadsto {x}^{-0.5} - \color{blue}{e^{\log \left(1 + x\right) \cdot -0.5}} \]
      2. log1p-udef71.8%

        \[\leadsto {x}^{-0.5} - e^{\color{blue}{\mathsf{log1p}\left(x\right)} \cdot -0.5} \]
    7. Applied egg-rr71.8%

      \[\leadsto {x}^{-0.5} - \color{blue}{e^{\mathsf{log1p}\left(x\right) \cdot -0.5}} \]
    8. Applied egg-rr71.8%

      \[\leadsto {x}^{-0.5} - \color{blue}{\frac{0 - \frac{-1}{x + 1}}{{\left(x + 1\right)}^{-0.5}}} \]
    9. Step-by-step derivation
      1. sub0-neg71.8%

        \[\leadsto {x}^{-0.5} - \frac{\color{blue}{-\frac{-1}{x + 1}}}{{\left(x + 1\right)}^{-0.5}} \]
      2. distribute-neg-frac71.8%

        \[\leadsto {x}^{-0.5} - \frac{\color{blue}{\frac{--1}{x + 1}}}{{\left(x + 1\right)}^{-0.5}} \]
      3. metadata-eval71.8%

        \[\leadsto {x}^{-0.5} - \frac{\frac{\color{blue}{1}}{x + 1}}{{\left(x + 1\right)}^{-0.5}} \]
    10. Simplified71.8%

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

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]

    if 8.50000000000000003e122 < x

    1. Initial program 57.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity57.6%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num57.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/57.6%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff57.6%

        \[\leadsto \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)} \]
      5. *-un-lft-identity57.6%

        \[\leadsto \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) \]
      6. fma-neg57.6%

        \[\leadsto \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) \]
      7. *-un-lft-identity57.6%

        \[\leadsto \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) \]
      8. inv-pow57.6%

        \[\leadsto \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) \]
      9. sqrt-pow241.0%

        \[\leadsto \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) \]
      10. metadata-eval41.0%

        \[\leadsto \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) \]
      11. pow1/241.0%

        \[\leadsto \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) \]
      12. pow-flip57.6%

        \[\leadsto \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) \]
      13. +-commutative57.6%

        \[\leadsto \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) \]
      14. metadata-eval57.6%

        \[\leadsto \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. Applied egg-rr57.6%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-udef57.6%

        \[\leadsto \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)} \]
      2. distribute-lft1-in57.6%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}} \]
      3. metadata-eval57.6%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} \]
      4. mul0-lft57.6%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \]
      5. +-rgt-identity57.6%

        \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    5. Simplified57.6%

      \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    6. Step-by-step derivation
      1. sqr-pow31.0%

        \[\leadsto \color{blue}{{x}^{\left(\frac{-0.5}{2}\right)} \cdot {x}^{\left(\frac{-0.5}{2}\right)}} - {\left(1 + x\right)}^{-0.5} \]
      2. fma-neg4.3%

        \[\leadsto \color{blue}{\mathsf{fma}\left({x}^{\left(\frac{-0.5}{2}\right)}, {x}^{\left(\frac{-0.5}{2}\right)}, -{\left(1 + x\right)}^{-0.5}\right)} \]
      3. metadata-eval4.3%

        \[\leadsto \mathsf{fma}\left({x}^{\color{blue}{-0.25}}, {x}^{\left(\frac{-0.5}{2}\right)}, -{\left(1 + x\right)}^{-0.5}\right) \]
      4. metadata-eval4.3%

        \[\leadsto \mathsf{fma}\left({x}^{-0.25}, {x}^{\color{blue}{-0.25}}, -{\left(1 + x\right)}^{-0.5}\right) \]
      5. +-commutative4.3%

        \[\leadsto \mathsf{fma}\left({x}^{-0.25}, {x}^{-0.25}, -{\color{blue}{\left(x + 1\right)}}^{-0.5}\right) \]
    7. Applied egg-rr4.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left({x}^{-0.25}, {x}^{-0.25}, -{\left(x + 1\right)}^{-0.5}\right)} \]
    8. Taylor expanded in x around inf 57.6%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}} - {\left(\frac{1}{x}\right)}^{0.5}} \]
    9. Step-by-step derivation
      1. unpow1/257.6%

        \[\leadsto \sqrt{\frac{1}{x}} - \color{blue}{\sqrt{\frac{1}{x}}} \]
      2. +-inverses57.6%

        \[\leadsto \color{blue}{0} \]
    10. Simplified57.6%

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

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

Alternative 10: 1.9% accurate, 209.0× speedup?

\[\begin{array}{l} \\ -1 \end{array} \]
(FPCore (x) :precision binary64 -1.0)
double code(double x) {
	return -1.0;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = -1.0d0
end function
public static double code(double x) {
	return -1.0;
}
def code(x):
	return -1.0
function code(x)
	return -1.0
end
function tmp = code(x)
	tmp = -1.0;
end
code[x_] := -1.0
\begin{array}{l}

\\
-1
\end{array}
Derivation
  1. Initial program 67.9%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Taylor expanded in x around 0 51.1%

    \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{1} \]
  3. Taylor expanded in x around inf 1.9%

    \[\leadsto \color{blue}{-1} \]
  4. Final simplification1.9%

    \[\leadsto -1 \]

Alternative 11: 19.4% accurate, 209.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (x) :precision binary64 0.0)
double code(double x) {
	return 0.0;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 0.0d0
end function
public static double code(double x) {
	return 0.0;
}
def code(x):
	return 0.0
function code(x)
	return 0.0
end
function tmp = code(x)
	tmp = 0.0;
end
code[x_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 67.9%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Step-by-step derivation
    1. *-un-lft-identity67.9%

      \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
    2. clear-num67.9%

      \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
    3. associate-/r/67.9%

      \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
    4. prod-diff67.9%

      \[\leadsto \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)} \]
    5. *-un-lft-identity67.9%

      \[\leadsto \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) \]
    6. fma-neg67.9%

      \[\leadsto \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) \]
    7. *-un-lft-identity67.9%

      \[\leadsto \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) \]
    8. inv-pow67.9%

      \[\leadsto \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) \]
    9. sqrt-pow264.0%

      \[\leadsto \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) \]
    10. metadata-eval64.0%

      \[\leadsto \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) \]
    11. pow1/264.0%

      \[\leadsto \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) \]
    12. pow-flip68.1%

      \[\leadsto \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) \]
    13. +-commutative68.1%

      \[\leadsto \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) \]
    14. metadata-eval68.1%

      \[\leadsto \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. Applied egg-rr68.1%

    \[\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)} \]
  4. Step-by-step derivation
    1. fma-udef68.1%

      \[\leadsto \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)} \]
    2. distribute-lft1-in68.1%

      \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}} \]
    3. metadata-eval68.1%

      \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} \]
    4. mul0-lft68.1%

      \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \]
    5. +-rgt-identity68.1%

      \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
  5. Simplified68.1%

    \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
  6. Step-by-step derivation
    1. sqr-pow61.2%

      \[\leadsto \color{blue}{{x}^{\left(\frac{-0.5}{2}\right)} \cdot {x}^{\left(\frac{-0.5}{2}\right)}} - {\left(1 + x\right)}^{-0.5} \]
    2. fma-neg54.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left({x}^{\left(\frac{-0.5}{2}\right)}, {x}^{\left(\frac{-0.5}{2}\right)}, -{\left(1 + x\right)}^{-0.5}\right)} \]
    3. metadata-eval54.8%

      \[\leadsto \mathsf{fma}\left({x}^{\color{blue}{-0.25}}, {x}^{\left(\frac{-0.5}{2}\right)}, -{\left(1 + x\right)}^{-0.5}\right) \]
    4. metadata-eval54.8%

      \[\leadsto \mathsf{fma}\left({x}^{-0.25}, {x}^{\color{blue}{-0.25}}, -{\left(1 + x\right)}^{-0.5}\right) \]
    5. +-commutative54.8%

      \[\leadsto \mathsf{fma}\left({x}^{-0.25}, {x}^{-0.25}, -{\color{blue}{\left(x + 1\right)}}^{-0.5}\right) \]
  7. Applied egg-rr54.8%

    \[\leadsto \color{blue}{\mathsf{fma}\left({x}^{-0.25}, {x}^{-0.25}, -{\left(x + 1\right)}^{-0.5}\right)} \]
  8. Taylor expanded in x around inf 16.5%

    \[\leadsto \color{blue}{\sqrt{\frac{1}{x}} - {\left(\frac{1}{x}\right)}^{0.5}} \]
  9. Step-by-step derivation
    1. unpow1/216.5%

      \[\leadsto \sqrt{\frac{1}{x}} - \color{blue}{\sqrt{\frac{1}{x}}} \]
    2. +-inverses16.5%

      \[\leadsto \color{blue}{0} \]
  10. Simplified16.5%

    \[\leadsto \color{blue}{0} \]
  11. Final simplification16.5%

    \[\leadsto 0 \]

Developer target: 99.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}} \end{array} \]
(FPCore (x)
 :precision binary64
 (/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0))))))
double code(double x) {
	return 1.0 / (((x + 1.0) * sqrt(x)) + (x * sqrt((x + 1.0))));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 1.0d0 / (((x + 1.0d0) * sqrt(x)) + (x * sqrt((x + 1.0d0))))
end function
public static double code(double x) {
	return 1.0 / (((x + 1.0) * Math.sqrt(x)) + (x * Math.sqrt((x + 1.0))));
}
def code(x):
	return 1.0 / (((x + 1.0) * math.sqrt(x)) + (x * math.sqrt((x + 1.0))))
function code(x)
	return Float64(1.0 / Float64(Float64(Float64(x + 1.0) * sqrt(x)) + Float64(x * sqrt(Float64(x + 1.0)))))
end
function tmp = code(x)
	tmp = 1.0 / (((x + 1.0) * sqrt(x)) + (x * sqrt((x + 1.0))));
end
code[x_] := N[(1.0 / N[(N[(N[(x + 1.0), $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(x * N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}
\end{array}

Reproduce

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