2isqrt (example 3.6)

Percentage Accurate: 69.1% → 99.9%
Time: 9.4s
Alternatives: 11
Speedup: 2.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 69.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{1 + x}\\ \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 0:\\ \;\;\;\;{x}^{-1.5} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{fma}\left(x, x, x\right)\right)}^{-0.5}}{\sqrt{x} + 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)) 0.0)
     (* (pow x -1.5) 0.5)
     (/ (pow (fma x x x) -0.5) (+ (sqrt x) t_0)))))
double code(double x) {
	double t_0 = sqrt((1.0 + x));
	double tmp;
	if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 0.0) {
		tmp = pow(x, -1.5) * 0.5;
	} else {
		tmp = pow(fma(x, x, x), -0.5) / (sqrt(x) + 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)) <= 0.0)
		tmp = Float64((x ^ -1.5) * 0.5);
	else
		tmp = Float64((fma(x, x, x) ^ -0.5) / Float64(sqrt(x) + t_0));
	end
	return 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], 0.0], N[(N[Power[x, -1.5], $MachinePrecision] * 0.5), $MachinePrecision], N[(N[Power[N[(x * x + x), $MachinePrecision], -0.5], $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + 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 0:\\
\;\;\;\;{x}^{-1.5} \cdot 0.5\\

\mathbf{else}:\\
\;\;\;\;\frac{{\left(\mathsf{fma}\left(x, x, x\right)\right)}^{-0.5}}{\sqrt{x} + 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)))) < 0.0

    1. Initial program 37.4%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left(\sqrt[3]{\color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}}}\right)}^{3} \]
    5. Step-by-step derivation
      1. rem-cube-cbrt67.7%

        \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
      2. *-commutative67.7%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{{x}^{3}}} \cdot 0.5} \]
      3. pow-flip68.3%

        \[\leadsto \sqrt{\color{blue}{{x}^{\left(-3\right)}}} \cdot 0.5 \]
      4. metadata-eval68.3%

        \[\leadsto \sqrt{{x}^{\color{blue}{-3}}} \cdot 0.5 \]
    6. Applied egg-rr68.3%

      \[\leadsto \color{blue}{\sqrt{{x}^{-3}} \cdot 0.5} \]
    7. Step-by-step derivation
      1. expm1-log1p-u68.3%

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

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

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

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

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

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

        \[\leadsto \color{blue}{{x}^{-1.5}} \cdot 0.5 \]
    10. Simplified100.0%

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

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

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x + x \cdot x}}} \]
    6. Step-by-step derivation
      1. flip--98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}} \cdot {\left(\mathsf{fma}\left(x, x, x\right)\right)}^{-0.5}} \]
    12. Step-by-step derivation
      1. associate-*l/99.9%

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

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

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

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

Alternative 2: 99.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{1 + x}\\ \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 0:\\ \;\;\;\;{x}^{-1.5} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{x} + t_0}}{\sqrt{x + x \cdot x}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sqrt (+ 1.0 x))))
   (if (<= (+ (/ 1.0 (sqrt x)) (/ -1.0 t_0)) 0.0)
     (* (pow x -1.5) 0.5)
     (/ (/ 1.0 (+ (sqrt x) t_0)) (sqrt (+ x (* x x)))))))
double code(double x) {
	double t_0 = sqrt((1.0 + x));
	double tmp;
	if (((1.0 / sqrt(x)) + (-1.0 / t_0)) <= 0.0) {
		tmp = pow(x, -1.5) * 0.5;
	} else {
		tmp = (1.0 / (sqrt(x) + t_0)) / sqrt((x + (x * x)));
	}
	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)) <= 0.0d0) then
        tmp = (x ** (-1.5d0)) * 0.5d0
    else
        tmp = (1.0d0 / (sqrt(x) + t_0)) / sqrt((x + (x * x)))
    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)) <= 0.0) {
		tmp = Math.pow(x, -1.5) * 0.5;
	} else {
		tmp = (1.0 / (Math.sqrt(x) + t_0)) / Math.sqrt((x + (x * x)));
	}
	return tmp;
}
def code(x):
	t_0 = math.sqrt((1.0 + x))
	tmp = 0
	if ((1.0 / math.sqrt(x)) + (-1.0 / t_0)) <= 0.0:
		tmp = math.pow(x, -1.5) * 0.5
	else:
		tmp = (1.0 / (math.sqrt(x) + t_0)) / math.sqrt((x + (x * x)))
	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)) <= 0.0)
		tmp = Float64((x ^ -1.5) * 0.5);
	else
		tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / sqrt(Float64(x + Float64(x * x))));
	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)) <= 0.0)
		tmp = (x ^ -1.5) * 0.5;
	else
		tmp = (1.0 / (sqrt(x) + t_0)) / sqrt((x + (x * x)));
	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], 0.0], N[(N[Power[x, -1.5], $MachinePrecision] * 0.5), $MachinePrecision], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(x + N[(x * x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 37.4%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left(\sqrt[3]{\color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}}}\right)}^{3} \]
    5. Step-by-step derivation
      1. rem-cube-cbrt67.7%

        \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
      2. *-commutative67.7%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{{x}^{3}}} \cdot 0.5} \]
      3. pow-flip68.3%

        \[\leadsto \sqrt{\color{blue}{{x}^{\left(-3\right)}}} \cdot 0.5 \]
      4. metadata-eval68.3%

        \[\leadsto \sqrt{{x}^{\color{blue}{-3}}} \cdot 0.5 \]
    6. Applied egg-rr68.3%

      \[\leadsto \color{blue}{\sqrt{{x}^{-3}} \cdot 0.5} \]
    7. Step-by-step derivation
      1. expm1-log1p-u68.3%

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

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

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

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

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

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

        \[\leadsto \color{blue}{{x}^{-1.5}} \cdot 0.5 \]
    10. Simplified100.0%

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

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

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x + x \cdot x}}} \]
    6. Step-by-step derivation
      1. flip--98.9%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 10^{-8}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t_0}}{\left(x + 0.5\right) - \frac{0.125}{x}}\\

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


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

    1. Initial program 37.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x + x \cdot x}}} \]
    6. Step-by-step derivation
      1. flip--38.8%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}}{\sqrt{x + x \cdot x}} \]
    10. Taylor expanded in x around inf 99.7%

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

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

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

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

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

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

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.7% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 10^{-8}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t_0}}{x + 0.5}\\

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


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

    1. Initial program 37.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x + x \cdot x}}} \]
    6. Step-by-step derivation
      1. flip--38.8%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}}{\sqrt{x + x \cdot x}} \]
    10. Taylor expanded in x around inf 99.5%

      \[\leadsto \frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{\color{blue}{0.5 + x}} \]
    11. Step-by-step derivation
      1. +-commutative7.8%

        \[\leadsto \frac{1}{\color{blue}{x + 0.5}} \]
    12. Simplified99.5%

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

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

    1. Initial program 99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 99.4% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 37.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. add-cube-cbrt37.6%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left(\sqrt[3]{\color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}}}\right)}^{3} \]
    5. Step-by-step derivation
      1. rem-cube-cbrt67.9%

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

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

        \[\leadsto \sqrt{\color{blue}{{x}^{\left(-3\right)}}} \cdot 0.5 \]
      4. metadata-eval68.4%

        \[\leadsto \sqrt{{x}^{\color{blue}{-3}}} \cdot 0.5 \]
    6. Applied egg-rr68.4%

      \[\leadsto \color{blue}{\sqrt{{x}^{-3}} \cdot 0.5} \]
    7. Step-by-step derivation
      1. expm1-log1p-u68.4%

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

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

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

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

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

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

        \[\leadsto \color{blue}{{x}^{-1.5}} \cdot 0.5 \]
    10. Simplified99.3%

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

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

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 98.5% accurate, 1.9× speedup?

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

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

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


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1 < x

    1. Initial program 38.7%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left(\sqrt[3]{\color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}}}\right)}^{3} \]
    5. Step-by-step derivation
      1. rem-cube-cbrt67.1%

        \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
      2. *-commutative67.1%

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

        \[\leadsto \sqrt{\color{blue}{{x}^{\left(-3\right)}}} \cdot 0.5 \]
      4. metadata-eval67.7%

        \[\leadsto \sqrt{{x}^{\color{blue}{-3}}} \cdot 0.5 \]
    6. Applied egg-rr67.7%

      \[\leadsto \color{blue}{\sqrt{{x}^{-3}} \cdot 0.5} \]
    7. Step-by-step derivation
      1. expm1-log1p-u67.7%

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

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

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

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

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

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

        \[\leadsto \color{blue}{{x}^{-1.5}} \cdot 0.5 \]
    10. Simplified97.9%

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

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

Alternative 7: 98.2% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.680000000000000049 < x

    1. Initial program 38.7%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {\left(\sqrt[3]{\color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}}}\right)}^{3} \]
    5. Step-by-step derivation
      1. rem-cube-cbrt67.1%

        \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
      2. *-commutative67.1%

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

        \[\leadsto \sqrt{\color{blue}{{x}^{\left(-3\right)}}} \cdot 0.5 \]
      4. metadata-eval67.7%

        \[\leadsto \sqrt{{x}^{\color{blue}{-3}}} \cdot 0.5 \]
    6. Applied egg-rr67.7%

      \[\leadsto \color{blue}{\sqrt{{x}^{-3}} \cdot 0.5} \]
    7. Step-by-step derivation
      1. expm1-log1p-u67.7%

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

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

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

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

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

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

        \[\leadsto \color{blue}{{x}^{-1.5}} \cdot 0.5 \]
    10. Simplified97.9%

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

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

Alternative 8: 51.6% accurate, 2.0× speedup?

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

\\
{x}^{-1.5} \cdot 0.5
\end{array}
Derivation
  1. Initial program 70.3%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto {\left(\sqrt[3]{\color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}}}\right)}^{3} \]
  5. Step-by-step derivation
    1. rem-cube-cbrt34.9%

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

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

      \[\leadsto \sqrt{\color{blue}{{x}^{\left(-3\right)}}} \cdot 0.5 \]
    4. metadata-eval35.2%

      \[\leadsto \sqrt{{x}^{\color{blue}{-3}}} \cdot 0.5 \]
  6. Applied egg-rr35.2%

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

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

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{{x}^{-3}}\right)} - 1\right)} \cdot 0.5 \]
    3. sqrt-pow120.6%

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

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

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

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

      \[\leadsto \color{blue}{{x}^{-1.5}} \cdot 0.5 \]
  10. Simplified49.9%

    \[\leadsto \color{blue}{{x}^{-1.5}} \cdot 0.5 \]
  11. Final simplification49.9%

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

Alternative 9: 7.4% accurate, 41.8× speedup?

\[\begin{array}{l} \\ \frac{1}{x + 0.5} \end{array} \]
(FPCore (x) :precision binary64 (/ 1.0 (+ x 0.5)))
double code(double x) {
	return 1.0 / (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 / (x + 0.5);
}
def code(x):
	return 1.0 / (x + 0.5)
function code(x)
	return Float64(1.0 / Float64(x + 0.5))
end
function tmp = code(x)
	tmp = 1.0 / (x + 0.5);
end
code[x_] := N[(1.0 / N[(x + 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + x \cdot x}} \]
  7. Taylor expanded in x around inf 7.3%

    \[\leadsto \frac{1}{\color{blue}{0.5 + x}} \]
  8. Step-by-step derivation
    1. +-commutative7.3%

      \[\leadsto \frac{1}{\color{blue}{x + 0.5}} \]
  9. Simplified7.3%

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

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

Alternative 10: 7.4% accurate, 69.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + x \cdot x}} \]
  7. Taylor expanded in x around inf 7.3%

    \[\leadsto \color{blue}{\frac{1}{x}} \]
  8. Final simplification7.3%

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

Alternative 11: 1.9% accurate, 209.0× speedup?

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

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

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

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

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

    \[\leadsto -1 \]

Developer target: 98.9% 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 2023171 
(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)))))