2isqrt (example 3.6)

Percentage Accurate: 69.1% → 99.8%
Time: 18.3s
Alternatives: 14
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 14 alternatives:

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

Initial Program: 69.1% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-1}{\sqrt{1 + x}}\\ \mathbf{if}\;\frac{1}{\sqrt{x}} + t_0 \leq 2 \cdot 10^{-10}:\\ \;\;\;\;\mathsf{fma}\left(0.3125, {x}^{-3.5}, 0.5 \cdot {x}^{-1.5}\right) + -0.375 \cdot {x}^{-2.5}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} + t_0\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (/ -1.0 (sqrt (+ 1.0 x)))))
   (if (<= (+ (/ 1.0 (sqrt x)) t_0) 2e-10)
     (+ (fma 0.3125 (pow x -3.5) (* 0.5 (pow x -1.5))) (* -0.375 (pow x -2.5)))
     (+ (pow x -0.5) t_0))))
double code(double x) {
	double t_0 = -1.0 / sqrt((1.0 + x));
	double tmp;
	if (((1.0 / sqrt(x)) + t_0) <= 2e-10) {
		tmp = fma(0.3125, pow(x, -3.5), (0.5 * pow(x, -1.5))) + (-0.375 * pow(x, -2.5));
	} else {
		tmp = pow(x, -0.5) + t_0;
	}
	return tmp;
}
function code(x)
	t_0 = Float64(-1.0 / sqrt(Float64(1.0 + x)))
	tmp = 0.0
	if (Float64(Float64(1.0 / sqrt(x)) + t_0) <= 2e-10)
		tmp = Float64(fma(0.3125, (x ^ -3.5), Float64(0.5 * (x ^ -1.5))) + Float64(-0.375 * (x ^ -2.5)));
	else
		tmp = Float64((x ^ -0.5) + t_0);
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[(-1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], 2e-10], N[(N[(0.3125 * N[Power[x, -3.5], $MachinePrecision] + N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[Power[x, -2.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -0.5], $MachinePrecision] + t$95$0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-1}{\sqrt{1 + x}}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + t_0 \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(0.3125, {x}^{-3.5}, 0.5 \cdot {x}^{-1.5}\right) + -0.375 \cdot {x}^{-2.5}\\

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


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

    1. Initial program 39.4%

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

        \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \frac{1}{\sqrt{x + 1}} \]
      2. reciprocal-define37.9%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
      3. +-commutative37.9%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified37.9%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt25.2%

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

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff4.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, -1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right) + \mathsf{fma}\left(-1, \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right), 1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right)} \]
    6. Applied egg-rr39.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-0.375 \cdot \sqrt{\frac{1}{{x}^{5}}} + \left(0.3125 \cdot \sqrt{\frac{1}{{x}^{7}}} + 0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\right)} \]
    10. Step-by-step derivation
      1. +-commutative68.6%

        \[\leadsto \color{blue}{\left(0.3125 \cdot \sqrt{\frac{1}{{x}^{7}}} + 0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\right) + -0.375 \cdot \sqrt{\frac{1}{{x}^{5}}}} \]
      2. *-un-lft-identity68.6%

        \[\leadsto \color{blue}{1 \cdot \left(0.3125 \cdot \sqrt{\frac{1}{{x}^{7}}} + 0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\right)} + -0.375 \cdot \sqrt{\frac{1}{{x}^{5}}} \]
      3. fma-def68.6%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(1, \mathsf{fma}\left(0.3125, {x}^{-3.5}, {x}^{-1.5} \cdot 0.5\right), -0.375 \cdot {x}^{-2.5}\right)} \]
    12. Step-by-step derivation
      1. fma-udef99.9%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(0.3125, {x}^{-3.5}, {x}^{-1.5} \cdot 0.5\right)} + -0.375 \cdot {x}^{-2.5} \]
      3. *-commutative99.9%

        \[\leadsto \mathsf{fma}\left(0.3125, {x}^{-3.5}, \color{blue}{0.5 \cdot {x}^{-1.5}}\right) + -0.375 \cdot {x}^{-2.5} \]
    13. Simplified99.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.3125, {x}^{-3.5}, 0.5 \cdot {x}^{-1.5}\right) + -0.375 \cdot {x}^{-2.5}} \]

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

    1. Initial program 99.6%

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

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

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
      3. +-commutative39.3%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified39.3%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt39.3%

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
      3. *-commutative39.3%

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff39.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(x + 1\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(x + 1\right)}^{-0.5}\right)\right)} \]
      11. expm1-log1p99.9%

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{\sqrt{1 + x}}} \]
      4. +-commutative99.9%

        \[\leadsto {x}^{-0.5} - \frac{1}{\sqrt{\color{blue}{x + 1}}} \]
    10. Applied egg-rr99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 2 \cdot 10^{-10}:\\ \;\;\;\;\mathsf{fma}\left(0.3125, {x}^{-3.5}, 0.5 \cdot {x}^{-1.5}\right) + -0.375 \cdot {x}^{-2.5}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-0.5} + \frac{-1}{\sqrt{1 + x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 83.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 64000000:\\ \;\;\;\;{x}^{-0.5} - \frac{\sqrt[3]{{\left(1 + x\right)}^{-0.5}}}{\sqrt[3]{1 + x}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 64000000.0)
   (- (pow x -0.5) (/ (cbrt (pow (+ 1.0 x) -0.5)) (cbrt (+ 1.0 x))))
   (* 0.5 (sqrt (/ 1.0 (pow x 3.0))))))
double code(double x) {
	double tmp;
	if (x <= 64000000.0) {
		tmp = pow(x, -0.5) - (cbrt(pow((1.0 + x), -0.5)) / cbrt((1.0 + x)));
	} else {
		tmp = 0.5 * sqrt((1.0 / pow(x, 3.0)));
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (x <= 64000000.0) {
		tmp = Math.pow(x, -0.5) - (Math.cbrt(Math.pow((1.0 + x), -0.5)) / Math.cbrt((1.0 + x)));
	} else {
		tmp = 0.5 * Math.sqrt((1.0 / Math.pow(x, 3.0)));
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= 64000000.0)
		tmp = Float64((x ^ -0.5) - Float64(cbrt((Float64(1.0 + x) ^ -0.5)) / cbrt(Float64(1.0 + x))));
	else
		tmp = Float64(0.5 * sqrt(Float64(1.0 / (x ^ 3.0))));
	end
	return tmp
end
code[x_] := If[LessEqual[x, 64000000.0], N[(N[Power[x, -0.5], $MachinePrecision] - N[(N[Power[N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision], 1/3], $MachinePrecision] / N[Power[N[(1.0 + x), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(1.0 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 64000000:\\
\;\;\;\;{x}^{-0.5} - \frac{\sqrt[3]{{\left(1 + x\right)}^{-0.5}}}{\sqrt[3]{1 + x}}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\\


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

    1. Initial program 99.4%

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

        \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \frac{1}{\sqrt{x + 1}} \]
      2. reciprocal-define39.0%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
      3. +-commutative39.0%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified39.0%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt39.1%

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
      3. *-commutative39.1%

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff39.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(x + 1\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(x + 1\right)}^{-0.5}\right)\right)} \]
      11. expm1-log1p99.8%

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{1 \cdot 1}{\color{blue}{\sqrt{1 + x}}} \]
      5. add-cbrt-cube99.6%

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

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{1 \cdot 1}{\sqrt[3]{\left(1 + x\right) \cdot \color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right)}}} \]
      10. cbrt-prod99.6%

        \[\leadsto {x}^{-0.5} - \frac{1 \cdot 1}{\color{blue}{\sqrt[3]{1 + x} \cdot \sqrt[3]{\mathsf{hypot}\left(1, \sqrt{x}\right)}}} \]
      11. hypot-udef99.6%

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

        \[\leadsto {x}^{-0.5} - \frac{1 \cdot 1}{\sqrt[3]{1 + x} \cdot \sqrt[3]{\sqrt{\color{blue}{1} + \sqrt{x} \cdot \sqrt{x}}}} \]
      13. add-sqr-sqrt99.6%

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{1}{\sqrt[3]{1 + x}} \cdot \frac{\sqrt[3]{1}}{\sqrt[3]{\sqrt{\color{blue}{1 \cdot 1} + x}}} \]
      17. add-sqr-sqrt99.6%

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

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

    if 6.4e7 < x

    1. Initial program 39.1%

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

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

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
      3. +-commutative38.2%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified38.2%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt25.3%

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
      3. *-commutative25.3%

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff4.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 83.5% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\\


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

    1. Initial program 99.4%

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

        \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \frac{1}{\sqrt{x + 1}} \]
      2. reciprocal-define39.0%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
      3. +-commutative39.0%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified39.0%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt39.1%

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
      3. *-commutative39.1%

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff39.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(x + 1\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(x + 1\right)}^{-0.5}\right)\right)} \]
      11. expm1-log1p99.8%

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

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

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

    if 3e8 < x

    1. Initial program 39.1%

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

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

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
      3. +-commutative38.2%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified38.2%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt25.3%

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
      3. *-commutative25.3%

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff4.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 82.5% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\\


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

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. reciprocal-define39.4%

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

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
      3. +-commutative39.5%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified39.5%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt39.5%

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
      3. *-commutative39.5%

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff39.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(x + 1\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(x + 1\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(x + 1\right)}^{-0.5}\right)\right)} \]
      11. expm1-log1p100.0%

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{\sqrt{1 + x}}} \]
      4. +-commutative100.0%

        \[\leadsto {x}^{-0.5} - \frac{1}{\sqrt{\color{blue}{x + 1}}} \]
    10. Applied egg-rr100.0%

      \[\leadsto {x}^{-0.5} - \color{blue}{\frac{1}{\sqrt{x + 1}}} \]
    11. Taylor expanded in x around 0 98.9%

      \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{1 + 0.5 \cdot x}} \]
    12. Step-by-step derivation
      1. *-commutative98.9%

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

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

    if 1.69999999999999996 < x

    1. Initial program 40.3%

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

        \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \frac{1}{\sqrt{x + 1}} \]
      2. reciprocal-define37.8%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
      3. +-commutative37.8%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified37.8%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt25.3%

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
      3. *-commutative25.3%

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff5.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, -1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right) + \mathsf{fma}\left(-1, \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right), 1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right)} \]
    6. Applied egg-rr40.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 69.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 4.4:\\ \;\;\;\;{x}^{-0.5} - \frac{1}{1 + x \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{reciprocal}\left(\left({x}^{3}\right)\right)} \cdot 1.5\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 4.4)
   (- (pow x -0.5) (/ 1.0 (+ 1.0 (* x 0.5))))
   (* (sqrt (reciprocal (pow x 3.0))) 1.5)))
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{reciprocal}\left(\left({x}^{3}\right)\right)} \cdot 1.5\\


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

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. reciprocal-define39.4%

        \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \frac{1}{\sqrt{x + 1}} \]
      2. reciprocal-define39.4%

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

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified39.4%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt39.4%

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

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff39.4%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(x + 1\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(x + 1\right)}^{-0.5}\right)\right)} \]
      11. expm1-log1p100.0%

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{\sqrt{1 + x}}} \]
      4. +-commutative100.0%

        \[\leadsto {x}^{-0.5} - \frac{1}{\sqrt{\color{blue}{x + 1}}} \]
    10. Applied egg-rr100.0%

      \[\leadsto {x}^{-0.5} - \color{blue}{\frac{1}{\sqrt{x + 1}}} \]
    11. Taylor expanded in x around 0 98.3%

      \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{1 + 0.5 \cdot x}} \]
    12. Step-by-step derivation
      1. *-commutative98.3%

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

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

    if 4.4000000000000004 < x

    1. Initial program 39.9%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. reciprocal-define4.8%

        \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \frac{1}{\sqrt{x + 1}} \]
      2. reciprocal-define37.8%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
      3. +-commutative37.8%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified37.8%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt25.2%

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

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff5.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, -1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right) + \mathsf{fma}\left(-1, \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right), 1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right)} \]
    6. Applied egg-rr39.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{1.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
    11. Step-by-step derivation
      1. reciprocal-define42.2%

        \[\leadsto 1.5 \cdot \sqrt{\color{blue}{\mathsf{reciprocal}\left(\left({x}^{3}\right)\right)}} \]
    12. Simplified42.2%

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

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

Alternative 6: 73.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.7:\\ \;\;\;\;{x}^{-0.5} - \frac{1}{1 + x \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{\mathsf{reciprocal}\left(\left({x}^{3}\right)\right)}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 1.7)
   (- (pow x -0.5) (/ 1.0 (+ 1.0 (* x 0.5))))
   (* 0.5 (sqrt (reciprocal (pow x 3.0))))))
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\mathsf{reciprocal}\left(\left({x}^{3}\right)\right)}\\


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

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. reciprocal-define39.4%

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

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
      3. +-commutative39.5%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified39.5%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt39.5%

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
      3. *-commutative39.5%

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff39.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \left(e^{\mathsf{log1p}\left({\left(x + 1\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(x + 1\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(x + 1\right)}^{-0.5}\right)\right)} \]
      11. expm1-log1p100.0%

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{\sqrt{1 + x}}} \]
      4. +-commutative100.0%

        \[\leadsto {x}^{-0.5} - \frac{1}{\sqrt{\color{blue}{x + 1}}} \]
    10. Applied egg-rr100.0%

      \[\leadsto {x}^{-0.5} - \color{blue}{\frac{1}{\sqrt{x + 1}}} \]
    11. Taylor expanded in x around 0 98.9%

      \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{1 + 0.5 \cdot x}} \]
    12. Step-by-step derivation
      1. *-commutative98.9%

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

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

    if 1.69999999999999996 < x

    1. Initial program 40.3%

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

        \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \frac{1}{\sqrt{x + 1}} \]
      2. reciprocal-define37.8%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
      3. +-commutative37.8%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified37.8%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt25.3%

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
      3. *-commutative25.3%

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff5.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, -1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right) + \mathsf{fma}\left(-1, \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right), 1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right)} \]
    6. Applied egg-rr40.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - e^{-0.5 \cdot \color{blue}{\mathsf{log1p}\left(x\right)}} \]
    10. Applied egg-rr6.7%

      \[\leadsto {x}^{-0.5} - \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right)}} \]
    11. Simplified6.6%

      \[\leadsto {x}^{-0.5} - \color{blue}{{\left(e^{-0.5}\right)}^{\left(\mathsf{log1p}\left(x\right)\right)}} \]
    12. Taylor expanded in x around inf 67.2%

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

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

        \[\leadsto \sqrt{\color{blue}{\mathsf{reciprocal}\left(\left({x}^{3}\right)\right)}} \cdot 0.5 \]
    14. Simplified49.6%

      \[\leadsto \color{blue}{\sqrt{\mathsf{reciprocal}\left(\left({x}^{3}\right)\right)} \cdot 0.5} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification73.3%

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

Alternative 7: 68.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 96.7%

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

        \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \frac{1}{\sqrt{x + 1}} \]
      2. reciprocal-define37.7%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
      3. +-commutative37.7%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified37.7%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt37.8%

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
      3. *-commutative37.8%

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff38.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, -1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right) + \mathsf{fma}\left(-1, \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right), 1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right)} \]
    6. Applied egg-rr97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{\sqrt{1 + x}}} \]
      4. +-commutative96.9%

        \[\leadsto {x}^{-0.5} - \frac{1}{\sqrt{\color{blue}{x + 1}}} \]
    10. Applied egg-rr96.9%

      \[\leadsto {x}^{-0.5} - \color{blue}{\frac{1}{\sqrt{x + 1}}} \]
    11. Taylor expanded in x around 0 93.6%

      \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{1 + 0.5 \cdot x}} \]
    12. Step-by-step derivation
      1. *-commutative93.6%

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

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

    if 2.20000000000000008e23 < x

    1. Initial program 39.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. reciprocal-define4.4%

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

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
      3. +-commutative39.6%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified39.6%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt26.1%

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
      3. *-commutative26.1%

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff4.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{\sqrt{1 + x}}} \]
      4. +-commutative32.1%

        \[\leadsto {x}^{-0.5} - \frac{1}{\sqrt{\color{blue}{x + 1}}} \]
    10. Applied egg-rr32.1%

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

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
    12. Step-by-step derivation
      1. reciprocal-define5.2%

        \[\leadsto \sqrt{\color{blue}{\mathsf{reciprocal}\left(x\right)}} \]
    13. Simplified5.2%

      \[\leadsto \color{blue}{\sqrt{\mathsf{reciprocal}\left(x\right)}} \]
    14. Step-by-step derivation
      1. reciprocal-define5.2%

        \[\leadsto \sqrt{\color{blue}{\frac{1}{x}}} \]
      2. pow1/25.2%

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

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

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

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

        \[\leadsto \color{blue}{{x}^{\left(\frac{-0.5}{2}\right)} \cdot {x}^{\left(\frac{-0.5}{2}\right)}} \]
      7. pow-prod-down40.4%

        \[\leadsto \color{blue}{{\left(x \cdot x\right)}^{\left(\frac{-0.5}{2}\right)}} \]
      8. pow240.4%

        \[\leadsto {\color{blue}{\left({x}^{2}\right)}}^{\left(\frac{-0.5}{2}\right)} \]
      9. metadata-eval40.4%

        \[\leadsto {\left({x}^{2}\right)}^{\color{blue}{-0.25}} \]
    15. Applied egg-rr40.4%

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

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

Alternative 8: 66.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2.2 \cdot 10^{+23}:\\ \;\;\;\;{x}^{-0.5} - \frac{1}{1 + x \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{{x}^{-1.5}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 2.2e+23)
   (- (pow x -0.5) (/ 1.0 (+ 1.0 (* x 0.5))))
   (cbrt (pow x -1.5))))
double code(double x) {
	double tmp;
	if (x <= 2.2e+23) {
		tmp = pow(x, -0.5) - (1.0 / (1.0 + (x * 0.5)));
	} else {
		tmp = cbrt(pow(x, -1.5));
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (x <= 2.2e+23) {
		tmp = Math.pow(x, -0.5) - (1.0 / (1.0 + (x * 0.5)));
	} else {
		tmp = Math.cbrt(Math.pow(x, -1.5));
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= 2.2e+23)
		tmp = Float64((x ^ -0.5) - Float64(1.0 / Float64(1.0 + Float64(x * 0.5))));
	else
		tmp = cbrt((x ^ -1.5));
	end
	return tmp
end
code[x_] := If[LessEqual[x, 2.2e+23], N[(N[Power[x, -0.5], $MachinePrecision] - N[(1.0 / N[(1.0 + N[(x * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[N[Power[x, -1.5], $MachinePrecision], 1/3], $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{{x}^{-1.5}}\\


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

    1. Initial program 96.7%

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

        \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \frac{1}{\sqrt{x + 1}} \]
      2. reciprocal-define37.7%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
      3. +-commutative37.7%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified37.7%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt37.8%

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
      3. *-commutative37.8%

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff38.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, -1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right) + \mathsf{fma}\left(-1, \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right), 1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right)} \]
    6. Applied egg-rr97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{\sqrt{1 + x}}} \]
      4. +-commutative96.9%

        \[\leadsto {x}^{-0.5} - \frac{1}{\sqrt{\color{blue}{x + 1}}} \]
    10. Applied egg-rr96.9%

      \[\leadsto {x}^{-0.5} - \color{blue}{\frac{1}{\sqrt{x + 1}}} \]
    11. Taylor expanded in x around 0 93.6%

      \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{1 + 0.5 \cdot x}} \]
    12. Step-by-step derivation
      1. *-commutative93.6%

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

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

    if 2.20000000000000008e23 < x

    1. Initial program 39.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. reciprocal-define4.4%

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

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
      3. +-commutative39.6%

        \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
    3. Simplified39.6%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. add-sqr-sqrt26.1%

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

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
      3. *-commutative26.1%

        \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
      4. prod-diff4.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{\sqrt{1 + x}}} \]
      4. +-commutative32.1%

        \[\leadsto {x}^{-0.5} - \frac{1}{\sqrt{\color{blue}{x + 1}}} \]
    10. Applied egg-rr32.1%

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

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
    12. Step-by-step derivation
      1. reciprocal-define5.2%

        \[\leadsto \sqrt{\color{blue}{\mathsf{reciprocal}\left(x\right)}} \]
    13. Simplified5.2%

      \[\leadsto \color{blue}{\sqrt{\mathsf{reciprocal}\left(x\right)}} \]
    14. Step-by-step derivation
      1. reciprocal-define5.2%

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

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left(\sqrt{\frac{1}{x}}\right)}^{3}}} \]
      4. reciprocal-define36.6%

        \[\leadsto \sqrt[3]{{\left(\sqrt{\color{blue}{\mathsf{reciprocal}\left(x\right)}}\right)}^{3}} \]
      5. reciprocal-define36.6%

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

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

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

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

        \[\leadsto \sqrt[3]{{\left({x}^{\color{blue}{-0.5}}\right)}^{3}} \]
      10. pow-pow36.6%

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

        \[\leadsto \sqrt[3]{{x}^{\color{blue}{-1.5}}} \]
      12. pow1/336.6%

        \[\leadsto \color{blue}{{\left({x}^{-1.5}\right)}^{0.3333333333333333}} \]
    15. Applied egg-rr36.6%

      \[\leadsto \color{blue}{{\left({x}^{-1.5}\right)}^{0.3333333333333333}} \]
    16. Step-by-step derivation
      1. unpow1/336.6%

        \[\leadsto \color{blue}{\sqrt[3]{{x}^{-1.5}}} \]
    17. Simplified36.6%

      \[\leadsto \color{blue}{\sqrt[3]{{x}^{-1.5}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification65.8%

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

Alternative 9: 52.7% accurate, 1.9× speedup?

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

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

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

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

      \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
    3. +-commutative38.6%

      \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
  3. Simplified38.6%

    \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. add-sqr-sqrt32.1%

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

      \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    3. *-commutative32.1%

      \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
    4. prod-diff21.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, -1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right) + \mathsf{fma}\left(-1, \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right), 1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right)} \]
  6. Applied egg-rr69.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{\sqrt{1 + x}}} \]
    4. +-commutative65.3%

      \[\leadsto {x}^{-0.5} - \frac{1}{\sqrt{\color{blue}{x + 1}}} \]
  10. Applied egg-rr65.3%

    \[\leadsto {x}^{-0.5} - \color{blue}{\frac{1}{\sqrt{x + 1}}} \]
  11. Taylor expanded in x around 0 50.5%

    \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{1 + 0.5 \cdot x}} \]
  12. Step-by-step derivation
    1. *-commutative50.5%

      \[\leadsto {x}^{-0.5} - \frac{1}{1 + \color{blue}{x \cdot 0.5}} \]
  13. Simplified50.5%

    \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{1 + x \cdot 0.5}} \]
  14. Final simplification50.5%

    \[\leadsto {x}^{-0.5} - \frac{1}{1 + x \cdot 0.5} \]
  15. Add Preprocessing

Alternative 10: 51.6% accurate, 1.9× speedup?

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

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

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

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

      \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
    3. +-commutative38.6%

      \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
  3. Simplified38.6%

    \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. add-sqr-sqrt32.1%

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

      \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    3. *-commutative32.1%

      \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
    4. prod-diff21.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, -1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right) + \mathsf{fma}\left(-1, \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right), 1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right)} \]
  6. Applied egg-rr69.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto {x}^{-0.5} - \left(1 + x \cdot -0.5\right) \]
  11. Add Preprocessing

Alternative 11: 51.0% accurate, 2.0× speedup?

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

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

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

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

      \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
    3. +-commutative38.6%

      \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
  3. Simplified38.6%

    \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. add-sqr-sqrt32.1%

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

      \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    3. *-commutative32.1%

      \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
    4. prod-diff21.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, -1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right) + \mathsf{fma}\left(-1, \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right), 1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right)} \]
  6. Applied egg-rr69.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{\sqrt{1 + x}}} \]
    4. +-commutative65.3%

      \[\leadsto {x}^{-0.5} - \frac{1}{\sqrt{\color{blue}{x + 1}}} \]
  10. Applied egg-rr65.3%

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

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

      \[\leadsto \sqrt{\color{blue}{\mathsf{reciprocal}\left(x\right)}} \]
    2. unpow1/222.6%

      \[\leadsto \color{blue}{{\mathsf{reciprocal}\left(x\right)}^{0.5}} \]
    3. rem-exp-log22.6%

      \[\leadsto {\mathsf{reciprocal}\left(\color{blue}{\left(e^{\log x}\right)}\right)}^{0.5} \]
    4. reciprocal-define45.2%

      \[\leadsto {\color{blue}{\left(\frac{1}{e^{\log x}}\right)}}^{0.5} \]
    5. exp-neg45.2%

      \[\leadsto {\color{blue}{\left(e^{-\log x}\right)}}^{0.5} \]
    6. exp-prod45.2%

      \[\leadsto \color{blue}{e^{\left(-\log x\right) \cdot 0.5}} \]
    7. distribute-lft-neg-out45.2%

      \[\leadsto e^{\color{blue}{-\log x \cdot 0.5}} \]
    8. distribute-rgt-neg-in45.2%

      \[\leadsto e^{\color{blue}{\log x \cdot \left(-0.5\right)}} \]
    9. metadata-eval45.2%

      \[\leadsto e^{\log x \cdot \color{blue}{-0.5}} \]
    10. exp-to-pow48.5%

      \[\leadsto \color{blue}{{x}^{-0.5}} \]
  13. Simplified48.5%

    \[\leadsto \color{blue}{{x}^{-0.5}} \]
  14. Final simplification48.5%

    \[\leadsto {x}^{-0.5} \]
  15. Add Preprocessing

Alternative 12: 22.6% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) \end{array} \]
(FPCore (x) :precision binary64 (reciprocal (sqrt x)))
\begin{array}{l}

\\
\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)
\end{array}
Derivation
  1. Initial program 68.8%

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

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

      \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
    3. +-commutative38.6%

      \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
  3. Simplified38.6%

    \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. add-sqr-sqrt32.1%

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

      \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    3. *-commutative32.1%

      \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
    4. prod-diff21.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, -1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right) + \mathsf{fma}\left(-1, \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right), 1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right)} \]
  6. Applied egg-rr69.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{\sqrt{1 + x}}} \]
    4. +-commutative65.3%

      \[\leadsto {x}^{-0.5} - \frac{1}{\sqrt{\color{blue}{x + 1}}} \]
  10. Applied egg-rr65.3%

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

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

      \[\leadsto \sqrt{\color{blue}{\mathsf{reciprocal}\left(x\right)}} \]
  13. Simplified22.6%

    \[\leadsto \color{blue}{\sqrt{\mathsf{reciprocal}\left(x\right)}} \]
  14. Step-by-step derivation
    1. reciprocal-define48.5%

      \[\leadsto \sqrt{\color{blue}{\frac{1}{x}}} \]
    2. pow1/248.5%

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

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

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

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

      \[\leadsto {\color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right)}}^{-0.5} \]
    7. unpow-prod-down48.1%

      \[\leadsto \color{blue}{{\left(\sqrt{x}\right)}^{-0.5} \cdot {\left(\sqrt{x}\right)}^{-0.5}} \]
  15. Applied egg-rr48.1%

    \[\leadsto \color{blue}{{\left(\sqrt{x}\right)}^{-0.5} \cdot {\left(\sqrt{x}\right)}^{-0.5}} \]
  16. Step-by-step derivation
    1. pow-sqr48.4%

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

      \[\leadsto {\left(\sqrt{x}\right)}^{\color{blue}{-1}} \]
    3. unpow-148.4%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{x}}} \]
    4. reciprocal-define21.6%

      \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \]
  17. Simplified21.6%

    \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \]
  18. Final simplification21.6%

    \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) \]
  19. Add Preprocessing

Alternative 13: 23.4% accurate, 2.1× speedup?

\[\begin{array}{l} \\ \sqrt{\mathsf{reciprocal}\left(x\right)} \end{array} \]
(FPCore (x) :precision binary64 (sqrt (reciprocal x)))
\begin{array}{l}

\\
\sqrt{\mathsf{reciprocal}\left(x\right)}
\end{array}
Derivation
  1. Initial program 68.8%

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

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

      \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
    3. +-commutative38.6%

      \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
  3. Simplified38.6%

    \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
  4. Add Preprocessing
  5. Step-by-step derivation
    1. add-sqr-sqrt32.1%

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

      \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
    3. *-commutative32.1%

      \[\leadsto \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} \cdot \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)} - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right) \cdot 1} \]
    4. prod-diff21.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, \sqrt{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right)}, -1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right) + \mathsf{fma}\left(-1, \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right), 1 \cdot \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)\right)} \]
  6. Applied egg-rr69.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{\sqrt{1 + x}}} \]
    4. +-commutative65.3%

      \[\leadsto {x}^{-0.5} - \frac{1}{\sqrt{\color{blue}{x + 1}}} \]
  10. Applied egg-rr65.3%

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

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

      \[\leadsto \sqrt{\color{blue}{\mathsf{reciprocal}\left(x\right)}} \]
  13. Simplified22.6%

    \[\leadsto \color{blue}{\sqrt{\mathsf{reciprocal}\left(x\right)}} \]
  14. Final simplification22.6%

    \[\leadsto \sqrt{\mathsf{reciprocal}\left(x\right)} \]
  15. Add Preprocessing

Alternative 14: 1.9% accurate, 209.0× speedup?

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

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

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

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

      \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x + 1}\right)\right)} \]
    3. +-commutative38.6%

      \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{\color{blue}{1 + x}}\right)\right) \]
  3. Simplified38.6%

    \[\leadsto \color{blue}{\mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \mathsf{reciprocal}\left(\left(\sqrt{1 + x}\right)\right)} \]
  4. Add Preprocessing
  5. Taylor expanded in x around 0 20.2%

    \[\leadsto \mathsf{reciprocal}\left(\left(\sqrt{x}\right)\right) - \color{blue}{1} \]
  6. Taylor expanded in x around inf 2.0%

    \[\leadsto \color{blue}{-1} \]
  7. Final simplification2.0%

    \[\leadsto -1 \]
  8. Add Preprocessing

Developer target: 98.9% accurate, 1.0× speedup?

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

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

Reproduce

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