2isqrt (example 3.6)

Percentage Accurate: 68.5% → 99.9%
Time: 9.1s
Alternatives: 11
Speedup: 2.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 68.5% 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.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{x + 1}} \leq 0:\\
\;\;\;\;\frac{{x}^{-1.5}}{2}\\

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


\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)))) < 0.0

    1. Initial program 37.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{\sqrt{1 + x} \cdot \sqrt{1 + x} + \sqrt{1 + x} \cdot \sqrt{x}}} \]
      8. rem-square-sqrt99.6%

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

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

      \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{2 \cdot x}} \]
    9. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{x \cdot 2}} \]
    10. Simplified99.7%

      \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{x \cdot 2}} \]
    11. Step-by-step derivation
      1. expm1-log1p-u99.7%

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{{x}^{\color{blue}{-1.5}}}{2}\right)} - 1 \]
    12. Applied egg-rr37.7%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{{x}^{-1.5}}{2}\right)} - 1} \]
    13. Step-by-step derivation
      1. expm1-def100.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{x}^{-1.5}}{2}\right)\right)} \]
      2. expm1-log1p100.0%

        \[\leadsto \color{blue}{\frac{{x}^{-1.5}}{2}} \]
    14. Simplified100.0%

      \[\leadsto \color{blue}{\frac{{x}^{-1.5}}{2}} \]

    if 0.0 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1))))

    1. Initial program 98.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{\sqrt{1 + x} \cdot \sqrt{1 + x} + \sqrt{1 + x} \cdot \sqrt{x}}} \]
      8. rem-square-sqrt99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.8% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 38.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{{x}^{-0.5}}{\left(1 + x\right) + \color{blue}{\left(\left(0.5 + \left(0.0625 \cdot \frac{1}{{x}^{2}} + x\right)\right) - 0.125 \cdot \frac{1}{x}\right)}} \]
    9. Step-by-step derivation
      1. +-commutative99.7%

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

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

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

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

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

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

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

    if 5.00000000000000041e-6 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1))))

    1. Initial program 99.6%

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      5. *-un-lft-identity99.6%

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

        \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      7. *-un-lft-identity99.6%

        \[\leadsto \left(\color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      8. inv-pow99.6%

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

        \[\leadsto \left(\color{blue}{{x}^{\left(\frac{-1}{2}\right)}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      10. metadata-eval99.9%

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      11. pow1/299.9%

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

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

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

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

      \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
    4. Step-by-step derivation
      1. fma-udef99.9%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)} \]
      2. distribute-lft1-in99.9%

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

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

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

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

Alternative 3: 99.8% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{\sqrt{1 + x} \cdot \sqrt{1 + x} + \sqrt{1 + x} \cdot \sqrt{x}}} \]
    8. rem-square-sqrt99.7%

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

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

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

Alternative 4: 99.4% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{1}{x} - \frac{-1}{\sqrt{1 + x}} \cdot \frac{-1}{\sqrt{1 + x}}}{{x}^{-0.5} - \frac{-1}{\sqrt{1 + x}}}} \]
  4. Step-by-step derivation
    1. frac-times59.1%

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{\color{blue}{1 + x}}}{{x}^{-0.5} - \frac{-1}{\sqrt{1 + x}}} \]
    4. frac-sub65.1%

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{\frac{1}{x}}{1 + x}}}{{x}^{-0.5} - \frac{-1}{\sqrt{1 + x}}} \]
  8. Step-by-step derivation
    1. associate-/l/99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 99.3% accurate, 1.7× speedup?

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

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

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

    if 0.440000000000000002 < x

    1. Initial program 39.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 99.3% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

    if 0.429999999999999993 < x

    1. Initial program 39.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 99.3% accurate, 1.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{{x}^{-0.5}}{1.5 + \left(x \cdot 2 - \frac{0.125}{x}\right)}\\


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

    if 0.429999999999999993 < x

    1. Initial program 39.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{{x}^{-0.5}}{1.5 + \left(x \cdot 2 - \frac{\color{blue}{0.125}}{x}\right)} \]
    10. Simplified98.9%

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

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

Alternative 8: 98.7% accurate, 1.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{{x}^{-1.5}}{2}\\


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

    if 1 < x

    1. Initial program 39.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{2 \cdot x}} \]
    9. Step-by-step derivation
      1. *-commutative97.5%

        \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{x \cdot 2}} \]
    10. Simplified97.5%

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{{x}^{\color{blue}{-1.5}}}{2}\right)} - 1 \]
    12. Applied egg-rr37.5%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{{x}^{-1.5}}{2}\right)} - 1} \]
    13. Step-by-step derivation
      1. expm1-def97.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{x}^{-1.5}}{2}\right)\right)} \]
      2. expm1-log1p97.7%

        \[\leadsto \color{blue}{\frac{{x}^{-1.5}}{2}} \]
    14. Simplified97.7%

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

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

Alternative 9: 99.1% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

    if 0.409999999999999976 < x

    1. Initial program 39.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{1.5 + 2 \cdot x}} \]
    9. Step-by-step derivation
      1. +-commutative98.5%

        \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{2 \cdot x + 1.5}} \]
      2. *-commutative98.5%

        \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{x \cdot 2} + 1.5} \]
    10. Simplified98.5%

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

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

Alternative 10: 98.5% accurate, 2.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{{x}^{-1.5}}{2}\\


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

    if 0.660000000000000031 < x

    1. Initial program 39.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{2 \cdot x}} \]
    9. Step-by-step derivation
      1. *-commutative97.5%

        \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{x \cdot 2}} \]
    10. Simplified97.5%

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{{x}^{\color{blue}{-1.5}}}{2}\right)} - 1 \]
    12. Applied egg-rr37.5%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{{x}^{-1.5}}{2}\right)} - 1} \]
    13. Step-by-step derivation
      1. expm1-def97.7%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{{x}^{-1.5}}{2}\right)\right)} \]
      2. expm1-log1p97.7%

        \[\leadsto \color{blue}{\frac{{x}^{-1.5}}{2}} \]
    14. Simplified97.7%

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

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

Alternative 11: 50.3% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {x}^{\color{blue}{-0.5}} \]
    4. *-un-lft-identity44.1%

      \[\leadsto \color{blue}{1 \cdot {x}^{-0.5}} \]
  6. Applied egg-rr44.1%

    \[\leadsto \color{blue}{1 \cdot {x}^{-0.5}} \]
  7. Step-by-step derivation
    1. *-lft-identity44.1%

      \[\leadsto \color{blue}{{x}^{-0.5}} \]
  8. Simplified44.1%

    \[\leadsto \color{blue}{{x}^{-0.5}} \]
  9. Final simplification44.1%

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

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