2isqrt (example 3.6)

Percentage Accurate: 68.8% → 99.7%
Time: 10.3s
Alternatives: 13
Speedup: 1.9×

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 13 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: 68.8% 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.7% accurate, 0.4× speedup?

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

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

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


\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)))) < 4.0000000000000001e-8

    1. Initial program 38.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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/38.9%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{1}} \]
      4. div-sub38.9%

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

        \[\leadsto \left(\color{blue}{1} - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot \frac{{x}^{-0.5}}{1} \]
      6. /-rgt-identity38.9%

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

      \[\leadsto \color{blue}{\left(1 - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot {x}^{-0.5}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity38.9%

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

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

      \[\leadsto \left(1 - \color{blue}{1 \cdot \sqrt{\frac{x}{1 + x}}}\right) \cdot {x}^{-0.5} \]
    8. Step-by-step derivation
      1. *-lft-identity39.0%

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

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

      \[\leadsto \color{blue}{\left(\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)\right)} \cdot {x}^{-0.5} \]
    11. Step-by-step derivation
      1. +-commutative99.7%

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

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

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

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

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

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

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

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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/99.8%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{1}} \]
      4. div-sub99.8%

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

        \[\leadsto \left(\color{blue}{1} - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot \frac{{x}^{-0.5}}{1} \]
      6. /-rgt-identity99.8%

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

      \[\leadsto \color{blue}{\left(1 - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot {x}^{-0.5}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity99.8%

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

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

      \[\leadsto \left(1 - \color{blue}{1 \cdot \sqrt{\frac{x}{1 + x}}}\right) \cdot {x}^{-0.5} \]
    8. Step-by-step derivation
      1. *-lft-identity99.9%

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

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

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

        \[\leadsto \frac{\color{blue}{1} - \sqrt{\frac{x}{1 + x}} \cdot \sqrt{\frac{x}{1 + x}}}{1 + \sqrt{\frac{x}{1 + x}}} \cdot {x}^{-0.5} \]
      3. add-sqr-sqrt99.9%

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

      \[\leadsto \color{blue}{\frac{1 - \frac{x}{1 + x}}{1 + \sqrt{\frac{x}{1 + x}}}} \cdot {x}^{-0.5} \]
    12. Step-by-step derivation
      1. sub-neg99.9%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.7% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \frac{1 - t_0}{1 + \sqrt{t_0}}\\


\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)))) < 4.0000000000000001e-8

    1. Initial program 38.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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/38.9%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{1}} \]
      4. div-sub38.9%

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

        \[\leadsto \left(\color{blue}{1} - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot \frac{{x}^{-0.5}}{1} \]
      6. /-rgt-identity38.9%

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

      \[\leadsto \color{blue}{\left(1 - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot {x}^{-0.5}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity38.9%

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

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

      \[\leadsto \left(1 - \color{blue}{1 \cdot \sqrt{\frac{x}{1 + x}}}\right) \cdot {x}^{-0.5} \]
    8. Step-by-step derivation
      1. *-lft-identity39.0%

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

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

      \[\leadsto \color{blue}{\left(\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)\right)} \cdot {x}^{-0.5} \]
    11. Step-by-step derivation
      1. +-commutative99.7%

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

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

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

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

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

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

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

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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/99.8%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{1}} \]
      4. div-sub99.8%

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

        \[\leadsto \left(\color{blue}{1} - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot \frac{{x}^{-0.5}}{1} \]
      6. /-rgt-identity99.8%

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

      \[\leadsto \color{blue}{\left(1 - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot {x}^{-0.5}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity99.8%

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

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

      \[\leadsto \left(1 - \color{blue}{1 \cdot \sqrt{\frac{x}{1 + x}}}\right) \cdot {x}^{-0.5} \]
    8. Step-by-step derivation
      1. *-lft-identity99.9%

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

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

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

        \[\leadsto \frac{\color{blue}{1} - \sqrt{\frac{x}{1 + x}} \cdot \sqrt{\frac{x}{1 + x}}}{1 + \sqrt{\frac{x}{1 + x}}} \cdot {x}^{-0.5} \]
      3. add-sqr-sqrt99.9%

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

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

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

Alternative 3: 99.7% accurate, 0.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \frac{1 - t_0}{1 + \sqrt{t_0}}\\


\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)))) < 4.0000000000000001e-8

    1. Initial program 38.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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/38.9%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{1}} \]
      4. div-sub38.9%

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

        \[\leadsto \left(\color{blue}{1} - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot \frac{{x}^{-0.5}}{1} \]
      6. /-rgt-identity38.9%

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

      \[\leadsto \color{blue}{\left(1 - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot {x}^{-0.5}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity38.9%

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

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

      \[\leadsto \left(1 - \color{blue}{1 \cdot \sqrt{\frac{x}{1 + x}}}\right) \cdot {x}^{-0.5} \]
    8. Step-by-step derivation
      1. *-lft-identity39.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{0.3125}{{x}^{3}} + \left(\color{blue}{\left(0 - \frac{0.375}{x \cdot x}\right)} + 0.5 \cdot \frac{1}{x}\right)\right) \cdot {x}^{-0.5} \]
      11. associate--r-99.6%

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

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

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

        \[\leadsto \left(\frac{0.3125}{{x}^{3}} + \left(0 - \left(\color{blue}{\frac{\frac{0.375}{x}}{x}} - \frac{0.5}{x}\right)\right)\right) \cdot {x}^{-0.5} \]
      15. div-sub99.6%

        \[\leadsto \left(\frac{0.3125}{{x}^{3}} + \left(0 - \color{blue}{\frac{\frac{0.375}{x} - 0.5}{x}}\right)\right) \cdot {x}^{-0.5} \]
      16. sub0-neg99.6%

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

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

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

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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/99.8%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{1}} \]
      4. div-sub99.8%

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

        \[\leadsto \left(\color{blue}{1} - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot \frac{{x}^{-0.5}}{1} \]
      6. /-rgt-identity99.8%

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

      \[\leadsto \color{blue}{\left(1 - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot {x}^{-0.5}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity99.8%

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

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

      \[\leadsto \left(1 - \color{blue}{1 \cdot \sqrt{\frac{x}{1 + x}}}\right) \cdot {x}^{-0.5} \]
    8. Step-by-step derivation
      1. *-lft-identity99.9%

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

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

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

        \[\leadsto \frac{\color{blue}{1} - \sqrt{\frac{x}{1 + x}} \cdot \sqrt{\frac{x}{1 + x}}}{1 + \sqrt{\frac{x}{1 + x}}} \cdot {x}^{-0.5} \]
      3. add-sqr-sqrt99.9%

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

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

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

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

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


\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)))) < 4.0000000000000001e-8

    1. Initial program 38.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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/38.9%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{1}} \]
      4. div-sub38.9%

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

        \[\leadsto \left(\color{blue}{1} - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot \frac{{x}^{-0.5}}{1} \]
      6. /-rgt-identity38.9%

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

      \[\leadsto \color{blue}{\left(1 - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot {x}^{-0.5}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity38.9%

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

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

      \[\leadsto \left(1 - \color{blue}{1 \cdot \sqrt{\frac{x}{1 + x}}}\right) \cdot {x}^{-0.5} \]
    8. Step-by-step derivation
      1. *-lft-identity39.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{0.3125}{{x}^{3}} + \left(\color{blue}{\left(0 - \frac{0.375}{x \cdot x}\right)} + 0.5 \cdot \frac{1}{x}\right)\right) \cdot {x}^{-0.5} \]
      11. associate--r-99.6%

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

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

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

        \[\leadsto \left(\frac{0.3125}{{x}^{3}} + \left(0 - \left(\color{blue}{\frac{\frac{0.375}{x}}{x}} - \frac{0.5}{x}\right)\right)\right) \cdot {x}^{-0.5} \]
      15. div-sub99.6%

        \[\leadsto \left(\frac{0.3125}{{x}^{3}} + \left(0 - \color{blue}{\frac{\frac{0.375}{x} - 0.5}{x}}\right)\right) \cdot {x}^{-0.5} \]
      16. sub0-neg99.6%

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

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

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

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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/99.8%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{1}} \]
      4. div-sub99.8%

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

        \[\leadsto \left(\color{blue}{1} - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot \frac{{x}^{-0.5}}{1} \]
      6. /-rgt-identity99.8%

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

      \[\leadsto \color{blue}{\left(1 - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot {x}^{-0.5}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity99.8%

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

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

      \[\leadsto \left(1 - \color{blue}{1 \cdot \sqrt{\frac{x}{1 + x}}}\right) \cdot {x}^{-0.5} \]
    8. Step-by-step derivation
      1. *-lft-identity99.9%

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

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

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

Alternative 5: 99.6% accurate, 0.5× speedup?

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

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

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


\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)))) < 1.00000000000000004e-10

    1. Initial program 37.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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/37.8%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{1}} \]
      4. div-sub37.8%

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

        \[\leadsto \left(\color{blue}{1} - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot \frac{{x}^{-0.5}}{1} \]
      6. /-rgt-identity37.8%

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

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

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

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

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

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

        \[\leadsto \left(1 - \left(1 + \left(\frac{0.375}{\color{blue}{x \cdot x}} - 0.5 \cdot \frac{1}{x}\right)\right)\right) \cdot {x}^{-0.5} \]
      5. associate-*r/37.8%

        \[\leadsto \left(1 - \left(1 + \left(\frac{0.375}{x \cdot x} - \color{blue}{\frac{0.5 \cdot 1}{x}}\right)\right)\right) \cdot {x}^{-0.5} \]
      6. metadata-eval37.8%

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

      \[\leadsto \left(1 - \color{blue}{\left(1 + \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)}\right) \cdot {x}^{-0.5} \]
    9. Step-by-step derivation
      1. expm1-log1p-u37.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(1 - \left(1 + \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)\right) \cdot {x}^{-0.5}\right)\right)} \]
      2. expm1-udef37.2%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(1 - \left(1 + \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)\right) \cdot {x}^{-0.5}\right)} - 1} \]
      3. *-commutative37.2%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{{x}^{-0.5} \cdot \left(1 - \left(1 + \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)\right)}\right)} - 1 \]
      4. associate--r+37.2%

        \[\leadsto e^{\mathsf{log1p}\left({x}^{-0.5} \cdot \color{blue}{\left(\left(1 - 1\right) - \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)}\right)} - 1 \]
      5. metadata-eval37.2%

        \[\leadsto e^{\mathsf{log1p}\left({x}^{-0.5} \cdot \left(\color{blue}{0} - \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)\right)} - 1 \]
      6. associate-/r*37.2%

        \[\leadsto e^{\mathsf{log1p}\left({x}^{-0.5} \cdot \left(0 - \left(\color{blue}{\frac{\frac{0.375}{x}}{x}} - \frac{0.5}{x}\right)\right)\right)} - 1 \]
      7. sub-div37.2%

        \[\leadsto e^{\mathsf{log1p}\left({x}^{-0.5} \cdot \left(0 - \color{blue}{\frac{\frac{0.375}{x} - 0.5}{x}}\right)\right)} - 1 \]
    10. Applied egg-rr37.2%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left({x}^{-0.5} \cdot \left(0 - \frac{\frac{0.375}{x} - 0.5}{x}\right)\right)} - 1} \]
    11. Step-by-step derivation
      1. expm1-def99.6%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{-0.5} \cdot \left(0 - \frac{\frac{0.375}{x} - 0.5}{x}\right)\right)\right)} \]
      2. expm1-log1p99.6%

        \[\leadsto \color{blue}{{x}^{-0.5} \cdot \left(0 - \frac{\frac{0.375}{x} - 0.5}{x}\right)} \]
      3. sub0-neg99.6%

        \[\leadsto {x}^{-0.5} \cdot \color{blue}{\left(-\frac{\frac{0.375}{x} - 0.5}{x}\right)} \]
      4. distribute-neg-frac99.6%

        \[\leadsto {x}^{-0.5} \cdot \color{blue}{\frac{-\left(\frac{0.375}{x} - 0.5\right)}{x}} \]
      5. sub-neg99.6%

        \[\leadsto {x}^{-0.5} \cdot \frac{-\color{blue}{\left(\frac{0.375}{x} + \left(-0.5\right)\right)}}{x} \]
      6. metadata-eval99.6%

        \[\leadsto {x}^{-0.5} \cdot \frac{-\left(\frac{0.375}{x} + \color{blue}{-0.5}\right)}{x} \]
      7. +-commutative99.6%

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

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

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

    1. Initial program 98.7%

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

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. div-inv98.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-identity98.7%

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

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

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

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{\color{blue}{1 \cdot 1}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      7. frac-times98.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-inv98.7%

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

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

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

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

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \frac{{x}^{-0.5}}{\sqrt{\color{blue}{1 + x}}} \]
    3. Applied egg-rr99.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/99.1%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{1}} \]
      4. div-sub99.0%

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

        \[\leadsto \left(\color{blue}{1} - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot \frac{{x}^{-0.5}}{1} \]
      6. /-rgt-identity99.0%

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

      \[\leadsto \color{blue}{\left(1 - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot {x}^{-0.5}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity99.0%

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

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

      \[\leadsto \left(1 - \color{blue}{1 \cdot \sqrt{\frac{x}{1 + x}}}\right) \cdot {x}^{-0.5} \]
    8. Step-by-step derivation
      1. *-lft-identity99.2%

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

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

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

Alternative 6: 99.6% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 5 \cdot 10^{-9}:\\ \;\;\;\;\frac{\left(--0.5\right) - \frac{0.375}{x}}{x} \cdot {x}^{-0.5}\\ \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)))) 5e-9)
   (* (/ (- (- -0.5) (/ 0.375 x)) x) (pow x -0.5))
   (- (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)))) <= 5e-9) {
		tmp = ((-(-0.5) - (0.375 / x)) / x) * pow(x, -0.5);
	} 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)))) <= 5d-9) then
        tmp = ((-(-0.5d0) - (0.375d0 / x)) / x) * (x ** (-0.5d0))
    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)))) <= 5e-9) {
		tmp = ((-(-0.5) - (0.375 / x)) / x) * Math.pow(x, -0.5);
	} 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)))) <= 5e-9:
		tmp = ((-(-0.5) - (0.375 / x)) / x) * math.pow(x, -0.5)
	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)))) <= 5e-9)
		tmp = Float64(Float64(Float64(Float64(-(-0.5)) - Float64(0.375 / x)) / x) * (x ^ -0.5));
	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)))) <= 5e-9)
		tmp = ((-(-0.5) - (0.375 / x)) / x) * (x ^ -0.5);
	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], 5e-9], N[(N[(N[((--0.5) - N[(0.375 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * N[Power[x, -0.5], $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 5 \cdot 10^{-9}:\\
\;\;\;\;\frac{\left(--0.5\right) - \frac{0.375}{x}}{x} \cdot {x}^{-0.5}\\

\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)))) < 5.0000000000000001e-9

    1. Initial program 38.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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/38.4%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{1}} \]
      4. div-sub38.3%

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

        \[\leadsto \left(\color{blue}{1} - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot \frac{{x}^{-0.5}}{1} \]
      6. /-rgt-identity38.3%

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

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

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

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

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

        \[\leadsto \left(1 - \left(1 + \left(\frac{\color{blue}{0.375}}{{x}^{2}} - 0.5 \cdot \frac{1}{x}\right)\right)\right) \cdot {x}^{-0.5} \]
      4. unpow238.4%

        \[\leadsto \left(1 - \left(1 + \left(\frac{0.375}{\color{blue}{x \cdot x}} - 0.5 \cdot \frac{1}{x}\right)\right)\right) \cdot {x}^{-0.5} \]
      5. associate-*r/38.4%

        \[\leadsto \left(1 - \left(1 + \left(\frac{0.375}{x \cdot x} - \color{blue}{\frac{0.5 \cdot 1}{x}}\right)\right)\right) \cdot {x}^{-0.5} \]
      6. metadata-eval38.4%

        \[\leadsto \left(1 - \left(1 + \left(\frac{0.375}{x \cdot x} - \frac{\color{blue}{0.5}}{x}\right)\right)\right) \cdot {x}^{-0.5} \]
    8. Simplified38.4%

      \[\leadsto \left(1 - \color{blue}{\left(1 + \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)}\right) \cdot {x}^{-0.5} \]
    9. Step-by-step derivation
      1. expm1-log1p-u38.4%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(1 - \left(1 + \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)\right) \cdot {x}^{-0.5}\right)\right)} \]
      2. expm1-udef37.5%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(1 - \left(1 + \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)\right) \cdot {x}^{-0.5}\right)} - 1} \]
      3. *-commutative37.5%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{{x}^{-0.5} \cdot \left(1 - \left(1 + \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)\right)}\right)} - 1 \]
      4. associate--r+37.5%

        \[\leadsto e^{\mathsf{log1p}\left({x}^{-0.5} \cdot \color{blue}{\left(\left(1 - 1\right) - \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)}\right)} - 1 \]
      5. metadata-eval37.5%

        \[\leadsto e^{\mathsf{log1p}\left({x}^{-0.5} \cdot \left(\color{blue}{0} - \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)\right)} - 1 \]
      6. associate-/r*37.5%

        \[\leadsto e^{\mathsf{log1p}\left({x}^{-0.5} \cdot \left(0 - \left(\color{blue}{\frac{\frac{0.375}{x}}{x}} - \frac{0.5}{x}\right)\right)\right)} - 1 \]
      7. sub-div37.5%

        \[\leadsto e^{\mathsf{log1p}\left({x}^{-0.5} \cdot \left(0 - \color{blue}{\frac{\frac{0.375}{x} - 0.5}{x}}\right)\right)} - 1 \]
    10. Applied egg-rr37.5%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left({x}^{-0.5} \cdot \left(0 - \frac{\frac{0.375}{x} - 0.5}{x}\right)\right)} - 1} \]
    11. Step-by-step derivation
      1. expm1-def99.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{-0.5} \cdot \left(0 - \frac{\frac{0.375}{x} - 0.5}{x}\right)\right)\right)} \]
      2. expm1-log1p99.2%

        \[\leadsto \color{blue}{{x}^{-0.5} \cdot \left(0 - \frac{\frac{0.375}{x} - 0.5}{x}\right)} \]
      3. sub0-neg99.2%

        \[\leadsto {x}^{-0.5} \cdot \color{blue}{\left(-\frac{\frac{0.375}{x} - 0.5}{x}\right)} \]
      4. distribute-neg-frac99.2%

        \[\leadsto {x}^{-0.5} \cdot \color{blue}{\frac{-\left(\frac{0.375}{x} - 0.5\right)}{x}} \]
      5. sub-neg99.2%

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

        \[\leadsto {x}^{-0.5} \cdot \frac{-\left(\frac{0.375}{x} + \color{blue}{-0.5}\right)}{x} \]
      7. +-commutative99.2%

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

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

    if 5.0000000000000001e-9 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1))))

    1. Initial program 99.1%

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

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

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

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.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-identity99.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-neg99.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-identity99.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-pow99.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-pow299.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 98.9% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.1:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\

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


\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. inv-pow99.6%

        \[\leadsto \color{blue}{{\left(\sqrt{x}\right)}^{-1}} - \frac{1}{\sqrt{x + 1}} \]
      2. pow1/299.6%

        \[\leadsto {\color{blue}{\left({x}^{0.5}\right)}}^{-1} - \frac{1}{\sqrt{x + 1}} \]
      3. pow-pow100.0%

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

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

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

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

      \[\leadsto \color{blue}{e^{\log x \cdot -0.5}} - \frac{1}{\sqrt{x + 1}} \]
    4. Taylor expanded in x around 0 98.7%

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

    if 1.1000000000000001 < x

    1. Initial program 40.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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/40.2%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{1}} \]
      4. div-sub40.2%

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

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

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

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

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

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

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

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

        \[\leadsto \left(1 - \left(1 + \left(\frac{0.375}{\color{blue}{x \cdot x}} - 0.5 \cdot \frac{1}{x}\right)\right)\right) \cdot {x}^{-0.5} \]
      5. associate-*r/38.8%

        \[\leadsto \left(1 - \left(1 + \left(\frac{0.375}{x \cdot x} - \color{blue}{\frac{0.5 \cdot 1}{x}}\right)\right)\right) \cdot {x}^{-0.5} \]
      6. metadata-eval38.8%

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

      \[\leadsto \left(1 - \color{blue}{\left(1 + \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)}\right) \cdot {x}^{-0.5} \]
    9. Step-by-step derivation
      1. expm1-log1p-u38.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\left(1 - \left(1 + \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)\right) \cdot {x}^{-0.5}\right)\right)} \]
      2. expm1-udef37.8%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\left(1 - \left(1 + \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)\right) \cdot {x}^{-0.5}\right)} - 1} \]
      3. *-commutative37.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{{x}^{-0.5} \cdot \left(1 - \left(1 + \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)\right)}\right)} - 1 \]
      4. associate--r+37.8%

        \[\leadsto e^{\mathsf{log1p}\left({x}^{-0.5} \cdot \color{blue}{\left(\left(1 - 1\right) - \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)}\right)} - 1 \]
      5. metadata-eval37.8%

        \[\leadsto e^{\mathsf{log1p}\left({x}^{-0.5} \cdot \left(\color{blue}{0} - \left(\frac{0.375}{x \cdot x} - \frac{0.5}{x}\right)\right)\right)} - 1 \]
      6. associate-/r*37.8%

        \[\leadsto e^{\mathsf{log1p}\left({x}^{-0.5} \cdot \left(0 - \left(\color{blue}{\frac{\frac{0.375}{x}}{x}} - \frac{0.5}{x}\right)\right)\right)} - 1 \]
      7. sub-div37.8%

        \[\leadsto e^{\mathsf{log1p}\left({x}^{-0.5} \cdot \left(0 - \color{blue}{\frac{\frac{0.375}{x} - 0.5}{x}}\right)\right)} - 1 \]
    10. Applied egg-rr37.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left({x}^{-0.5} \cdot \left(0 - \frac{\frac{0.375}{x} - 0.5}{x}\right)\right)} - 1} \]
    11. Step-by-step derivation
      1. expm1-def97.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{-0.5} \cdot \left(0 - \frac{\frac{0.375}{x} - 0.5}{x}\right)\right)\right)} \]
      2. expm1-log1p97.2%

        \[\leadsto \color{blue}{{x}^{-0.5} \cdot \left(0 - \frac{\frac{0.375}{x} - 0.5}{x}\right)} \]
      3. sub0-neg97.2%

        \[\leadsto {x}^{-0.5} \cdot \color{blue}{\left(-\frac{\frac{0.375}{x} - 0.5}{x}\right)} \]
      4. distribute-neg-frac97.2%

        \[\leadsto {x}^{-0.5} \cdot \color{blue}{\frac{-\left(\frac{0.375}{x} - 0.5\right)}{x}} \]
      5. sub-neg97.2%

        \[\leadsto {x}^{-0.5} \cdot \frac{-\color{blue}{\left(\frac{0.375}{x} + \left(-0.5\right)\right)}}{x} \]
      6. metadata-eval97.2%

        \[\leadsto {x}^{-0.5} \cdot \frac{-\left(\frac{0.375}{x} + \color{blue}{-0.5}\right)}{x} \]
      7. +-commutative97.2%

        \[\leadsto {x}^{-0.5} \cdot \frac{-\color{blue}{\left(-0.5 + \frac{0.375}{x}\right)}}{x} \]
    12. Simplified97.2%

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

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

Alternative 8: 98.3% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} \cdot \frac{0.5}{x}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 1.0)
   (+ (+ (pow x -0.5) (* x 0.5)) -1.0)
   (* (pow x -0.5) (/ 0.5 x))))
double code(double x) {
	double tmp;
	if (x <= 1.0) {
		tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
	} else {
		tmp = pow(x, -0.5) * (0.5 / 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)) + (x * 0.5d0)) + (-1.0d0)
    else
        tmp = (x ** (-0.5d0)) * (0.5d0 / 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) + (x * 0.5)) + -1.0;
	} else {
		tmp = Math.pow(x, -0.5) * (0.5 / x);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 1.0:
		tmp = (math.pow(x, -0.5) + (x * 0.5)) + -1.0
	else:
		tmp = math.pow(x, -0.5) * (0.5 / x)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 1.0)
		tmp = Float64(Float64((x ^ -0.5) + Float64(x * 0.5)) + -1.0);
	else
		tmp = Float64((x ^ -0.5) * Float64(0.5 / x));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 1.0)
		tmp = ((x ^ -0.5) + (x * 0.5)) + -1.0;
	else
		tmp = (x ^ -0.5) * (0.5 / x);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 1.0], N[(N[(N[Power[x, -0.5], $MachinePrecision] + N[(x * 0.5), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] * N[(0.5 / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\left({x}^{-0.5} + x \cdot 0.5\right) + -1\\

\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \frac{0.5}{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. inv-pow99.6%

        \[\leadsto \color{blue}{{\left(\sqrt{x}\right)}^{-1}} - \frac{1}{\sqrt{x + 1}} \]
      2. pow1/299.6%

        \[\leadsto {\color{blue}{\left({x}^{0.5}\right)}}^{-1} - \frac{1}{\sqrt{x + 1}} \]
      3. pow-pow100.0%

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

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

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

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

      \[\leadsto \color{blue}{e^{\log x \cdot -0.5}} - \frac{1}{\sqrt{x + 1}} \]
    4. Taylor expanded in x around 0 98.7%

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

    if 1 < x

    1. Initial program 40.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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/40.2%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{1}} \]
      4. div-sub40.2%

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

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

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

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

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

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

Alternative 9: 98.0% accurate, 1.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \frac{0.5}{x}\\


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

    1. Initial program 99.6%

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

        \[\leadsto \color{blue}{{\left(\sqrt{x}\right)}^{-1}} - \frac{1}{\sqrt{x + 1}} \]
      2. pow1/299.6%

        \[\leadsto {\color{blue}{\left({x}^{0.5}\right)}}^{-1} - \frac{1}{\sqrt{x + 1}} \]
      3. pow-pow100.0%

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

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

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

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

      \[\leadsto \color{blue}{e^{\log x \cdot -0.5}} - \frac{1}{\sqrt{x + 1}} \]
    4. Taylor expanded in x around 0 98.2%

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

    if 0.67000000000000004 < x

    1. Initial program 40.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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/40.2%

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{1}} \]
      4. div-sub40.2%

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.5}{x}} \cdot {x}^{-0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.0%

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

Alternative 10: 67.3% accurate, 2.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{\left(x \cdot x\right)}^{-0.25}\\


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

    1. Initial program 99.6%

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

        \[\leadsto \color{blue}{{\left(\sqrt{x}\right)}^{-1}} - \frac{1}{\sqrt{x + 1}} \]
      2. pow1/299.6%

        \[\leadsto {\color{blue}{\left({x}^{0.5}\right)}}^{-1} - \frac{1}{\sqrt{x + 1}} \]
      3. pow-pow100.0%

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

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

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

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

      \[\leadsto \color{blue}{e^{\log x \cdot -0.5}} - \frac{1}{\sqrt{x + 1}} \]
    4. Taylor expanded in x around 0 98.2%

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

    if 0.80000000000000004 < x

    1. Initial program 40.2%

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

        \[\leadsto \color{blue}{{\left(\sqrt{x}\right)}^{-1}} - \frac{1}{\sqrt{x + 1}} \]
      2. pow1/240.2%

        \[\leadsto {\color{blue}{\left({x}^{0.5}\right)}}^{-1} - \frac{1}{\sqrt{x + 1}} \]
      3. pow-pow29.2%

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

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

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

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

      \[\leadsto \color{blue}{e^{\log x \cdot -0.5}} - \frac{1}{\sqrt{x + 1}} \]
    4. Taylor expanded in x around inf 5.8%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
    5. Step-by-step derivation
      1. inv-pow5.8%

        \[\leadsto \sqrt{\color{blue}{{x}^{-1}}} \]
      2. sqrt-pow15.8%

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

        \[\leadsto {x}^{\color{blue}{-0.5}} \]
      4. sqr-pow5.8%

        \[\leadsto \color{blue}{{x}^{\left(\frac{-0.5}{2}\right)} \cdot {x}^{\left(\frac{-0.5}{2}\right)}} \]
      5. pow-prod-down36.5%

        \[\leadsto \color{blue}{{\left(x \cdot x\right)}^{\left(\frac{-0.5}{2}\right)}} \]
      6. metadata-eval36.5%

        \[\leadsto {\left(x \cdot x\right)}^{\color{blue}{-0.25}} \]
    6. Applied egg-rr36.5%

      \[\leadsto \color{blue}{{\left(x \cdot x\right)}^{-0.25}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.8:\\ \;\;\;\;{x}^{-0.5} + -1\\ \mathbf{else}:\\ \;\;\;\;{\left(x \cdot x\right)}^{-0.25}\\ \end{array} \]

Alternative 11: 49.7% accurate, 2.0× speedup?

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

\\
\sqrt{\frac{1}{x}}
\end{array}
Derivation
  1. Initial program 69.4%

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

      \[\leadsto \color{blue}{{\left(\sqrt{x}\right)}^{-1}} - \frac{1}{\sqrt{x + 1}} \]
    2. pow1/269.4%

      \[\leadsto {\color{blue}{\left({x}^{0.5}\right)}}^{-1} - \frac{1}{\sqrt{x + 1}} \]
    3. pow-pow64.0%

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

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

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

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

    \[\leadsto \color{blue}{e^{\log x \cdot -0.5}} - \frac{1}{\sqrt{x + 1}} \]
  4. Taylor expanded in x around inf 50.1%

    \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
  5. Final simplification50.1%

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

Alternative 12: 49.8% accurate, 2.0× speedup?

\[\begin{array}{l} \\ {x}^{-0.5} \end{array} \]
(FPCore (x) :precision binary64 (pow x -0.5))
double code(double x) {
	return pow(x, -0.5);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = x ** (-0.5d0)
end function
public static double code(double x) {
	return Math.pow(x, -0.5);
}
def code(x):
	return math.pow(x, -0.5)
function code(x)
	return x ^ -0.5
end
function tmp = code(x)
	tmp = x ^ -0.5;
end
code[x_] := N[Power[x, -0.5], $MachinePrecision]
\begin{array}{l}

\\
{x}^{-0.5}
\end{array}
Derivation
  1. Initial program 69.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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/69.6%

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{1 + x}} \cdot \frac{{x}^{-0.5}}{1}} \]
    4. div-sub69.6%

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

      \[\leadsto \left(\color{blue}{1} - \frac{\sqrt{x}}{\sqrt{1 + x}}\right) \cdot \frac{{x}^{-0.5}}{1} \]
    6. /-rgt-identity69.6%

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

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

    \[\leadsto \color{blue}{1} \cdot {x}^{-0.5} \]
  7. Final simplification50.2%

    \[\leadsto {x}^{-0.5} \]

Alternative 13: 2.3% accurate, 41.8× speedup?

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

\\
x \cdot 0.5 + -1
\end{array}
Derivation
  1. Initial program 69.4%

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

      \[\leadsto \color{blue}{{\left(\sqrt{x}\right)}^{-1}} - \frac{1}{\sqrt{x + 1}} \]
    2. pow1/269.4%

      \[\leadsto {\color{blue}{\left({x}^{0.5}\right)}}^{-1} - \frac{1}{\sqrt{x + 1}} \]
    3. pow-pow64.0%

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

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

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

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

    \[\leadsto \color{blue}{e^{\log x \cdot -0.5}} - \frac{1}{\sqrt{x + 1}} \]
  4. Taylor expanded in x around 0 50.4%

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

    \[\leadsto \color{blue}{0.5 \cdot x} - 1 \]
  6. Final simplification2.5%

    \[\leadsto x \cdot 0.5 + -1 \]

Developer target: 99.0% 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 2023230 
(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)))))