2isqrt (example 3.6)

Percentage Accurate: 69.5% → 99.4%
Time: 11.2s
Alternatives: 14
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 14 alternatives:

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

Initial Program: 69.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.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \frac{\frac{1}{x}}{\mathsf{fma}\left({x}^{-0.5}, 1 + x, \sqrt{1 + x}\right)} \end{array} \]
(FPCore (x)
 :precision binary64
 (/ (/ 1.0 x) (fma (pow x -0.5) (+ 1.0 x) (sqrt (+ 1.0 x)))))
double code(double x) {
	return (1.0 / x) / fma(pow(x, -0.5), (1.0 + x), sqrt((1.0 + x)));
}
function code(x)
	return Float64(Float64(1.0 / x) / fma((x ^ -0.5), Float64(1.0 + x), sqrt(Float64(1.0 + x))))
end
code[x_] := N[(N[(1.0 / x), $MachinePrecision] / N[(N[Power[x, -0.5], $MachinePrecision] * N[(1.0 + x), $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{1}{x}}{\mathsf{fma}\left({x}^{-0.5}, 1 + x, \sqrt{1 + x}\right)}
\end{array}
Derivation
  1. Initial program 70.8%

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

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

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

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

      \[\leadsto \frac{1}{\sqrt{x}} - \left(\color{blue}{0} + \log \left(e^{\frac{1}{\sqrt{x + 1}}}\right)\right) \]
    5. add-log-exp70.8%

      \[\leadsto \frac{1}{\sqrt{x}} - \left(0 + \color{blue}{\frac{1}{\sqrt{x + 1}}}\right) \]
    6. inv-pow70.8%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{\left(-1.5 \cdot 0.3333333333333333\right)}} \]
    5. pow-pow56.3%

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

      \[\leadsto {x}^{-0.5} - {\left({\color{blue}{\left(x + 1\right)}}^{-1.5}\right)}^{0.3333333333333333} \]
    7. pow1/357.3%

      \[\leadsto {x}^{-0.5} - \color{blue}{\sqrt[3]{{\left(x + 1\right)}^{-1.5}}} \]
    8. flip--57.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 10^{-9}:\\ \;\;\;\;\frac{1 + \left(x - x\right)}{x \cdot \left(\sqrt{\frac{1}{x}} \cdot 1.5 + \sqrt{x} \cdot 2\right)}\\ \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-9)
   (/ (+ 1.0 (- x x)) (* x (+ (* (sqrt (/ 1.0 x)) 1.5) (* (sqrt x) 2.0))))
   (- (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-9) {
		tmp = (1.0 + (x - x)) / (x * ((sqrt((1.0 / x)) * 1.5) + (sqrt(x) * 2.0)));
	} else {
		tmp = pow(x, -0.5) - pow((1.0 + x), -0.5);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (((1.0d0 / sqrt(x)) - (1.0d0 / sqrt((1.0d0 + x)))) <= 1d-9) then
        tmp = (1.0d0 + (x - x)) / (x * ((sqrt((1.0d0 / x)) * 1.5d0) + (sqrt(x) * 2.0d0)))
    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-9) {
		tmp = (1.0 + (x - x)) / (x * ((Math.sqrt((1.0 / x)) * 1.5) + (Math.sqrt(x) * 2.0)));
	} 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-9:
		tmp = (1.0 + (x - x)) / (x * ((math.sqrt((1.0 / x)) * 1.5) + (math.sqrt(x) * 2.0)))
	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-9)
		tmp = Float64(Float64(1.0 + Float64(x - x)) / Float64(x * Float64(Float64(sqrt(Float64(1.0 / x)) * 1.5) + Float64(sqrt(x) * 2.0))));
	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-9)
		tmp = (1.0 + (x - x)) / (x * ((sqrt((1.0 / x)) * 1.5) + (sqrt(x) * 2.0)));
	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-9], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * 1.5), $MachinePrecision] + N[(N[Sqrt[x], $MachinePrecision] * 2.0), $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^{-9}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{x \cdot \left(\sqrt{\frac{1}{x}} \cdot 1.5 + \sqrt{x} \cdot 2\right)}\\

\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.00000000000000006e-9

    1. Initial program 37.2%

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

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

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

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

        \[\leadsto \frac{1}{\sqrt{x}} - \left(\color{blue}{0} + \log \left(e^{\frac{1}{\sqrt{x + 1}}}\right)\right) \]
      5. add-log-exp37.2%

        \[\leadsto \frac{1}{\sqrt{x}} - \left(0 + \color{blue}{\frac{1}{\sqrt{x + 1}}}\right) \]
      6. inv-pow37.2%

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

        \[\leadsto \frac{1}{\sqrt{x}} - \left(0 + \color{blue}{{\left(x + 1\right)}^{\left(\frac{-1}{2}\right)}}\right) \]
      8. +-commutative31.4%

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{\left(-1.5 \cdot 0.3333333333333333\right)}} \]
      5. pow-pow5.2%

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

        \[\leadsto {x}^{-0.5} - {\left({\color{blue}{\left(x + 1\right)}}^{-1.5}\right)}^{0.3333333333333333} \]
      7. pow1/37.4%

        \[\leadsto {x}^{-0.5} - \color{blue}{\sqrt[3]{{\left(x + 1\right)}^{-1.5}}} \]
      8. flip--7.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.00000000000000006e-9 < (-.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.3%

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

Alternative 3: 98.6% accurate, 1.0× speedup?

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

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

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

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

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

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

      \[\leadsto \frac{1}{\sqrt{x}} - \left(\color{blue}{0} + \log \left(e^{\frac{1}{\sqrt{x + 1}}}\right)\right) \]
    5. add-log-exp70.8%

      \[\leadsto \frac{1}{\sqrt{x}} - \left(0 + \color{blue}{\frac{1}{\sqrt{x + 1}}}\right) \]
    6. inv-pow70.8%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{\left(-1.5 \cdot 0.3333333333333333\right)}} \]
    5. pow-pow56.3%

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

      \[\leadsto {x}^{-0.5} - {\left({\color{blue}{\left(x + 1\right)}}^{-1.5}\right)}^{0.3333333333333333} \]
    7. pow1/357.3%

      \[\leadsto {x}^{-0.5} - \color{blue}{\sqrt[3]{{\left(x + 1\right)}^{-1.5}}} \]
    8. flip--57.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 98.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e16 < x

    1. Initial program 36.9%

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

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

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

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

        \[\leadsto \frac{1}{\sqrt{x}} - \left(\color{blue}{0} + \log \left(e^{\frac{1}{\sqrt{x + 1}}}\right)\right) \]
      5. add-log-exp36.9%

        \[\leadsto \frac{1}{\sqrt{x}} - \left(0 + \color{blue}{\frac{1}{\sqrt{x + 1}}}\right) \]
      6. inv-pow36.9%

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

        \[\leadsto \frac{1}{\sqrt{x}} - \left(0 + \color{blue}{{\left(x + 1\right)}^{\left(\frac{-1}{2}\right)}}\right) \]
      8. +-commutative30.6%

        \[\leadsto \frac{1}{\sqrt{x}} - \left(0 + {\color{blue}{\left(1 + x\right)}}^{\left(\frac{-1}{2}\right)}\right) \]
      9. metadata-eval30.6%

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{\left(-1.5 \cdot 0.3333333333333333\right)}} \]
      5. pow-pow3.3%

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

        \[\leadsto {x}^{-0.5} - {\left({\color{blue}{\left(x + 1\right)}}^{-1.5}\right)}^{0.3333333333333333} \]
      7. pow1/35.2%

        \[\leadsto {x}^{-0.5} - \color{blue}{\sqrt[3]{{\left(x + 1\right)}^{-1.5}}} \]
      8. flip--5.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 98.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 98.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.7e8 < x

    1. Initial program 36.5%

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

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

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

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

        \[\leadsto \frac{1}{\sqrt{x}} - \left(\color{blue}{0} + \log \left(e^{\frac{1}{\sqrt{x + 1}}}\right)\right) \]
      5. add-log-exp36.5%

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

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

        \[\leadsto \frac{1}{\sqrt{x}} - \left(0 + \color{blue}{{\left(x + 1\right)}^{\left(\frac{-1}{2}\right)}}\right) \]
      8. +-commutative30.6%

        \[\leadsto \frac{1}{\sqrt{x}} - \left(0 + {\color{blue}{\left(1 + x\right)}}^{\left(\frac{-1}{2}\right)}\right) \]
      9. metadata-eval30.6%

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{\left(-1.5 \cdot 0.3333333333333333\right)}} \]
      5. pow-pow3.8%

        \[\leadsto {x}^{-0.5} - \color{blue}{{\left({\left(1 + x\right)}^{-1.5}\right)}^{0.3333333333333333}} \]
      6. +-commutative3.8%

        \[\leadsto {x}^{-0.5} - {\left({\color{blue}{\left(x + 1\right)}}^{-1.5}\right)}^{0.3333333333333333} \]
      7. pow1/36.0%

        \[\leadsto {x}^{-0.5} - \color{blue}{\sqrt[3]{{\left(x + 1\right)}^{-1.5}}} \]
      8. flip--6.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 97.7% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.680000000000000049 < x

    1. Initial program 37.7%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. add-log-exp7.0%

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

        \[\leadsto \frac{1}{\sqrt{x}} - \log \color{blue}{\left(1 \cdot e^{\frac{1}{\sqrt{x + 1}}}\right)} \]
      3. log-prod7.0%

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

        \[\leadsto \frac{1}{\sqrt{x}} - \left(\color{blue}{0} + \log \left(e^{\frac{1}{\sqrt{x + 1}}}\right)\right) \]
      5. add-log-exp37.7%

        \[\leadsto \frac{1}{\sqrt{x}} - \left(0 + \color{blue}{\frac{1}{\sqrt{x + 1}}}\right) \]
      6. inv-pow37.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{\left(-1.5 \cdot 0.3333333333333333\right)}} \]
      5. pow-pow6.0%

        \[\leadsto {x}^{-0.5} - \color{blue}{{\left({\left(1 + x\right)}^{-1.5}\right)}^{0.3333333333333333}} \]
      6. +-commutative6.0%

        \[\leadsto {x}^{-0.5} - {\left({\color{blue}{\left(x + 1\right)}}^{-1.5}\right)}^{0.3333333333333333} \]
      7. pow1/38.2%

        \[\leadsto {x}^{-0.5} - \color{blue}{\sqrt[3]{{\left(x + 1\right)}^{-1.5}}} \]
      8. flip--8.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 97.7% accurate, 1.8× 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{1 + \left(x - x\right)}{x \cdot \left(\sqrt{x} \cdot 2\right)}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 1.0)
   (+ (+ (pow x -0.5) (* x 0.5)) -1.0)
   (/ (+ 1.0 (- x x)) (* x (* (sqrt x) 2.0)))))
double code(double x) {
	double tmp;
	if (x <= 1.0) {
		tmp = (pow(x, -0.5) + (x * 0.5)) + -1.0;
	} else {
		tmp = (1.0 + (x - x)) / (x * (sqrt(x) * 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 = (1.0d0 + (x - x)) / (x * (sqrt(x) * 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 = (1.0 + (x - x)) / (x * (Math.sqrt(x) * 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 = (1.0 + (x - x)) / (x * (math.sqrt(x) * 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(Float64(1.0 + Float64(x - x)) / Float64(x * Float64(sqrt(x) * 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 = (1.0 + (x - x)) / (x * (sqrt(x) * 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[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(x * N[(N[Sqrt[x], $MachinePrecision] * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1 < x

    1. Initial program 37.7%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. add-log-exp7.0%

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

        \[\leadsto \frac{1}{\sqrt{x}} - \log \color{blue}{\left(1 \cdot e^{\frac{1}{\sqrt{x + 1}}}\right)} \]
      3. log-prod7.0%

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

        \[\leadsto \frac{1}{\sqrt{x}} - \left(\color{blue}{0} + \log \left(e^{\frac{1}{\sqrt{x + 1}}}\right)\right) \]
      5. add-log-exp37.7%

        \[\leadsto \frac{1}{\sqrt{x}} - \left(0 + \color{blue}{\frac{1}{\sqrt{x + 1}}}\right) \]
      6. inv-pow37.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{\left(-1.5 \cdot 0.3333333333333333\right)}} \]
      5. pow-pow6.0%

        \[\leadsto {x}^{-0.5} - \color{blue}{{\left({\left(1 + x\right)}^{-1.5}\right)}^{0.3333333333333333}} \]
      6. +-commutative6.0%

        \[\leadsto {x}^{-0.5} - {\left({\color{blue}{\left(x + 1\right)}}^{-1.5}\right)}^{0.3333333333333333} \]
      7. pow1/38.2%

        \[\leadsto {x}^{-0.5} - \color{blue}{\sqrt[3]{{\left(x + 1\right)}^{-1.5}}} \]
      8. flip--8.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1 < x

    1. Initial program 37.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{-0.5} + \color{blue}{1}} \]
    7. Taylor expanded in x around inf 36.9%

      \[\leadsto \frac{\color{blue}{\frac{1}{{x}^{2}}}}{{x}^{-0.5} + 1} \]
    8. Step-by-step derivation
      1. unpow236.9%

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

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

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

Alternative 9: 68.6% 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.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2 < x

    1. Initial program 37.7%

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

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

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

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff37.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-identity37.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-neg37.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-identity37.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-pow37.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-pow231.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-eval31.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/231.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-flip37.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. +-commutative37.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-eval37.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-rr37.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-udef37.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-in37.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-eval37.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-lft37.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
    9. 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. metadata-eval5.7%

        \[\leadsto {x}^{\color{blue}{\left(2 \cdot -0.25\right)}} \]
      5. pow-pow36.1%

        \[\leadsto \color{blue}{{\left({x}^{2}\right)}^{-0.25}} \]
      6. pow236.1%

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

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

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

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

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

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


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.819999999999999951 < x

    1. Initial program 37.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{x \cdot 1 + x \cdot {x}^{-0.5}}} \]
      4. *-rgt-identity7.9%

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

      \[\leadsto \color{blue}{\frac{1}{x + x \cdot {x}^{-0.5}}} \]
    9. Taylor expanded in x around inf 7.9%

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

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

Alternative 11: 68.3% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.80000000000000004 < x

    1. Initial program 37.7%

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

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

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

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff37.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-identity37.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-neg37.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-identity37.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-pow37.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-pow231.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-eval31.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/231.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-flip37.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. +-commutative37.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-eval37.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-rr37.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-udef37.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-in37.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-eval37.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-lft37.9%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
    9. 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. metadata-eval5.7%

        \[\leadsto {x}^{\color{blue}{\left(2 \cdot -0.25\right)}} \]
      5. pow-pow36.1%

        \[\leadsto \color{blue}{{\left({x}^{2}\right)}^{-0.25}} \]
      6. pow236.1%

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

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

    \[\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 12: 51.1% 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 70.8%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    12. pow-flip71.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. +-commutative71.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-eval71.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-rr71.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-udef71.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-in71.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-eval71.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-lft71.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 \cdot {x}^{-0.5}} \]
  10. Applied egg-rr53.4%

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

      \[\leadsto \color{blue}{{x}^{-0.5}} \]
  12. Simplified53.4%

    \[\leadsto \color{blue}{{x}^{-0.5}} \]
  13. Final simplification53.4%

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

Alternative 13: 7.4% accurate, 69.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{x \cdot 1 + x \cdot {x}^{-0.5}}} \]
    4. *-rgt-identity55.1%

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

    \[\leadsto \color{blue}{\frac{1}{x + x \cdot {x}^{-0.5}}} \]
  9. Taylor expanded in x around inf 7.5%

    \[\leadsto \color{blue}{\frac{1}{x}} \]
  10. Final simplification7.5%

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

Alternative 14: 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 70.8%

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

    \[\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: 98.8% 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 2023256 
(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)))))