2isqrt (example 3.6)

Percentage Accurate: 38.1% → 99.6%
Time: 15.1s
Alternatives: 4
Speedup: 2.0×

Specification

?
\[x > 1 \land x < 10^{+308}\]
\[\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 4 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: 38.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.6% accurate, 1.0× speedup?

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

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

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. flip--36.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 79.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.5e7 < x

    1. Initial program 35.0%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--35.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
    10. Step-by-step derivation
      1. unpow-163.9%

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

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

        \[\leadsto 0.5 \cdot \sqrt{{\left(e^{\color{blue}{3 \cdot \log x}}\right)}^{-1}} \]
      4. exp-prod62.6%

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

        \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{-1 \cdot \left(3 \cdot \log x\right)}}} \]
      6. associate-*r*62.6%

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

        \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{-3} \cdot \log x}} \]
      8. *-commutative62.6%

        \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{\log x \cdot -3}}} \]
      9. exp-to-pow64.9%

        \[\leadsto 0.5 \cdot \sqrt{\color{blue}{{x}^{-3}}} \]
      10. metadata-eval64.9%

        \[\leadsto 0.5 \cdot \sqrt{{x}^{\color{blue}{\left(2 \cdot -1.5\right)}}} \]
      11. pow-sqr65.0%

        \[\leadsto 0.5 \cdot \sqrt{\color{blue}{{x}^{-1.5} \cdot {x}^{-1.5}}} \]
      12. rem-sqrt-square99.4%

        \[\leadsto 0.5 \cdot \color{blue}{\left|{x}^{-1.5}\right|} \]
      13. rem-square-sqrt99.0%

        \[\leadsto 0.5 \cdot \left|\color{blue}{\sqrt{{x}^{-1.5}} \cdot \sqrt{{x}^{-1.5}}}\right| \]
      14. fabs-sqr99.0%

        \[\leadsto 0.5 \cdot \color{blue}{\left(\sqrt{{x}^{-1.5}} \cdot \sqrt{{x}^{-1.5}}\right)} \]
      15. rem-square-sqrt99.4%

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

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

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

Alternative 3: 98.8% accurate, 1.0× speedup?

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

\\
\frac{\frac{1}{x}}{{x}^{-0.5} \cdot 1.5 + 2 \cdot \sqrt{x}}
\end{array}
Derivation
  1. Initial program 36.7%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. flip--36.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x}}{\color{blue}{e^{\left(-\log x\right) \cdot 0.5}} \cdot \left(-0.5 + 2\right) + 2 \cdot \sqrt{x}} \]
    8. distribute-lft-neg-out98.3%

      \[\leadsto \frac{\frac{1}{x}}{e^{\color{blue}{-\log x \cdot 0.5}} \cdot \left(-0.5 + 2\right) + 2 \cdot \sqrt{x}} \]
    9. distribute-rgt-neg-in98.3%

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

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

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

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

    \[\leadsto \frac{\frac{1}{x}}{\color{blue}{{x}^{-0.5} \cdot 1.5 + 2 \cdot \sqrt{x}}} \]
  16. Final simplification98.3%

    \[\leadsto \frac{\frac{1}{x}}{{x}^{-0.5} \cdot 1.5 + 2 \cdot \sqrt{x}} \]
  17. Add Preprocessing

Alternative 4: 97.9% accurate, 2.0× speedup?

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

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

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. flip--36.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
  10. Step-by-step derivation
    1. unpow-162.9%

      \[\leadsto 0.5 \cdot \sqrt{\color{blue}{{\left({x}^{3}\right)}^{-1}}} \]
    2. exp-to-pow60.7%

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

      \[\leadsto 0.5 \cdot \sqrt{{\left(e^{\color{blue}{3 \cdot \log x}}\right)}^{-1}} \]
    4. exp-prod61.6%

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

      \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{-1 \cdot \left(3 \cdot \log x\right)}}} \]
    6. associate-*r*61.6%

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

      \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{-3} \cdot \log x}} \]
    8. *-commutative61.6%

      \[\leadsto 0.5 \cdot \sqrt{e^{\color{blue}{\log x \cdot -3}}} \]
    9. exp-to-pow63.9%

      \[\leadsto 0.5 \cdot \sqrt{\color{blue}{{x}^{-3}}} \]
    10. metadata-eval63.9%

      \[\leadsto 0.5 \cdot \sqrt{{x}^{\color{blue}{\left(2 \cdot -1.5\right)}}} \]
    11. pow-sqr64.0%

      \[\leadsto 0.5 \cdot \sqrt{\color{blue}{{x}^{-1.5} \cdot {x}^{-1.5}}} \]
    12. rem-sqrt-square97.1%

      \[\leadsto 0.5 \cdot \color{blue}{\left|{x}^{-1.5}\right|} \]
    13. rem-square-sqrt96.7%

      \[\leadsto 0.5 \cdot \left|\color{blue}{\sqrt{{x}^{-1.5}} \cdot \sqrt{{x}^{-1.5}}}\right| \]
    14. fabs-sqr96.7%

      \[\leadsto 0.5 \cdot \color{blue}{\left(\sqrt{{x}^{-1.5}} \cdot \sqrt{{x}^{-1.5}}\right)} \]
    15. rem-square-sqrt97.1%

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

    \[\leadsto \color{blue}{0.5 \cdot {x}^{-1.5}} \]
  12. Final simplification97.1%

    \[\leadsto 0.5 \cdot {x}^{-1.5} \]
  13. Add Preprocessing

Developer target: 98.3% 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 2024027 
(FPCore (x)
  :name "2isqrt (example 3.6)"
  :precision binary64
  :pre (and (> x 1.0) (< x 1e+308))

  :herbie-target
  (/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))

  (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))