2isqrt (example 3.6)

Percentage Accurate: 69.1% → 99.7%
Time: 17.8s
Alternatives: 15
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 15 alternatives:

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

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

\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)))) < 1.9999999999999999e-7

    1. Initial program 45.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\left(1 + \left(x - x\right)\right) \cdot \frac{1}{\color{blue}{\left(0.5 + \left(x + 0.0625 \cdot \frac{1}{{x}^{2}}\right)\right) - 0.125 \cdot \frac{1}{x}}}}{\sqrt{x} + \sqrt{1 + x}} \]
    5. Step-by-step derivation
      1. associate--l+99.6%

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

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

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

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

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

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

    if 1.9999999999999999e-7 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1))))

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. expm1-log1p-u99.6%

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)\right)} \]
      2. expm1-udef99.6%

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)} - 1\right)} \]
      3. associate--r-99.6%

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

        \[\leadsto \left(\frac{1}{\color{blue}{{x}^{0.5}}} - e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)}\right) + 1 \]
      5. pow-flip99.9%

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

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)}\right) + 1 \]
      7. pow1/299.9%

        \[\leadsto \left({x}^{-0.5} - e^{\mathsf{log1p}\left(\frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right)}\right) + 1 \]
      8. pow-flip99.9%

        \[\leadsto \left({x}^{-0.5} - e^{\mathsf{log1p}\left(\color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right)}\right) + 1 \]
      9. +-commutative99.9%

        \[\leadsto \left({x}^{-0.5} - e^{\mathsf{log1p}\left({\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right)}\right) + 1 \]
      10. metadata-eval99.9%

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

      \[\leadsto \color{blue}{\left({x}^{-0.5} - e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)}\right) + 1} \]
    4. Step-by-step derivation
      1. associate-+l-99.9%

        \[\leadsto \color{blue}{{x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} \]
      2. expm1-def99.9%

        \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
      3. expm1-log1p99.9%

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

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

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

Alternative 2: 99.7% accurate, 0.5× speedup?

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

\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)))) < 1.9999999999999999e-7

    1. Initial program 45.0%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\left(1 + \left(x - x\right)\right) \cdot \frac{1}{\color{blue}{\left(0.5 + x\right) - 0.125 \cdot \frac{1}{x}}}}{\sqrt{x} + \sqrt{1 + x}} \]
    5. Step-by-step derivation
      1. cancel-sign-sub-inv99.6%

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

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

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

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

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

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

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

    if 1.9999999999999999e-7 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1))))

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. expm1-log1p-u99.6%

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)\right)} \]
      2. expm1-udef99.6%

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)} - 1\right)} \]
      3. associate--r-99.6%

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

        \[\leadsto \left(\frac{1}{\color{blue}{{x}^{0.5}}} - e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)}\right) + 1 \]
      5. pow-flip99.9%

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

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)}\right) + 1 \]
      7. pow1/299.9%

        \[\leadsto \left({x}^{-0.5} - e^{\mathsf{log1p}\left(\frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right)}\right) + 1 \]
      8. pow-flip99.9%

        \[\leadsto \left({x}^{-0.5} - e^{\mathsf{log1p}\left(\color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right)}\right) + 1 \]
      9. +-commutative99.9%

        \[\leadsto \left({x}^{-0.5} - e^{\mathsf{log1p}\left({\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right)}\right) + 1 \]
      10. metadata-eval99.9%

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

      \[\leadsto \color{blue}{\left({x}^{-0.5} - e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)}\right) + 1} \]
    4. Step-by-step derivation
      1. associate-+l-99.9%

        \[\leadsto \color{blue}{{x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} \]
      2. expm1-def99.9%

        \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
      3. expm1-log1p99.9%

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

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

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

Alternative 3: 99.5% accurate, 0.5× speedup?

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

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


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

    1. Initial program 44.7%

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      6. metadata-eval45.8%

        \[\leadsto \frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}} \cdot \frac{\color{blue}{1 \cdot 1}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      7. frac-times45.8%

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

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

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

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

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

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

    if 9.99999999999999999e-15 < (-.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. expm1-log1p-u99.4%

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)\right)} \]
      2. expm1-udef99.3%

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)} - 1\right)} \]
      3. associate--r-99.3%

        \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{x}} - e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)}\right) + 1} \]
      4. pow1/299.3%

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

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

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)}\right) + 1 \]
      7. pow1/299.7%

        \[\leadsto \left({x}^{-0.5} - e^{\mathsf{log1p}\left(\frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right)}\right) + 1 \]
      8. pow-flip99.7%

        \[\leadsto \left({x}^{-0.5} - e^{\mathsf{log1p}\left(\color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right)}\right) + 1 \]
      9. +-commutative99.7%

        \[\leadsto \left({x}^{-0.5} - e^{\mathsf{log1p}\left({\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right)}\right) + 1 \]
      10. metadata-eval99.7%

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

      \[\leadsto \color{blue}{\left({x}^{-0.5} - e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)}\right) + 1} \]
    4. Step-by-step derivation
      1. associate-+l-99.7%

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

        \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
      3. expm1-log1p99.8%

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

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

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

Alternative 4: 99.6% accurate, 0.5× speedup?

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

\\
\frac{\left(1 + \left(x - x\right)\right) \cdot \left({\left(1 + x\right)}^{-0.5} \cdot {x}^{-0.5}\right)}{\sqrt{x} + \sqrt{1 + x}}
\end{array}
Derivation
  1. Initial program 74.9%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\left(1 + \left(x - x\right)\right) \cdot \frac{1}{\sqrt{x + {x}^{2}}}}{\sqrt{x} + \sqrt{1 + x}}} \]
  4. Step-by-step derivation
    1. metadata-eval92.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 99.0% accurate, 0.5× speedup?

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

\\
\frac{1}{\left(\sqrt{x} + \sqrt{1 + x}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)}
\end{array}
Derivation
  1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\left(1 + \left(x - x\right)\right) \cdot \frac{1}{\sqrt{x + {x}^{2}}}}{\sqrt{x} + \sqrt{1 + x}}\right)} - 1} \]
  5. Applied egg-rr70.7%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{\left(\sqrt{x} + \sqrt{x + 1}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)}\right)} - 1} \]
  6. Step-by-step derivation
    1. expm1-def95.1%

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

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

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

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

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

Alternative 6: 99.6% accurate, 0.5× speedup?

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

\\
\frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{\mathsf{hypot}\left(x, \sqrt{x}\right)}
\end{array}
Derivation
  1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\left(1 + \left(x - x\right)\right) \cdot \frac{1}{\sqrt{x + {x}^{2}}}}{\sqrt{x} + \sqrt{1 + x}}\right)} - 1} \]
  5. Applied egg-rr70.7%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{\left(\sqrt{x} + \sqrt{x + 1}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)}\right)} - 1} \]
  6. Step-by-step derivation
    1. expm1-def95.1%

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

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

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

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

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

Alternative 7: 99.4% accurate, 0.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{x}\\


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

    1. Initial program 86.0%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. add-sqr-sqrt85.5%

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

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

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

        \[\leadsto \sqrt{\frac{\color{blue}{1}}{\sqrt{x} \cdot \sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      5. add-sqr-sqrt86.2%

        \[\leadsto \sqrt{\frac{1}{\color{blue}{x}}} - \frac{1}{\sqrt{x + 1}} \]
    3. Applied egg-rr86.2%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} - \frac{1}{\sqrt{x + 1}} \]
    4. Applied egg-rr85.8%

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

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

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

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

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

        \[\leadsto \frac{\frac{\frac{\left(1 + x\right) - \color{blue}{x}}{x}}{1 + x}}{{x}^{-0.5} + {\left(x + 1\right)}^{-0.5}} \]
      6. associate-+r-99.2%

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

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

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

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

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

    if 5.0000000000000004e90 < x

    1. Initial program 54.3%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      6. metadata-eval54.3%

        \[\leadsto \frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}} \cdot \frac{\color{blue}{1 \cdot 1}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      7. frac-times54.3%

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

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

      \[\leadsto \color{blue}{\frac{\left(1 + \left(x - x\right)\right) \cdot \frac{1}{\sqrt{x + {x}^{2}}}}{\sqrt{x} + \sqrt{1 + x}}} \]
    4. Step-by-step derivation
      1. expm1-log1p-u78.3%

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\left(1 + \left(x - x\right)\right) \cdot \frac{1}{\sqrt{x + {x}^{2}}}}{\sqrt{x} + \sqrt{1 + x}}\right)} - 1} \]
    5. Applied egg-rr54.3%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{\left(\sqrt{x} + \sqrt{x + 1}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)}\right)} - 1} \]
    6. Step-by-step derivation
      1. expm1-def97.5%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\left(\sqrt{x} + \sqrt{x + 1}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)}\right)\right)} \]
      2. expm1-log1p97.5%

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x} + \sqrt{x + 1}}}{\mathsf{hypot}\left(x, \sqrt{x}\right)}} \]
    8. Taylor expanded in x around inf 99.8%

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

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

Alternative 8: 99.3% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{x}\\


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

    1. Initial program 99.4%

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

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)\right)} \]
      2. expm1-udef99.3%

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)} - 1\right)} \]
      3. associate--r-99.3%

        \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{x}} - e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)}\right) + 1} \]
      4. pow1/299.3%

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

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

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)}\right) + 1 \]
      7. pow1/299.7%

        \[\leadsto \left({x}^{-0.5} - e^{\mathsf{log1p}\left(\frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right)}\right) + 1 \]
      8. pow-flip99.7%

        \[\leadsto \left({x}^{-0.5} - e^{\mathsf{log1p}\left(\color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right)}\right) + 1 \]
      9. +-commutative99.7%

        \[\leadsto \left({x}^{-0.5} - e^{\mathsf{log1p}\left({\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right)}\right) + 1 \]
      10. metadata-eval99.7%

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

      \[\leadsto \color{blue}{\left({x}^{-0.5} - e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)}\right) + 1} \]
    4. Step-by-step derivation
      1. associate-+l-99.7%

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

        \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
      3. expm1-log1p99.8%

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

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

    if 6.5e7 < x

    1. Initial program 44.7%

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      6. metadata-eval45.8%

        \[\leadsto \frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}} \cdot \frac{\color{blue}{1 \cdot 1}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      7. frac-times45.8%

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

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

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

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\left(1 + \left(x - x\right)\right) \cdot \frac{1}{\sqrt{x + {x}^{2}}}}{\sqrt{x} + \sqrt{1 + x}}\right)} - 1} \]
    5. Applied egg-rr43.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{\left(\sqrt{x} + \sqrt{x + 1}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)}\right)} - 1} \]
    6. Step-by-step derivation
      1. expm1-def97.9%

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x} + \sqrt{x + 1}}}{\mathsf{hypot}\left(x, \sqrt{x}\right)}} \]
    8. Taylor expanded in x around inf 98.8%

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

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

Alternative 9: 98.8% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{0.5}{{x}^{1.5}}\\


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

    1. Initial program 99.4%

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

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)\right)} \]
      2. expm1-udef99.3%

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)} - 1\right)} \]
      3. associate--r-99.3%

        \[\leadsto \color{blue}{\left(\frac{1}{\sqrt{x}} - e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)}\right) + 1} \]
      4. pow1/299.3%

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

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

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1}}\right)}\right) + 1 \]
      7. pow1/299.7%

        \[\leadsto \left({x}^{-0.5} - e^{\mathsf{log1p}\left(\frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right)}\right) + 1 \]
      8. pow-flip99.7%

        \[\leadsto \left({x}^{-0.5} - e^{\mathsf{log1p}\left(\color{blue}{{\left(x + 1\right)}^{\left(-0.5\right)}}\right)}\right) + 1 \]
      9. +-commutative99.7%

        \[\leadsto \left({x}^{-0.5} - e^{\mathsf{log1p}\left({\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}\right)}\right) + 1 \]
      10. metadata-eval99.7%

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

      \[\leadsto \color{blue}{\left({x}^{-0.5} - e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)}\right) + 1} \]
    4. Step-by-step derivation
      1. associate-+l-99.7%

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

        \[\leadsto {x}^{-0.5} - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)\right)} \]
      3. expm1-log1p99.8%

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

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

    if 1e8 < x

    1. Initial program 44.7%

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}}} \]
      3. *-un-lft-identity44.8%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}}}} \]
      5. flip--44.7%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}}}} \]
      6. pow1/244.7%

        \[\leadsto \frac{1}{\frac{1}{\frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}}} \]
      7. pow-flip35.2%

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

        \[\leadsto \frac{1}{\frac{1}{{x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}}} \]
      9. pow1/235.2%

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \sqrt{{x}^{3}}}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u64.8%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{2 \cdot \sqrt{{x}^{3}}}\right)\right)} \]
      2. expm1-udef43.9%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{2 \cdot \sqrt{{x}^{3}}}\right)} - 1} \]
      3. associate-/r*43.9%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\frac{1}{2}}{\sqrt{{x}^{3}}}}\right)} - 1 \]
      4. metadata-eval43.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{0.5}}{\sqrt{{x}^{3}}}\right)} - 1 \]
      5. sqrt-pow143.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{0.5}{\color{blue}{{x}^{\left(\frac{3}{2}\right)}}}\right)} - 1 \]
      6. metadata-eval43.9%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{0.5}{{x}^{\color{blue}{1.5}}}\right)} - 1 \]
    6. Applied egg-rr43.9%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{0.5}{{x}^{1.5}}\right)} - 1} \]
    7. Simplified97.0%

      \[\leadsto \color{blue}{\frac{0.5}{{x}^{1.5}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.5%

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

Alternative 10: 97.9% accurate, 1.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{0.5}{{x}^{1.5}}\\


\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. add-sqr-sqrt99.1%

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

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}}}} - \frac{1}{\sqrt{x + 1}} \]
      3. frac-times99.5%

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot 1}{\sqrt{x} \cdot \sqrt{x}}}} - \frac{1}{\sqrt{x + 1}} \]
      4. metadata-eval99.5%

        \[\leadsto \sqrt{\frac{\color{blue}{1}}{\sqrt{x} \cdot \sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      5. add-sqr-sqrt99.7%

        \[\leadsto \sqrt{\frac{1}{\color{blue}{x}}} - \frac{1}{\sqrt{x + 1}} \]
    3. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} - \frac{1}{\sqrt{x + 1}} \]
    4. Taylor expanded in x around 0 99.2%

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

        \[\leadsto \color{blue}{\left(\sqrt{\frac{1}{x}} - 1\right) - -0.5 \cdot x} \]
      2. cancel-sign-sub-inv99.2%

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

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

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

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

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

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

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

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

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

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

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

    if 1 < x

    1. Initial program 45.4%

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}}} \]
      3. *-un-lft-identity45.5%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}}}} \]
      5. flip--45.4%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}}}} \]
      6. pow1/245.4%

        \[\leadsto \frac{1}{\frac{1}{\frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}}} \]
      7. pow-flip36.1%

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

        \[\leadsto \frac{1}{\frac{1}{{x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}}} \]
      9. pow1/236.1%

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \sqrt{{x}^{3}}}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u64.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{2 \cdot \sqrt{{x}^{3}}}\right)\right)} \]
      2. expm1-udef43.8%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{2 \cdot \sqrt{{x}^{3}}}\right)} - 1} \]
      3. associate-/r*43.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\frac{1}{2}}{\sqrt{{x}^{3}}}}\right)} - 1 \]
      4. metadata-eval43.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{0.5}}{\sqrt{{x}^{3}}}\right)} - 1 \]
      5. sqrt-pow143.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{0.5}{\color{blue}{{x}^{\left(\frac{3}{2}\right)}}}\right)} - 1 \]
      6. metadata-eval43.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{0.5}{{x}^{\color{blue}{1.5}}}\right)} - 1 \]
    6. Applied egg-rr43.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{0.5}{{x}^{1.5}}\right)} - 1} \]
    7. Simplified95.9%

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

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

Alternative 11: 67.2% accurate, 1.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{0}{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. Taylor expanded in x around 0 98.6%

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{1} \]
    3. Step-by-step derivation
      1. expm1-log1p-u91.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x}}\right)\right)} - 1 \]
      2. expm1-udef91.7%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x}}\right)} - 1\right)} - 1 \]
      3. pow1/291.7%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\frac{1}{\color{blue}{{x}^{0.5}}}\right)} - 1\right) - 1 \]
      4. pow-flip91.7%

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

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

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left({x}^{-0.5}\right)} - 1\right)} - 1 \]
    5. Step-by-step derivation
      1. expm1-def91.7%

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

        \[\leadsto \color{blue}{{x}^{-0.5}} - 1 \]
    6. Simplified99.0%

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

    if 1 < x

    1. Initial program 45.4%

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      6. metadata-eval46.7%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{x}} \]
    6. Simplified42.6%

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

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

Alternative 12: 97.6% accurate, 1.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{0.5}{{x}^{1.5}}\\


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

    1. Initial program 99.6%

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

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{1} \]
    3. Step-by-step derivation
      1. expm1-log1p-u91.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x}}\right)\right)} - 1 \]
      2. expm1-udef91.7%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\frac{1}{\sqrt{x}}\right)} - 1\right)} - 1 \]
      3. pow1/291.7%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\frac{1}{\color{blue}{{x}^{0.5}}}\right)} - 1\right) - 1 \]
      4. pow-flip91.7%

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

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

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left({x}^{-0.5}\right)} - 1\right)} - 1 \]
    5. Step-by-step derivation
      1. expm1-def91.7%

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

        \[\leadsto \color{blue}{{x}^{-0.5}} - 1 \]
    6. Simplified99.0%

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

    if 0.660000000000000031 < x

    1. Initial program 45.4%

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

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

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}}} \]
      3. *-un-lft-identity45.5%

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

        \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}}}} \]
      5. flip--45.4%

        \[\leadsto \frac{1}{\frac{1}{\color{blue}{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}}}} \]
      6. pow1/245.4%

        \[\leadsto \frac{1}{\frac{1}{\frac{1}{\color{blue}{{x}^{0.5}}} - \frac{1}{\sqrt{x + 1}}}} \]
      7. pow-flip36.1%

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

        \[\leadsto \frac{1}{\frac{1}{{x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}}} \]
      9. pow1/236.1%

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{2 \cdot \sqrt{{x}^{3}}}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u64.2%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{2 \cdot \sqrt{{x}^{3}}}\right)\right)} \]
      2. expm1-udef43.8%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{2 \cdot \sqrt{{x}^{3}}}\right)} - 1} \]
      3. associate-/r*43.8%

        \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\frac{1}{2}}{\sqrt{{x}^{3}}}}\right)} - 1 \]
      4. metadata-eval43.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{0.5}}{\sqrt{{x}^{3}}}\right)} - 1 \]
      5. sqrt-pow143.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{0.5}{\color{blue}{{x}^{\left(\frac{3}{2}\right)}}}\right)} - 1 \]
      6. metadata-eval43.8%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{0.5}{{x}^{\color{blue}{1.5}}}\right)} - 1 \]
    6. Applied egg-rr43.8%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{0.5}{{x}^{1.5}}\right)} - 1} \]
    7. Simplified95.9%

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

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

Alternative 13: 22.3% accurate, 26.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.7 \cdot 10^{+153}:\\
\;\;\;\;\frac{1}{x}\\

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


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

    1. Initial program 76.2%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      6. metadata-eval77.0%

        \[\leadsto \frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}} \cdot \frac{\color{blue}{1 \cdot 1}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      7. frac-times77.0%

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

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

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

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

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

    if 4.69999999999999968e153 < x

    1. Initial program 71.1%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      6. metadata-eval71.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{x}} \]
    6. Simplified71.1%

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

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

Alternative 14: 19.1% accurate, 69.7× speedup?

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

\\
\frac{0}{x}
\end{array}
Derivation
  1. Initial program 74.9%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{x}} \]
  6. Simplified20.9%

    \[\leadsto \color{blue}{\frac{0}{x}} \]
  7. Final simplification20.9%

    \[\leadsto \frac{0}{x} \]

Alternative 15: 1.9% accurate, 209.0× speedup?

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

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

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

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

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

    \[\leadsto -1 \]

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 2023336 
(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)))))