2isqrt (example 3.6)

Percentage Accurate: 37.8% → 99.7%
Time: 24.8s
Alternatives: 13
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 13 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: 37.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.7% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 59.3%

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

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

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

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

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

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

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

        \[\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-sqrt61.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. +-commutative61.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-pow61.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-pow261.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-eval61.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/261.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-flip61.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. +-commutative61.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-eval61.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-rr61.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/62.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-identity62.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e16 < x

    1. Initial program 38.0%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 84.1%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-0.125 \cdot \left(\sqrt{\frac{1}{x}} \cdot {\left(\sqrt{-1}\right)}^{2}\right) - 0.5 \cdot \left(\sqrt{\frac{1}{x}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}{x} + 0.5 \cdot \left(\sqrt{\frac{1}{x}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}{x}} \]
    5. Step-by-step derivation
      1. mul-1-neg0.0%

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{\frac{1}{x}} \cdot -0.5 - \frac{\sqrt{\frac{1}{x}} \cdot 0.625}{x}}{-x}} \]
    7. Step-by-step derivation
      1. pow1/299.7%

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

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

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

        \[\leadsto \frac{{x}^{\color{blue}{-0.5}} \cdot -0.5 - \frac{\sqrt{\frac{1}{x}} \cdot 0.625}{x}}{-x} \]
      5. *-un-lft-identity99.8%

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

      \[\leadsto \frac{\color{blue}{\left(1 \cdot {x}^{-0.5}\right)} \cdot -0.5 - \frac{\sqrt{\frac{1}{x}} \cdot 0.625}{x}}{-x} \]
    9. Step-by-step derivation
      1. *-lft-identity99.8%

        \[\leadsto \frac{\color{blue}{{x}^{-0.5}} \cdot -0.5 - \frac{\sqrt{\frac{1}{x}} \cdot 0.625}{x}}{-x} \]
    10. Simplified99.8%

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

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

Alternative 2: 98.8% accurate, 0.5× speedup?

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

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

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


\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))))) < 3.9999999999999999e-16

    1. Initial program 37.7%

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity37.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{\color{blue}{1 \cdot x + \frac{0.5}{x} \cdot x}} \]
      2. *-lft-identity99.4%

        \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{\color{blue}{x} + \frac{0.5}{x} \cdot x} \]
      3. associate-*l/99.4%

        \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{x + \color{blue}{\frac{0.5 \cdot x}{x}}} \]
      4. associate-/l*99.4%

        \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{x + \color{blue}{0.5 \cdot \frac{x}{x}}} \]
      5. *-inverses99.4%

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

        \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{x + \color{blue}{0.5}} \]
    14. Simplified99.4%

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

    if 3.9999999999999999e-16 < (-.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 80.2%

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

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

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

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

        \[\leadsto \frac{1}{\frac{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}} \]
      6. pow1/280.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 98.7% accurate, 0.5× speedup?

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

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

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


\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))))) < 3.9999999999999999e-16

    1. Initial program 37.7%

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity37.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{\color{blue}{1 \cdot x + \frac{0.5}{x} \cdot x}} \]
      2. *-lft-identity99.4%

        \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{\color{blue}{x} + \frac{0.5}{x} \cdot x} \]
      3. associate-*l/99.4%

        \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{x + \color{blue}{\frac{0.5 \cdot x}{x}}} \]
      4. associate-/l*99.4%

        \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{x + \color{blue}{0.5 \cdot \frac{x}{x}}} \]
      5. *-inverses99.4%

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

        \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{x + \color{blue}{0.5}} \]
    14. Simplified99.4%

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

    if 3.9999999999999999e-16 < (-.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 80.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.7% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 49.6%

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity51.7%

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left(1 + x\right) - x}{\sqrt{1 + x} + \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)}}{\sqrt{1 + x} + \sqrt{x}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
      2. +-inverses99.2%

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

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

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

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

    if 4.9999999999999996e22 < x

    1. Initial program 38.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 83.8%

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-0.125 \cdot \left(\sqrt{\frac{1}{x}} \cdot {\left(\sqrt{-1}\right)}^{2}\right) - 0.5 \cdot \left(\sqrt{\frac{1}{x}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}{x} + 0.5 \cdot \left(\sqrt{\frac{1}{x}} \cdot {\left(\sqrt{-1}\right)}^{2}\right)}{x}} \]
    5. Step-by-step derivation
      1. mul-1-neg0.0%

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{\frac{1}{x}} \cdot -0.5 - \frac{\sqrt{\frac{1}{x}} \cdot 0.625}{x}}{-x}} \]
    7. Step-by-step derivation
      1. pow1/299.7%

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

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

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

        \[\leadsto \frac{{x}^{\color{blue}{-0.5}} \cdot -0.5 - \frac{\sqrt{\frac{1}{x}} \cdot 0.625}{x}}{-x} \]
      5. *-un-lft-identity99.8%

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

      \[\leadsto \frac{\color{blue}{\left(1 \cdot {x}^{-0.5}\right)} \cdot -0.5 - \frac{\sqrt{\frac{1}{x}} \cdot 0.625}{x}}{-x} \]
    9. Step-by-step derivation
      1. *-lft-identity99.8%

        \[\leadsto \frac{\color{blue}{{x}^{-0.5}} \cdot -0.5 - \frac{\sqrt{\frac{1}{x}} \cdot 0.625}{x}}{-x} \]
    10. Simplified99.8%

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

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

Alternative 5: 98.8% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 80.2%

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity83.5%

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

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

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

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

    if 7.5e7 < x

    1. Initial program 37.7%

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity37.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{\color{blue}{1 \cdot x + \frac{0.5}{x} \cdot x}} \]
      2. *-lft-identity99.4%

        \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{\color{blue}{x} + \frac{0.5}{x} \cdot x} \]
      3. associate-*l/99.4%

        \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{x + \color{blue}{\frac{0.5 \cdot x}{x}}} \]
      4. associate-/l*99.4%

        \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{x + \color{blue}{0.5 \cdot \frac{x}{x}}} \]
      5. *-inverses99.4%

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

        \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{x + \color{blue}{0.5}} \]
    14. Simplified99.4%

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

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

Alternative 6: 97.8% accurate, 1.9× speedup?

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

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

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

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity39.8%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{\frac{1}{x}}}{x} \cdot \frac{0.5}{1 + \frac{0.5}{x}}} \]
    2. inv-pow96.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{\color{blue}{1 \cdot x + \frac{0.5}{x} \cdot x}} \]
    2. *-lft-identity96.9%

      \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{\color{blue}{x} + \frac{0.5}{x} \cdot x} \]
    3. associate-*l/96.9%

      \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{x + \color{blue}{\frac{0.5 \cdot x}{x}}} \]
    4. associate-/l*96.9%

      \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{x + \color{blue}{0.5 \cdot \frac{x}{x}}} \]
    5. *-inverses96.9%

      \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{x + 0.5 \cdot \color{blue}{1}} \]
    6. metadata-eval96.9%

      \[\leadsto 0.5 \cdot \frac{{x}^{-0.5}}{x + \color{blue}{0.5}} \]
  14. Simplified96.9%

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

Alternative 7: 97.6% accurate, 2.0× speedup?

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

\\
\frac{\sqrt{\frac{1}{x}} \cdot 0.5}{x}
\end{array}
Derivation
  1. Initial program 39.6%

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

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity39.8%

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

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

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

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

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

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

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

    \[\leadsto \frac{\sqrt{\frac{1}{x}} \cdot 0.5}{\color{blue}{x}} \]
  9. Add Preprocessing

Alternative 8: 96.5% accurate, 2.0× speedup?

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

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

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

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity39.8%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\sqrt{\frac{1}{x}} \cdot 0.5}{\color{blue}{x \cdot \left(1 + \frac{0.5}{x}\right)}} \]
  11. Step-by-step derivation
    1. associate-/l*96.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{0.5}{\sqrt{x} \cdot \left(x + 0.5\right)}} \]
  15. Add Preprocessing

Alternative 9: 43.9% accurate, 2.0× speedup?

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

\\
{x}^{-1.5}
\end{array}
Derivation
  1. Initial program 39.6%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0 5.7%

    \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
  4. Step-by-step derivation
    1. pow1/25.7%

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

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

      \[\leadsto e^{\color{blue}{\left(-\log x\right)} \cdot 0.5} \]
  5. Applied egg-rr5.7%

    \[\leadsto \color{blue}{e^{\left(-\log x\right) \cdot 0.5}} \]
  6. Applied egg-rr44.4%

    \[\leadsto \color{blue}{{x}^{-1.5}} \]
  7. Add Preprocessing

Alternative 10: 37.0% accurate, 23.2× speedup?

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

\\
\frac{\frac{-1}{x}}{\frac{-1 - x}{0.5}}
\end{array}
Derivation
  1. Initial program 39.6%

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

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity39.8%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot \frac{1 + x}{0.5}}} \]
    2. associate-/r*37.6%

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

    \[\leadsto \color{blue}{\frac{\frac{1}{x}}{\frac{1 + x}{0.5}}} \]
  11. Final simplification37.6%

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

Alternative 11: 6.4% accurate, 26.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 5.5 \cdot 10^{+153}:\\ \;\;\;\;0.25\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.125}{x}\\ \end{array} \end{array} \]
(FPCore (x) :precision binary64 (if (<= x 5.5e+153) 0.25 (/ -0.125 x)))
double code(double x) {
	double tmp;
	if (x <= 5.5e+153) {
		tmp = 0.25;
	} else {
		tmp = -0.125 / x;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 5.5d+153) then
        tmp = 0.25d0
    else
        tmp = (-0.125d0) / x
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 5.5e+153) {
		tmp = 0.25;
	} else {
		tmp = -0.125 / x;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 5.5e+153:
		tmp = 0.25
	else:
		tmp = -0.125 / x
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 5.5e+153)
		tmp = 0.25;
	else
		tmp = Float64(-0.125 / x);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 5.5e+153)
		tmp = 0.25;
	else
		tmp = -0.125 / x;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 5.5e+153], 0.25, N[(-0.125 / x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.5 \cdot 10^{+153}:\\
\;\;\;\;0.25\\

\mathbf{else}:\\
\;\;\;\;\frac{-0.125}{x}\\


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

    1. Initial program 12.4%

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity12.7%

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

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

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

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

      \[\leadsto \frac{\color{blue}{0.5 \cdot \sqrt{\frac{1}{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    6. Step-by-step derivation
      1. *-commutative94.0%

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{x}{x + x}} \]
    9. Step-by-step derivation
      1. associate-*r/6.2%

        \[\leadsto \color{blue}{\frac{0.5 \cdot x}{x + x}} \]
      2. count-26.2%

        \[\leadsto \frac{0.5 \cdot x}{\color{blue}{2 \cdot x}} \]
      3. times-frac6.2%

        \[\leadsto \color{blue}{\frac{0.5}{2} \cdot \frac{x}{x}} \]
      4. metadata-eval6.2%

        \[\leadsto \color{blue}{0.25} \cdot \frac{x}{x} \]
      5. *-inverses6.2%

        \[\leadsto 0.25 \cdot \color{blue}{1} \]
      6. metadata-eval6.2%

        \[\leadsto \color{blue}{0.25} \]
    10. Simplified6.2%

      \[\leadsto \color{blue}{0.25} \]

    if 5.5000000000000003e153 < x

    1. Initial program 69.5%

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

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

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

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity69.5%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5}{x + x} \cdot \frac{x}{x + x}} \]
    9. Step-by-step derivation
      1. associate-*l/7.4%

        \[\leadsto \color{blue}{\frac{-0.5 \cdot \frac{x}{x + x}}{x + x}} \]
      2. count-27.4%

        \[\leadsto \frac{-0.5 \cdot \frac{x}{x + x}}{\color{blue}{2 \cdot x}} \]
      3. associate-/r*7.4%

        \[\leadsto \color{blue}{\frac{\frac{-0.5 \cdot \frac{x}{x + x}}{2}}{x}} \]
      4. associate-*r/7.4%

        \[\leadsto \frac{\frac{\color{blue}{\frac{-0.5 \cdot x}{x + x}}}{2}}{x} \]
      5. count-27.4%

        \[\leadsto \frac{\frac{\frac{-0.5 \cdot x}{\color{blue}{2 \cdot x}}}{2}}{x} \]
      6. times-frac7.4%

        \[\leadsto \frac{\frac{\color{blue}{\frac{-0.5}{2} \cdot \frac{x}{x}}}{2}}{x} \]
      7. metadata-eval7.4%

        \[\leadsto \frac{\frac{\color{blue}{-0.25} \cdot \frac{x}{x}}{2}}{x} \]
      8. *-inverses7.4%

        \[\leadsto \frac{\frac{-0.25 \cdot \color{blue}{1}}{2}}{x} \]
      9. metadata-eval7.4%

        \[\leadsto \frac{\frac{\color{blue}{-0.25}}{2}}{x} \]
      10. metadata-eval7.4%

        \[\leadsto \frac{\color{blue}{-0.125}}{x} \]
    10. Simplified7.4%

      \[\leadsto \color{blue}{\frac{-0.125}{x}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 7.9% accurate, 69.7× speedup?

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

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

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

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity39.8%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{-\frac{-0.5}{x + x}} \]
  9. Step-by-step derivation
    1. distribute-neg-frac8.2%

      \[\leadsto \color{blue}{\frac{--0.5}{x + x}} \]
    2. metadata-eval8.2%

      \[\leadsto \frac{\color{blue}{0.5}}{x + x} \]
    3. count-28.2%

      \[\leadsto \frac{0.5}{\color{blue}{2 \cdot x}} \]
    4. associate-/r*8.2%

      \[\leadsto \color{blue}{\frac{\frac{0.5}{2}}{x}} \]
    5. metadata-eval8.2%

      \[\leadsto \frac{\color{blue}{0.25}}{x} \]
  10. Simplified8.2%

    \[\leadsto \color{blue}{\frac{0.25}{x}} \]
  11. Add Preprocessing

Alternative 13: 4.7% accurate, 209.0× speedup?

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

\\
0.25
\end{array}
Derivation
  1. Initial program 39.6%

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

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

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity39.8%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0.5 \cdot \frac{x}{x + x}} \]
  9. Step-by-step derivation
    1. associate-*r/4.8%

      \[\leadsto \color{blue}{\frac{0.5 \cdot x}{x + x}} \]
    2. count-24.8%

      \[\leadsto \frac{0.5 \cdot x}{\color{blue}{2 \cdot x}} \]
    3. times-frac4.8%

      \[\leadsto \color{blue}{\frac{0.5}{2} \cdot \frac{x}{x}} \]
    4. metadata-eval4.8%

      \[\leadsto \color{blue}{0.25} \cdot \frac{x}{x} \]
    5. *-inverses4.8%

      \[\leadsto 0.25 \cdot \color{blue}{1} \]
    6. metadata-eval4.8%

      \[\leadsto \color{blue}{0.25} \]
  10. Simplified4.8%

    \[\leadsto \color{blue}{0.25} \]
  11. Add Preprocessing

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

  :alt
  (/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))

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