2isqrt (example 3.6)

Percentage Accurate: 70.1% → 92.3%
Time: 10.0s
Alternatives: 10
Speedup: 1.8×

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 10 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: 70.1% accurate, 1.0× speedup?

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

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

Alternative 1: 92.3% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {x}^{-0.5} - \frac{1}{{\color{blue}{\left(x + 1\right)}}^{0.5}} \]
    4. pow1/268.1%

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

      \[\leadsto \color{blue}{\frac{{x}^{-0.5} \cdot {x}^{-0.5} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{{x}^{-0.5} + \frac{1}{\sqrt{x + 1}}}} \]
    6. pow-prod-up61.2%

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{1}}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}{{x}^{-0.5} + \frac{1}{\sqrt{x + 1}}} \]
    11. add-sqr-sqrt72.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{\frac{1}{1 + x}}{x}}}{{x}^{-0.5} + {\left(x + 1\right)}^{-0.5}} \]
  16. Final simplification92.6%

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

Alternative 2: 91.8% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 41.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{1}{{\color{blue}{\left(x + 1\right)}}^{0.5}} \]
      4. pow1/232.0%

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

        \[\leadsto \color{blue}{\frac{{x}^{-0.5} \cdot {x}^{-0.5} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{{x}^{-0.5} + \frac{1}{\sqrt{x + 1}}}} \]
      6. pow-prod-up18.0%

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{1}}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}{{x}^{-0.5} + \frac{1}{\sqrt{x + 1}}} \]
      11. add-sqr-sqrt42.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.0000000000000001e-15 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1))))

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 91.8% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {x}^{-0.5} - \frac{1}{{\color{blue}{\left(x + 1\right)}}^{0.5}} \]
    4. pow1/268.1%

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

      \[\leadsto \color{blue}{\frac{{x}^{-0.5} \cdot {x}^{-0.5} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{{x}^{-0.5} + \frac{1}{\sqrt{x + 1}}}} \]
    6. pow-prod-up61.2%

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{1}}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}{{x}^{-0.5} + \frac{1}{\sqrt{x + 1}}} \]
    11. add-sqr-sqrt72.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 90.9% accurate, 1.8× speedup?

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

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

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


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

    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 91.3%

      \[\leadsto e^{\log x \cdot -0.5} - \frac{1}{\color{blue}{0.5 \cdot x + 1}} \]
    5. Step-by-step derivation
      1. pow-to-exp98.6%

        \[\leadsto \color{blue}{{x}^{-0.5}} - \frac{1}{0.5 \cdot x + 1} \]
      2. expm1-log1p-u91.3%

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

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

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

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

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

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

    if 1.19999999999999996 < x

    1. Initial program 43.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{1}{{\color{blue}{\left(x + 1\right)}}^{0.5}} \]
      4. pow1/233.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 90.9% accurate, 1.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x \cdot x}}{2 \cdot \sqrt{\frac{1}{x}}}\\


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

    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 91.3%

      \[\leadsto e^{\log x \cdot -0.5} - \frac{1}{\color{blue}{0.5 \cdot x + 1}} \]
    5. Step-by-step derivation
      1. pow-to-exp98.6%

        \[\leadsto \color{blue}{{x}^{-0.5}} - \frac{1}{0.5 \cdot x + 1} \]
      2. expm1-log1p-u91.3%

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

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

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

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

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

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

    if 1.67999999999999994 < x

    1. Initial program 43.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{1}{{\color{blue}{\left(x + 1\right)}}^{0.5}} \]
      4. pow1/233.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{x + 1}}{\color{blue}{2 \cdot \sqrt{\frac{1}{x}}}} \]
    9. Taylor expanded in x around inf 81.2%

      \[\leadsto \frac{\color{blue}{\frac{1}{{x}^{2}}}}{2 \cdot \sqrt{\frac{1}{x}}} \]
    10. Step-by-step derivation
      1. unpow281.2%

        \[\leadsto \frac{\frac{1}{\color{blue}{x \cdot x}}}{2 \cdot \sqrt{\frac{1}{x}}} \]
    11. Simplified81.2%

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

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

Alternative 6: 69.1% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.9 \cdot 10^{+23}:\\
\;\;\;\;{x}^{-0.5} - \frac{1}{1 + x \cdot 0.5}\\

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


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

    1. Initial program 95.2%

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

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

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

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

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

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

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

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

      \[\leadsto e^{\log x \cdot -0.5} - \frac{1}{\color{blue}{0.5 \cdot x + 1}} \]
    5. Step-by-step derivation
      1. pow-to-exp92.0%

        \[\leadsto \color{blue}{{x}^{-0.5}} - \frac{1}{0.5 \cdot x + 1} \]
      2. expm1-log1p-u85.3%

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

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

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

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

        \[\leadsto \color{blue}{{x}^{-0.5}} - \frac{1}{0.5 \cdot x + 1} \]
    8. Simplified92.0%

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

    if 5.89999999999999987e23 < x

    1. Initial program 43.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(x \cdot x\right)}^{\color{blue}{-0.25}} \]
    7. Applied egg-rr44.0%

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

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

Alternative 7: 69.1% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2 < x

    1. Initial program 42.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(x \cdot x\right)}^{\color{blue}{-0.25}} \]
    7. Applied egg-rr41.3%

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

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

Alternative 8: 68.8% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.80000000000000004 < x

    1. Initial program 43.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {\left(x \cdot x\right)}^{\color{blue}{-0.25}} \]
    7. Applied egg-rr41.1%

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

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

Alternative 9: 51.3% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
  6. Final simplification52.4%

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

Alternative 10: 1.9% accurate, 209.0× speedup?

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

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

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

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

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

    \[\leadsto -1 \]

Developer target: 99.1% accurate, 1.0× speedup?

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

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

Reproduce

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