2isqrt (example 3.6)

Percentage Accurate: 38.8% → 99.9%
Time: 10.7s
Alternatives: 10
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 10 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.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 10^{+17}:\\
\;\;\;\;\frac{\frac{1}{\mathsf{fma}\left(x, x, x\right)}}{{x}^{-0.5} + {\left(x + 1\right)}^{-0.5}}\\

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


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

    1. Initial program 62.1%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--62.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. div-inv62.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e17 < x

    1. Initial program 38.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{1}{e^{\color{blue}{3 \cdot \log x}}}} \cdot 0.5 \]
      4. exp-neg67.4%

        \[\leadsto \sqrt{\color{blue}{e^{-3 \cdot \log x}}} \cdot 0.5 \]
      5. distribute-lft-neg-in67.4%

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

        \[\leadsto \sqrt{e^{\color{blue}{-3} \cdot \log x}} \cdot 0.5 \]
      7. *-commutative67.4%

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

        \[\leadsto \sqrt{\color{blue}{{x}^{-3}}} \cdot 0.5 \]
    9. Simplified70.4%

      \[\leadsto \color{blue}{\sqrt{{x}^{-3}} \cdot 0.5} \]
    10. Step-by-step derivation
      1. *-un-lft-identity70.4%

        \[\leadsto \color{blue}{\left(1 \cdot \sqrt{{x}^{-3}}\right)} \cdot 0.5 \]
      2. sqrt-pow1100.0%

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

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

      \[\leadsto \color{blue}{\left(1 \cdot {x}^{-1.5}\right)} \cdot 0.5 \]
    12. Step-by-step derivation
      1. *-lft-identity100.0%

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

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

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

Alternative 2: 99.0% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 38.7%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--38.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. div-inv38.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{1}{e^{\color{blue}{3 \cdot \log x}}}} \cdot 0.5 \]
      4. exp-neg67.6%

        \[\leadsto \sqrt{\color{blue}{e^{-3 \cdot \log x}}} \cdot 0.5 \]
      5. distribute-lft-neg-in67.6%

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

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

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

        \[\leadsto \sqrt{\color{blue}{{x}^{-3}}} \cdot 0.5 \]
    9. Simplified70.5%

      \[\leadsto \color{blue}{\sqrt{{x}^{-3}} \cdot 0.5} \]
    10. Step-by-step derivation
      1. *-un-lft-identity70.5%

        \[\leadsto \color{blue}{\left(1 \cdot \sqrt{{x}^{-3}}\right)} \cdot 0.5 \]
      2. sqrt-pow1100.0%

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

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

      \[\leadsto \color{blue}{\left(1 \cdot {x}^{-1.5}\right)} \cdot 0.5 \]
    12. Step-by-step derivation
      1. *-lft-identity100.0%

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

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

    if 0.0 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64)))))

    1. Initial program 65.0%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\color{blue}{x \cdot \left(1 + 0.5 \cdot \frac{1}{x}\right)}} \]
    6. Step-by-step derivation
      1. distribute-lft-in52.5%

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

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

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

        \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{x + \color{blue}{\left(x \cdot \frac{1}{x}\right) \cdot 0.5}} \]
      5. rgt-mult-inverse52.5%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left(1 + x\right) - x}{\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}}}}{x + 0.5} \]
    10. Step-by-step derivation
      1. associate--l+99.2%

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}}{x + 0.5} \]
    12. Step-by-step derivation
      1. *-un-lft-identity78.5%

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

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{1}{\left(\sqrt{x} + \sqrt{1 + x}\right) \cdot \left(x + 0.5\right)}} \]
    14. Step-by-step derivation
      1. *-lft-identity78.4%

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

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

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

Alternative 3: 98.9% accurate, 0.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;t\_0 - \sqrt{\frac{1}{x + 1}}\\


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

    1. Initial program 38.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{x} - \frac{1}{1 + x}\right) \cdot \frac{1}{{x}^{-0.5} + \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}} \]
      14. pow-flip39.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{1}{{x}^{3}}} \cdot 0.5} \]
      2. exp-to-pow67.0%

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

        \[\leadsto \sqrt{\frac{1}{e^{\color{blue}{3 \cdot \log x}}}} \cdot 0.5 \]
      4. exp-neg67.8%

        \[\leadsto \sqrt{\color{blue}{e^{-3 \cdot \log x}}} \cdot 0.5 \]
      5. distribute-lft-neg-in67.8%

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

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

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

        \[\leadsto \sqrt{\color{blue}{{x}^{-3}}} \cdot 0.5 \]
    9. Simplified70.6%

      \[\leadsto \color{blue}{\sqrt{{x}^{-3}} \cdot 0.5} \]
    10. Step-by-step derivation
      1. *-un-lft-identity70.6%

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

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

        \[\leadsto \left(1 \cdot {x}^{\color{blue}{-1.5}}\right) \cdot 0.5 \]
    11. Applied egg-rr99.2%

      \[\leadsto \color{blue}{\left(1 \cdot {x}^{-1.5}\right)} \cdot 0.5 \]
    12. Step-by-step derivation
      1. *-lft-identity99.2%

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

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

    if 2e-14 < (-.f64 (/.f64 #s(literal 1 binary64) (sqrt.f64 x)) (/.f64 #s(literal 1 binary64) (sqrt.f64 (+.f64 x #s(literal 1 binary64)))))

    1. Initial program 79.3%

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

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

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

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

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

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

        \[\leadsto \frac{1}{\sqrt{x}} - \sqrt{\frac{1}{\color{blue}{1 + x}}} \]
    4. Applied egg-rr79.8%

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

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

Alternative 4: 99.9% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 8 \cdot 10^{+15}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x} + \sqrt{x + 1}}}{\sqrt{x \cdot \left(x + 1\right)}}\\

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


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

    1. Initial program 65.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 8e15 < x

    1. Initial program 38.7%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--38.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. div-inv38.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\frac{1}{e^{\color{blue}{3 \cdot \log x}}}} \cdot 0.5 \]
      4. exp-neg67.6%

        \[\leadsto \sqrt{\color{blue}{e^{-3 \cdot \log x}}} \cdot 0.5 \]
      5. distribute-lft-neg-in67.6%

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

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

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

        \[\leadsto \sqrt{\color{blue}{{x}^{-3}}} \cdot 0.5 \]
    9. Simplified70.5%

      \[\leadsto \color{blue}{\sqrt{{x}^{-3}} \cdot 0.5} \]
    10. Step-by-step derivation
      1. *-un-lft-identity70.5%

        \[\leadsto \color{blue}{\left(1 \cdot \sqrt{{x}^{-3}}\right)} \cdot 0.5 \]
      2. sqrt-pow1100.0%

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

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

      \[\leadsto \color{blue}{\left(1 \cdot {x}^{-1.5}\right)} \cdot 0.5 \]
    12. Step-by-step derivation
      1. *-lft-identity100.0%

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

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

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

Alternative 5: 98.9% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 79.3%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{x}^{-0.5} + \frac{-1}{\sqrt{1 + x}}} \]
    5. Step-by-step derivation
      1. *-rgt-identity79.3%

        \[\leadsto {x}^{-0.5} + \color{blue}{\frac{-1}{\sqrt{1 + x}} \cdot 1} \]
      2. cancel-sign-sub79.3%

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

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{\color{blue}{1}}{\sqrt{1 + x}} \]
      7. unpow1/279.3%

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

        \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{e^{\log \left(1 + x\right) \cdot 0.5}}} \]
      9. log1p-undefine78.0%

        \[\leadsto {x}^{-0.5} - \frac{1}{e^{\color{blue}{\mathsf{log1p}\left(x\right)} \cdot 0.5}} \]
      10. *-commutative78.0%

        \[\leadsto {x}^{-0.5} - \frac{1}{e^{\color{blue}{0.5 \cdot \mathsf{log1p}\left(x\right)}}} \]
      11. exp-neg78.2%

        \[\leadsto {x}^{-0.5} - \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right)}} \]
      12. *-commutative78.2%

        \[\leadsto {x}^{-0.5} - e^{-\color{blue}{\mathsf{log1p}\left(x\right) \cdot 0.5}} \]
      13. distribute-rgt-neg-in78.2%

        \[\leadsto {x}^{-0.5} - e^{\color{blue}{\mathsf{log1p}\left(x\right) \cdot \left(-0.5\right)}} \]
      14. log1p-undefine78.2%

        \[\leadsto {x}^{-0.5} - e^{\color{blue}{\log \left(1 + x\right)} \cdot \left(-0.5\right)} \]
      15. metadata-eval78.2%

        \[\leadsto {x}^{-0.5} - e^{\log \left(1 + x\right) \cdot \color{blue}{-0.5}} \]
      16. exp-to-pow79.4%

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

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

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

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

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

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

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

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

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

    if 9e7 < x

    1. Initial program 38.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{x} - \frac{1}{1 + x}\right) \cdot \frac{1}{{x}^{-0.5} + \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}} \]
      14. pow-flip39.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{1}{{x}^{3}}} \cdot 0.5} \]
      2. exp-to-pow67.0%

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

        \[\leadsto \sqrt{\frac{1}{e^{\color{blue}{3 \cdot \log x}}}} \cdot 0.5 \]
      4. exp-neg67.8%

        \[\leadsto \sqrt{\color{blue}{e^{-3 \cdot \log x}}} \cdot 0.5 \]
      5. distribute-lft-neg-in67.8%

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

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

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

        \[\leadsto \sqrt{\color{blue}{{x}^{-3}}} \cdot 0.5 \]
    9. Simplified70.6%

      \[\leadsto \color{blue}{\sqrt{{x}^{-3}} \cdot 0.5} \]
    10. Step-by-step derivation
      1. *-un-lft-identity70.6%

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

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

        \[\leadsto \left(1 \cdot {x}^{\color{blue}{-1.5}}\right) \cdot 0.5 \]
    11. Applied egg-rr99.2%

      \[\leadsto \color{blue}{\left(1 \cdot {x}^{-1.5}\right)} \cdot 0.5 \]
    12. Step-by-step derivation
      1. *-lft-identity99.2%

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

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

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

Alternative 6: 98.9% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 79.3%

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

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

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

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

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

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

        \[\leadsto -1 \cdot \frac{1}{-\sqrt{x}} - \color{blue}{-1 \cdot \frac{1}{-\sqrt{x + 1}}} \]
      7. distribute-neg-frac279.3%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(-1, \frac{1}{-\sqrt{x}}, -\left(-\frac{1}{\sqrt{x + 1}}\right) \cdot -1\right) + \mathsf{fma}\left(-\left(-\frac{1}{\sqrt{x + 1}}\right), -1, \left(-\frac{1}{\sqrt{x + 1}}\right) \cdot -1\right)} \]
      9. distribute-neg-frac79.3%

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

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

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

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

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

    if 9e7 < x

    1. Initial program 38.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{x} - \frac{1}{1 + x}\right) \cdot \frac{1}{{x}^{-0.5} + \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}} \]
      14. pow-flip39.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{1}{{x}^{3}}} \cdot 0.5} \]
      2. exp-to-pow67.0%

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

        \[\leadsto \sqrt{\frac{1}{e^{\color{blue}{3 \cdot \log x}}}} \cdot 0.5 \]
      4. exp-neg67.8%

        \[\leadsto \sqrt{\color{blue}{e^{-3 \cdot \log x}}} \cdot 0.5 \]
      5. distribute-lft-neg-in67.8%

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

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

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

        \[\leadsto \sqrt{\color{blue}{{x}^{-3}}} \cdot 0.5 \]
    9. Simplified70.6%

      \[\leadsto \color{blue}{\sqrt{{x}^{-3}} \cdot 0.5} \]
    10. Step-by-step derivation
      1. *-un-lft-identity70.6%

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

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

        \[\leadsto \left(1 \cdot {x}^{\color{blue}{-1.5}}\right) \cdot 0.5 \]
    11. Applied egg-rr99.2%

      \[\leadsto \color{blue}{\left(1 \cdot {x}^{-1.5}\right)} \cdot 0.5 \]
    12. Step-by-step derivation
      1. *-lft-identity99.2%

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

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

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

Alternative 7: 99.0% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 79.3%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{x}^{-0.5} + \frac{-1}{\sqrt{1 + x}}} \]
    5. Step-by-step derivation
      1. *-rgt-identity79.3%

        \[\leadsto {x}^{-0.5} + \color{blue}{\frac{-1}{\sqrt{1 + x}} \cdot 1} \]
      2. cancel-sign-sub79.3%

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

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

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

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

        \[\leadsto {x}^{-0.5} - \frac{\color{blue}{1}}{\sqrt{1 + x}} \]
      7. unpow1/279.3%

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

        \[\leadsto {x}^{-0.5} - \frac{1}{\color{blue}{e^{\log \left(1 + x\right) \cdot 0.5}}} \]
      9. log1p-undefine78.0%

        \[\leadsto {x}^{-0.5} - \frac{1}{e^{\color{blue}{\mathsf{log1p}\left(x\right)} \cdot 0.5}} \]
      10. *-commutative78.0%

        \[\leadsto {x}^{-0.5} - \frac{1}{e^{\color{blue}{0.5 \cdot \mathsf{log1p}\left(x\right)}}} \]
      11. exp-neg78.2%

        \[\leadsto {x}^{-0.5} - \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right)}} \]
      12. *-commutative78.2%

        \[\leadsto {x}^{-0.5} - e^{-\color{blue}{\mathsf{log1p}\left(x\right) \cdot 0.5}} \]
      13. distribute-rgt-neg-in78.2%

        \[\leadsto {x}^{-0.5} - e^{\color{blue}{\mathsf{log1p}\left(x\right) \cdot \left(-0.5\right)}} \]
      14. log1p-undefine78.2%

        \[\leadsto {x}^{-0.5} - e^{\color{blue}{\log \left(1 + x\right)} \cdot \left(-0.5\right)} \]
      15. metadata-eval78.2%

        \[\leadsto {x}^{-0.5} - e^{\log \left(1 + x\right) \cdot \color{blue}{-0.5}} \]
      16. exp-to-pow79.4%

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

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

    if 9e7 < x

    1. Initial program 38.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(\frac{1}{x} - \frac{1}{1 + x}\right) \cdot \frac{1}{{x}^{-0.5} + \frac{1}{\color{blue}{{\left(x + 1\right)}^{0.5}}}} \]
      14. pow-flip39.0%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\sqrt{\frac{1}{{x}^{3}}} \cdot 0.5} \]
      2. exp-to-pow67.0%

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

        \[\leadsto \sqrt{\frac{1}{e^{\color{blue}{3 \cdot \log x}}}} \cdot 0.5 \]
      4. exp-neg67.8%

        \[\leadsto \sqrt{\color{blue}{e^{-3 \cdot \log x}}} \cdot 0.5 \]
      5. distribute-lft-neg-in67.8%

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

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

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

        \[\leadsto \sqrt{\color{blue}{{x}^{-3}}} \cdot 0.5 \]
    9. Simplified70.6%

      \[\leadsto \color{blue}{\sqrt{{x}^{-3}} \cdot 0.5} \]
    10. Step-by-step derivation
      1. *-un-lft-identity70.6%

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

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

        \[\leadsto \left(1 \cdot {x}^{\color{blue}{-1.5}}\right) \cdot 0.5 \]
    11. Applied egg-rr99.2%

      \[\leadsto \color{blue}{\left(1 \cdot {x}^{-1.5}\right)} \cdot 0.5 \]
    12. Step-by-step derivation
      1. *-lft-identity99.2%

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

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

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

Alternative 8: 98.7% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\color{blue}{x \cdot \left(1 + 0.5 \cdot \frac{1}{x}\right)}} \]
  6. Step-by-step derivation
    1. distribute-lft-in39.8%

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

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

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

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{x + \color{blue}{\left(x \cdot \frac{1}{x}\right) \cdot 0.5}} \]
    5. rgt-mult-inverse39.8%

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{\left(1 + x\right) - x}{\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}}}}{x + 0.5} \]
  10. Step-by-step derivation
    1. associate--l+83.9%

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}}{x + 0.5} \]
  12. Final simplification97.9%

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

Alternative 9: 97.9% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \sqrt{\frac{1}{e^{\color{blue}{3 \cdot \log x}}}} \cdot 0.5 \]
    4. exp-neg66.5%

      \[\leadsto \sqrt{\color{blue}{e^{-3 \cdot \log x}}} \cdot 0.5 \]
    5. distribute-lft-neg-in66.5%

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

      \[\leadsto \sqrt{e^{\color{blue}{-3} \cdot \log x}} \cdot 0.5 \]
    7. *-commutative66.5%

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

      \[\leadsto \sqrt{\color{blue}{{x}^{-3}}} \cdot 0.5 \]
  9. Simplified69.2%

    \[\leadsto \color{blue}{\sqrt{{x}^{-3}} \cdot 0.5} \]
  10. Step-by-step derivation
    1. *-un-lft-identity69.2%

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

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

      \[\leadsto \left(1 \cdot {x}^{\color{blue}{-1.5}}\right) \cdot 0.5 \]
  11. Applied egg-rr96.4%

    \[\leadsto \color{blue}{\left(1 \cdot {x}^{-1.5}\right)} \cdot 0.5 \]
  12. Step-by-step derivation
    1. *-lft-identity96.4%

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

    \[\leadsto \color{blue}{{x}^{-1.5}} \cdot 0.5 \]
  14. Add Preprocessing

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
  8. Step-by-step derivation
    1. unpow1/25.8%

      \[\leadsto \color{blue}{{\left(\frac{1}{x}\right)}^{0.5}} \]
    2. rem-exp-log5.8%

      \[\leadsto {\left(\frac{1}{\color{blue}{e^{\log x}}}\right)}^{0.5} \]
    3. exp-neg5.8%

      \[\leadsto {\color{blue}{\left(e^{-\log x}\right)}}^{0.5} \]
    4. exp-prod5.8%

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

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

      \[\leadsto e^{\color{blue}{\log x \cdot \left(-0.5\right)}} \]
    7. metadata-eval5.8%

      \[\leadsto e^{\log x \cdot \color{blue}{-0.5}} \]
    8. exp-to-pow5.8%

      \[\leadsto \color{blue}{{x}^{-0.5}} \]
  9. Simplified5.8%

    \[\leadsto \color{blue}{{x}^{-0.5}} \]
  10. Add Preprocessing

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

  :alt
  (! :herbie-platform default (/ 1 (+ (* (+ x 1) (sqrt x)) (* x (sqrt (+ x 1))))))

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