2isqrt (example 3.6)

Percentage Accurate: 69.5% → 99.6%
Time: 12.7s
Alternatives: 11
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 11 alternatives:

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{\color{blue}{x \cdot x + x \cdot 1}}} \]
    5. *-rgt-identity67.9%

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

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x \cdot x + \color{blue}{{x}^{1}}}} \]
    7. sqr-pow67.9%

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

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

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\mathsf{hypot}\left(x, {x}^{\color{blue}{0.5}}\right)} \]
    10. unpow1/267.9%

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\mathsf{hypot}\left(x, \color{blue}{\sqrt{x}}\right)} \]
  5. Simplified67.9%

    \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\mathsf{hypot}\left(x, \sqrt{x}\right)}} \]
  6. Step-by-step derivation
    1. flip--68.4%

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}}}}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \]
    2. div-inv68.4%

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

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

      \[\leadsto \frac{\left(\left(1 + x\right) - \color{blue}{x}\right) \cdot \frac{1}{\sqrt{1 + x} + \sqrt{x}}}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \]
    5. associate--l+99.6%

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \]
    4. +-commutative99.6%

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

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

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

Alternative 2: 91.7% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 37.8%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. flip--37.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. frac-times25.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\color{blue}{2 \cdot \sqrt{\frac{1}{x}}}} \]
    5. Step-by-step derivation
      1. frac-2neg37.8%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left(-1 + \left(-x\right)\right) - x \cdot -1}{x \cdot \left(-1 + \left(-x\right)\right)}}}{2 \cdot \sqrt{\frac{1}{x}}} \]
    7. Step-by-step derivation
      1. associate-/r*37.9%

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

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

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

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

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

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

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

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

    if 5.0000000000000002e-14 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1))))

    1. Initial program 98.5%

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.9% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{\color{blue}{x \cdot x + x \cdot 1}}} \]
    5. *-rgt-identity67.9%

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

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x \cdot x + \color{blue}{{x}^{1}}}} \]
    7. sqr-pow67.9%

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

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

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\mathsf{hypot}\left(x, {x}^{\color{blue}{0.5}}\right)} \]
    10. unpow1/267.9%

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\mathsf{hypot}\left(x, \color{blue}{\sqrt{x}}\right)} \]
  5. Simplified67.9%

    \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\mathsf{hypot}\left(x, \sqrt{x}\right)}} \]
  6. Step-by-step derivation
    1. flip--68.4%

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}}}}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \]
    2. div-inv68.4%

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

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

      \[\leadsto \frac{\left(\left(1 + x\right) - \color{blue}{x}\right) \cdot \frac{1}{\sqrt{1 + x} + \sqrt{x}}}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \]
    5. associate--l+99.6%

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \]
    4. +-commutative99.6%

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

    \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \]
  10. Step-by-step derivation
    1. expm1-log1p-u96.3%

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

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{\mathsf{hypot}\left(x, \sqrt{x}\right)}\right)} - 1} \]
    3. associate-/l/64.0%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right) \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)}}\right)} - 1 \]
    4. *-commutative64.0%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{1}{\color{blue}{\left(\sqrt{x} + \sqrt{1 + x}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)}}\right)} - 1 \]
  11. Applied egg-rr64.0%

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

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

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

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

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

Alternative 4: 91.7% accurate, 1.0× speedup?

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

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

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{1}}{\sqrt{x} \cdot \sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
    4. add-sqr-sqrt58.6%

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}} \]
    12. inv-pow67.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 91.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.1%

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{\color{blue}{{x}^{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) \]
      9. pow-flip99.4%

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. associate--l-99.1%

        \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
      5. fma-udef99.1%

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

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

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

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

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

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

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

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

    if 3.6e7 < x

    1. Initial program 38.1%

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

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

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

        \[\leadsto \frac{\frac{\color{blue}{1}}{\sqrt{x} \cdot \sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
      4. add-sqr-sqrt20.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\color{blue}{2 \cdot \sqrt{\frac{1}{x}}}} \]
    5. Step-by-step derivation
      1. frac-2neg38.2%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left(-1 + \left(-x\right)\right) - x \cdot -1}{x \cdot \left(-1 + \left(-x\right)\right)}}}{2 \cdot \sqrt{\frac{1}{x}}} \]
    7. Step-by-step derivation
      1. associate-/r*38.3%

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

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

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

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

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

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

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

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

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

Alternative 6: 90.9% accurate, 1.8× speedup?

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

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

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


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

    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. pow1/299.6%

        \[\leadsto \left(\frac{1}{\color{blue}{{x}^{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) \]
      9. pow-flip100.0%

        \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\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. associate-+l-100.0%

        \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p100.0%

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

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. associate--l-100.0%

        \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
      5. fma-udef100.0%

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \color{blue}{{\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 100.0%

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

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

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

    if 0.73999999999999999 < x

    1. Initial program 39.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}} \]
      12. inv-pow39.6%

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\color{blue}{2 \cdot \sqrt{\frac{1}{x}}}} \]
    5. Step-by-step derivation
      1. frac-2neg38.2%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left(-1 + \left(-x\right)\right) - x \cdot -1}{x \cdot \left(-1 + \left(-x\right)\right)}}}{2 \cdot \sqrt{\frac{1}{x}}} \]
    7. Step-by-step derivation
      1. associate-/r*38.3%

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

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

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

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

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

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

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

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

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

Alternative 7: 68.9% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. 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. pow1/299.6%

        \[\leadsto \left(\frac{1}{\color{blue}{{x}^{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) \]
      9. pow-flip100.0%

        \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\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. associate-+l-100.0%

        \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p100.0%

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

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. associate--l-100.0%

        \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
      5. fma-udef100.0%

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \color{blue}{{\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 99.9%

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

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

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

    if 0.660000000000000031 < x

    1. Initial program 39.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}} \]
      12. inv-pow39.6%

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

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

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

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{\frac{1}{x} + \left(-\frac{1}{1 + x}\right)}}{2 \cdot \sqrt{\frac{1}{x}}}\right)} - 1 \]
      4. distribute-neg-frac37.4%

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{1}{x} + \frac{\color{blue}{-1}}{1 + x}}{2 \cdot \sqrt{\frac{1}{x}}}\right)} - 1 \]
      6. sqrt-div37.4%

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{1}{x} + \frac{-1}{1 + x}}{2 \cdot \frac{\color{blue}{1}}{\sqrt{x}}}\right)} - 1 \]
      8. un-div-inv37.4%

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{1}{x} + \frac{-1}{1 + x}}{\color{blue}{\frac{2}{\sqrt{x}}}}\right)} - 1 \]
    6. Applied egg-rr37.4%

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} + \frac{-1}{1 + x}}{\color{blue}{\frac{1}{0.5}}} \cdot \sqrt{x} \]
      5. associate-/l*38.2%

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

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

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

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

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

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

Alternative 8: 90.8% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. 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. pow1/299.6%

        \[\leadsto \left(\frac{1}{\color{blue}{{x}^{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) \]
      9. pow-flip100.0%

        \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\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. associate-+l-100.0%

        \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
      2. expm1-log1p100.0%

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

        \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. associate--l-100.0%

        \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
      5. fma-udef100.0%

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \color{blue}{{\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 99.9%

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

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

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

    if 0.660000000000000031 < x

    1. Initial program 39.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}} \]
      12. inv-pow39.6%

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\color{blue}{2 \cdot \sqrt{\frac{1}{x}}}} \]
    5. Step-by-step derivation
      1. frac-2neg38.2%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left(-1 + \left(-x\right)\right) - x \cdot -1}{x \cdot \left(-1 + \left(-x\right)\right)}}}{2 \cdot \sqrt{\frac{1}{x}}} \]
    7. Step-by-step derivation
      1. associate-/r*38.3%

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

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

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

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

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

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

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

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

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

Alternative 9: 52.9% accurate, 2.0× speedup?

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

\\
\frac{1}{x + {x}^{0.5}}
\end{array}
Derivation
  1. Initial program 67.9%

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

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

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

      \[\leadsto \frac{\frac{\color{blue}{1}}{\sqrt{x} \cdot \sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
    4. add-sqr-sqrt58.6%

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}} \]
    12. inv-pow67.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{x + {x}^{\color{blue}{0.5}}} \]
  6. Simplified50.6%

    \[\leadsto \color{blue}{\frac{1}{x + {x}^{0.5}}} \]
  7. Final simplification50.6%

    \[\leadsto \frac{1}{x + {x}^{0.5}} \]

Alternative 10: 50.9% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \left(\frac{1}{\color{blue}{{x}^{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) \]
    9. pow-flip62.3%

      \[\leadsto \left(\color{blue}{{x}^{\left(-0.5\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-eval62.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/262.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-flip68.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. +-commutative68.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-eval68.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-rr68.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. associate-+l-68.0%

      \[\leadsto \color{blue}{{x}^{-0.5} - \left({\left(1 + x\right)}^{-0.5} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)} \]
    2. expm1-log1p68.0%

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

      \[\leadsto {x}^{-0.5} - \left(\color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - 1\right)} - \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right) \]
    4. associate--l-51.6%

      \[\leadsto {x}^{-0.5} - \color{blue}{\left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)\right)\right)} \]
    5. fma-udef51.6%

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}\right)\right) \]
    6. distribute-lft1-in51.6%

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

      \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(1 + x\right)}^{-0.5}\right)} - \left(1 + \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5}\right)\right) \]
    8. mul0-lft51.6%

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

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

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

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

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

    \[\leadsto \color{blue}{{x}^{-0.5} - 1} \]
  7. Final simplification48.4%

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

Alternative 11: 2.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 Float64(-(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 67.9%

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

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

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

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

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

    \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(x\right) \cdot 0.5}}} \]
  4. Taylor expanded in x around inf 2.2%

    \[\leadsto \color{blue}{-1 \cdot \sqrt{\frac{1}{x}}} \]
  5. Step-by-step derivation
    1. mul-1-neg2.2%

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

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

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

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

      \[\leadsto -{x}^{\color{blue}{-0.5}} \]
    4. expm1-log1p-u2.2%

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

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

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

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

      \[\leadsto -\color{blue}{{x}^{-0.5}} \]
  10. Simplified2.2%

    \[\leadsto -\color{blue}{{x}^{-0.5}} \]
  11. Final simplification2.2%

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

Developer target: 99.0% accurate, 1.0× speedup?

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

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

Reproduce

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