2isqrt (example 3.6)

Percentage Accurate: 69.0% → 99.7%
Time: 13.0s
Alternatives: 11
Speedup: 1.9×

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.0% 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.7% 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 5 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{x} + t_0}}{\left(0.5 + \left(x + \frac{0.0625}{{x}^{2}}\right)\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)) 5e-7)
     (/
      (/ 1.0 (+ (sqrt x) t_0))
      (- (+ 0.5 (+ x (/ 0.0625 (pow x 2.0)))) (/ 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)) <= 5e-7) {
		tmp = (1.0 / (sqrt(x) + t_0)) / ((0.5 + (x + (0.0625 / pow(x, 2.0)))) - (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)) <= 5d-7) then
        tmp = (1.0d0 / (sqrt(x) + t_0)) / ((0.5d0 + (x + (0.0625d0 / (x ** 2.0d0)))) - (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)) <= 5e-7) {
		tmp = (1.0 / (Math.sqrt(x) + t_0)) / ((0.5 + (x + (0.0625 / Math.pow(x, 2.0)))) - (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)) <= 5e-7:
		tmp = (1.0 / (math.sqrt(x) + t_0)) / ((0.5 + (x + (0.0625 / math.pow(x, 2.0)))) - (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)) <= 5e-7)
		tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / Float64(Float64(0.5 + Float64(x + Float64(0.0625 / (x ^ 2.0)))) - 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)) <= 5e-7)
		tmp = (1.0 / (sqrt(x) + t_0)) / ((0.5 + (x + (0.0625 / (x ^ 2.0)))) - (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], 5e-7], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(N[(0.5 + N[(x + N[(0.0625 / N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + t_0}}{\left(0.5 + \left(x + \frac{0.0625}{{x}^{2}}\right)\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)))) < 4.99999999999999977e-7

    1. Initial program 37.1%

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

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

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

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff37.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-identity37.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-neg37.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-identity37.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/237.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-flip31.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-eval31.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/231.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-flip37.1%

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

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

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

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

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

        \[\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-def6.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-6.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-udef6.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-in6.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-eval6.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-lft6.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-eval6.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
      8. pow1/37.6%

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

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

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

        \[\leadsto \frac{\color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
      12. pow-pow37.2%

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

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

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

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

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

        \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
      18. pow-pow37.2%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x \cdot \left(x + 1\right)}}} \]
    9. Step-by-step derivation
      1. flip--38.6%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
    13. Taylor expanded in x around inf 99.6%

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

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

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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 5 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{\left(0.5 + \left(x + \frac{0.0625}{{x}^{2}}\right)\right) - \frac{0.125}{x}}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 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 5 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{x} + t_0}}{x + \left(0.5 + \frac{-0.125}{x}\right)}\\ \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)) 5e-7)
     (/ (/ 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)) <= 5e-7) {
		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)) <= 5d-7) 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)) <= 5e-7) {
		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)) <= 5e-7:
		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)) <= 5e-7)
		tmp = Float64(Float64(1.0 / Float64(sqrt(x) + t_0)) / Float64(x + Float64(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)) <= 5e-7)
		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], 5e-7], N[(N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision] / N[(x + N[(0.5 + N[(-0.125 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 37.1%

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

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

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

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff37.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-identity37.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-neg37.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-identity37.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/237.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-flip31.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-eval31.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/231.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-flip37.1%

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

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

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

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

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

        \[\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-def6.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-6.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-udef6.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-in6.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-eval6.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-lft6.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-eval6.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
      8. pow1/37.6%

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

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

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

        \[\leadsto \frac{\color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
      12. pow-pow37.2%

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

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

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

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

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

        \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
      18. pow-pow37.2%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x \cdot \left(x + 1\right)}}} \]
    9. Step-by-step derivation
      1. flip--38.6%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
    13. Taylor expanded in x around inf 99.5%

      \[\leadsto \frac{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}{\color{blue}{\left(0.5 + x\right) - 0.125 \cdot \frac{1}{x}}} \]
    14. Step-by-step derivation
      1. sub-neg99.5%

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

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

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

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

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

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

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

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

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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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 5 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{x + \left(0.5 + \frac{-0.125}{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 99.6% 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^{-13}:\\ \;\;\;\;\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)) 5e-13)
     (/ (/ 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)) <= 5e-13) {
		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)) <= 5d-13) 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)) <= 5e-13) {
		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)) <= 5e-13:
		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)) <= 5e-13)
		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)) <= 5e-13)
		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], 5e-13], 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 5 \cdot 10^{-13}:\\
\;\;\;\;\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)))) < 4.9999999999999999e-13

    1. Initial program 36.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{{\left(1 + x\right)}^{\color{blue}{\left(1.5 \cdot 0.3333333333333333\right)}}} \]
      7. pow-pow4.8%

        \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
      8. pow1/36.9%

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

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}}} \]
      10. *-un-lft-identity5.6%

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

        \[\leadsto \frac{\color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
      12. pow-pow36.7%

        \[\leadsto \frac{\color{blue}{{\left(1 + x\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
      13. metadata-eval36.7%

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{x + 1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
      16. *-rgt-identity36.7%

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

        \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
      18. pow-pow36.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
    13. Taylor expanded in x around inf 99.6%

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

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

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

    if 4.9999999999999999e-13 < (-.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. Add Preprocessing
    3. 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. pow1/299.4%

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

        \[\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.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) \]
    4. 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)} \]
    5. Step-by-step derivation
      1. associate-+l-99.8%

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

        \[\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.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-99.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-udef99.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-in99.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-eval99.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-lft99.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-eval99.6%

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

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

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

Alternative 4: 99.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 5 \cdot 10^{-13}:\\ \;\;\;\;0.5 \cdot {x}^{-1.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)))) 5e-13)
   (* 0.5 (pow x -1.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)))) <= 5e-13) {
		tmp = 0.5 * pow(x, -1.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)))) <= 5d-13) then
        tmp = 0.5d0 * (x ** (-1.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)))) <= 5e-13) {
		tmp = 0.5 * Math.pow(x, -1.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)))) <= 5e-13:
		tmp = 0.5 * math.pow(x, -1.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)))) <= 5e-13)
		tmp = Float64(0.5 * (x ^ -1.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)))) <= 5e-13)
		tmp = 0.5 * (x ^ -1.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], 5e-13], N[(0.5 * N[Power[x, -1.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}
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 5 \cdot 10^{-13}:\\
\;\;\;\;0.5 \cdot {x}^{-1.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)))) < 4.9999999999999999e-13

    1. Initial program 36.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.9999999999999999e-13 < (-.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. Add Preprocessing
    3. 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. pow1/299.4%

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

        \[\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.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) \]
    4. 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)} \]
    5. Step-by-step derivation
      1. associate-+l-99.8%

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

        \[\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.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-99.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-udef99.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-in99.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-eval99.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-lft99.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-eval99.6%

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

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

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

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

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

Alternative 5: 99.0% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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-def58.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-58.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-udef58.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-in58.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-eval58.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-lft58.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-eval58.1%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
    8. pow1/358.6%

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

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

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

      \[\leadsto \frac{\color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
    12. pow-pow71.7%

      \[\leadsto \frac{\color{blue}{{\left(1 + x\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
    13. metadata-eval71.7%

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{x + 1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
    16. *-rgt-identity71.7%

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

      \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
    18. pow-pow71.7%

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

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

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

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

    \[\leadsto \color{blue}{\frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x \cdot \left(x + 1\right)}}} \]
  9. Step-by-step derivation
    1. flip--72.4%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}}{\sqrt{x \cdot \left(x + 1\right)}} \]
  13. Step-by-step derivation
    1. expm1-log1p-u89.1%

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

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

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{1}{\sqrt{x \cdot \left(x + 1\right)} \cdot \left(\sqrt{1 + x} + \sqrt{x}\right)}}\right)} - 1 \]
    4. associate-/r*67.2%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}}{\sqrt{1 + x} + \sqrt{x}}} \]
    3. associate-/r*99.1%

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

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

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

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

Alternative 6: 98.6% accurate, 1.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.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. Add Preprocessing
    3. 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) \]
    4. 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)} \]
    5. 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}} \]
    6. Simplified100.0%

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

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

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

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

    if 1 < x

    1. Initial program 37.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      12. pow-flip37.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. +-commutative37.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-eval37.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) \]
    4. Applied egg-rr37.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)} \]
    5. Step-by-step derivation
      1. associate-+l-37.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 96.7% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;\frac{1}{\sqrt{x}}\\

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


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

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. 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) \]
    4. 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)} \]
    5. 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}} \]
    6. Simplified100.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
      8. pow1/399.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
      18. pow-pow99.5%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x \cdot \left(x + 1\right)}}} \]
    9. Taylor expanded in x around 0 93.7%

      \[\leadsto \frac{\color{blue}{1}}{\sqrt{x \cdot \left(x + 1\right)}} \]
    10. Taylor expanded in x around 0 93.7%

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

    if 0.5 < x

    1. Initial program 37.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      12. pow-flip37.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. +-commutative37.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-eval37.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) \]
    4. Applied egg-rr37.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)} \]
    5. Step-by-step derivation
      1. associate-+l-37.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 98.4% accurate, 1.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.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. Add Preprocessing
    3. 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) \]
    4. 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)} \]
    5. 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}} \]
    6. Simplified100.0%

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

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

    if 0.680000000000000049 < x

    1. Initial program 37.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left({x}^{-0.5} - \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      12. pow-flip37.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. +-commutative37.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-eval37.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) \]
    4. Applied egg-rr37.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)} \]
    5. Step-by-step derivation
      1. associate-+l-37.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 51.1% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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-def58.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-58.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-udef58.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-in58.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-eval58.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-lft58.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-eval58.1%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
    8. pow1/358.6%

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

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

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

      \[\leadsto \frac{\color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
    12. pow-pow71.7%

      \[\leadsto \frac{\color{blue}{{\left(1 + x\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
    13. metadata-eval71.7%

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{x + 1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
    16. *-rgt-identity71.7%

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

      \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
    18. pow-pow71.7%

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

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

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

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

    \[\leadsto \color{blue}{\frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x \cdot \left(x + 1\right)}}} \]
  9. Taylor expanded in x around 0 68.0%

    \[\leadsto \frac{\color{blue}{1}}{\sqrt{x \cdot \left(x + 1\right)}} \]
  10. Taylor expanded in x around 0 54.2%

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

    \[\leadsto \frac{1}{\sqrt{x}} \]
  12. Add Preprocessing

Alternative 10: 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 71.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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-def58.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-58.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-udef58.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-in58.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-eval58.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-lft58.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-eval58.1%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
    8. pow1/358.6%

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

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

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

      \[\leadsto \frac{\color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
    12. pow-pow71.7%

      \[\leadsto \frac{\color{blue}{{\left(1 + x\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
    13. metadata-eval71.7%

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{x + 1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
    16. *-rgt-identity71.7%

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

      \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
    18. pow-pow71.7%

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

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

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

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

    \[\leadsto \color{blue}{\frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x \cdot \left(x + 1\right)}}} \]
  9. Taylor expanded in x around 0 68.0%

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

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

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

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

    \[\leadsto \frac{1}{x + 0.5} \]
  14. Add Preprocessing

Alternative 11: 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 71.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\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-def58.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-58.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-udef58.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-in58.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-eval58.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-lft58.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-eval58.1%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
    8. pow1/358.6%

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

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

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

      \[\leadsto \frac{\color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
    12. pow-pow71.7%

      \[\leadsto \frac{\color{blue}{{\left(1 + x\right)}^{\left(1.5 \cdot 0.3333333333333333\right)}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
    13. metadata-eval71.7%

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{x + 1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt[3]{{\left(1 + x\right)}^{1.5}}} \]
    16. *-rgt-identity71.7%

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

      \[\leadsto \frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{{\left({\left(1 + x\right)}^{1.5}\right)}^{0.3333333333333333}}} \]
    18. pow-pow71.7%

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

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

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

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

    \[\leadsto \color{blue}{\frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x \cdot \left(x + 1\right)}}} \]
  9. Taylor expanded in x around 0 68.0%

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

    \[\leadsto \color{blue}{\frac{1}{x}} \]
  11. Final simplification7.4%

    \[\leadsto \frac{1}{x} \]
  12. Add Preprocessing

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