2isqrt (example 3.6)

Percentage Accurate: 68.4% → 99.8%
Time: 15.4s
Alternatives: 12
Speedup: 1.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 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: 68.4% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 71.4%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x \cdot \left(1 + x\right)}}} \]
    5. Step-by-step derivation
      1. flip--72.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-sqrt71.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-sqrt72.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1 + \color{blue}{0}}{\sqrt{x}} \cdot \frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}} \]
      5. metadata-eval99.2%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{x}} \cdot \frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}} \]
      6. associate-*l/99.3%

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

        \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}}}}{\sqrt{x}} \]
      8. associate-/l/99.3%

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

        \[\leadsto \frac{\frac{1}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x + 1} \cdot \sqrt{x}}}}{\sqrt{x}} \]
      10. rem-square-sqrt99.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.9999999999999999e105 < x

    1. Initial program 50.3%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x}}}{\sqrt{1 + x}}} \]
    5. Step-by-step derivation
      1. div-sub50.3%

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

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

        \[\leadsto \frac{\sqrt{\frac{\color{blue}{x + 1}}{x}} - \frac{\sqrt{x}}{\sqrt{x}}}{\sqrt{1 + x}} \]
      4. *-inverses50.3%

        \[\leadsto \frac{\sqrt{\frac{x + 1}{x}} - \color{blue}{1}}{\sqrt{1 + x}} \]
    6. Applied egg-rr50.3%

      \[\leadsto \frac{\color{blue}{\sqrt{\frac{x + 1}{x}} - 1}}{\sqrt{1 + x}} \]
    7. Taylor expanded in x around inf 50.3%

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

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

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

      \[\leadsto \frac{\color{blue}{\left(1 + \frac{0.5}{x}\right)} - 1}{\sqrt{1 + x}} \]
    10. Step-by-step derivation
      1. div-inv50.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.5% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{1}}{\sqrt{x}} \cdot \frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}} \]
    6. associate-*l/99.3%

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

      \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}}}}{\sqrt{x}} \]
    8. associate-/l/99.3%

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

      \[\leadsto \frac{\frac{1}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x + 1} \cdot \sqrt{x}}}}{\sqrt{x}} \]
    10. rem-square-sqrt99.5%

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

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

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

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

    \[\leadsto \frac{\frac{1}{\sqrt{1 + x} \cdot \sqrt{x} + \left(1 + x\right)}}{\sqrt{x}} \]
  12. Add Preprocessing

Alternative 3: 99.7% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{1.5 + \left(x \cdot 2 - \frac{0.125}{x}\right)}}{\sqrt{x}}\\


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3550 < x

    1. Initial program 35.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{x}} \cdot \frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}} \]
      6. associate-*l/99.2%

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

        \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}}}}{\sqrt{x}} \]
      8. associate-/l/99.2%

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

        \[\leadsto \frac{\frac{1}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x + 1} \cdot \sqrt{x}}}}{\sqrt{x}} \]
      10. rem-square-sqrt99.4%

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

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

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

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

      \[\leadsto \frac{\frac{1}{\color{blue}{\left(1.5 + 2 \cdot x\right) - 0.125 \cdot \frac{1}{x}}}}{\sqrt{x}} \]
    12. Step-by-step derivation
      1. associate--l+99.5%

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

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

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

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

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

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

Alternative 4: 98.9% accurate, 1.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{1.5 + x \cdot 2}}{\sqrt{x}}\\


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

    1. Initial program 99.6%

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

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

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

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

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

        \[\leadsto \frac{1}{\sqrt{x}} - \left(1 + \left(x \cdot -0.5 + \color{blue}{x \cdot \left(x \cdot 0.375\right)}\right)\right) \]
      5. distribute-lft-out98.0%

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

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

    if 0.51000000000000001 < x

    1. Initial program 35.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{x}} \cdot \frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}} \]
      6. associate-*l/99.2%

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

        \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}}}}{\sqrt{x}} \]
      8. associate-/l/99.2%

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

        \[\leadsto \frac{\frac{1}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x + 1} \cdot \sqrt{x}}}}{\sqrt{x}} \]
      10. rem-square-sqrt99.4%

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

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

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

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

      \[\leadsto \frac{\frac{1}{\color{blue}{1.5 + 2 \cdot x}}}{\sqrt{x}} \]
    12. Step-by-step derivation
      1. *-commutative99.2%

        \[\leadsto \frac{\frac{1}{1.5 + \color{blue}{x \cdot 2}}}{\sqrt{x}} \]
    13. Simplified99.2%

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

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

Alternative 5: 99.1% accurate, 1.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{1.5 + \left(x \cdot 2 - \frac{0.125}{x}\right)}}{\sqrt{x}}\\


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

    1. Initial program 99.6%

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

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

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

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

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

        \[\leadsto \frac{1}{\sqrt{x}} - \left(1 + \left(x \cdot -0.5 + \color{blue}{x \cdot \left(x \cdot 0.375\right)}\right)\right) \]
      5. distribute-lft-out98.0%

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

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

    if 0.51000000000000001 < x

    1. Initial program 35.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{x}} \cdot \frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}} \]
      6. associate-*l/99.2%

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

        \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}}}}{\sqrt{x}} \]
      8. associate-/l/99.2%

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

        \[\leadsto \frac{\frac{1}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x + 1} \cdot \sqrt{x}}}}{\sqrt{x}} \]
      10. rem-square-sqrt99.4%

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

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

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

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

      \[\leadsto \frac{\frac{1}{\color{blue}{\left(1.5 + 2 \cdot x\right) - 0.125 \cdot \frac{1}{x}}}}{\sqrt{x}} \]
    12. Step-by-step derivation
      1. associate--l+99.5%

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

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

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

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

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

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

Alternative 6: 99.0% accurate, 1.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{1.5 + x \cdot 2}}{\sqrt{x}}\\


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.409999999999999976 < x

    1. Initial program 35.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{x}} \cdot \frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}} \]
      6. associate-*l/99.2%

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

        \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}}}}{\sqrt{x}} \]
      8. associate-/l/99.2%

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

        \[\leadsto \frac{\frac{1}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x + 1} \cdot \sqrt{x}}}}{\sqrt{x}} \]
      10. rem-square-sqrt99.4%

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

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

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

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

      \[\leadsto \frac{\frac{1}{\color{blue}{1.5 + 2 \cdot x}}}{\sqrt{x}} \]
    12. Step-by-step derivation
      1. *-commutative99.2%

        \[\leadsto \frac{\frac{1}{1.5 + \color{blue}{x \cdot 2}}}{\sqrt{x}} \]
    13. Simplified99.2%

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

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

Alternative 7: 98.4% accurate, 1.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{1 + x}}\\


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.69999999999999996 < x

    1. Initial program 35.4%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x}}}{\sqrt{1 + x}}} \]
    5. Step-by-step derivation
      1. div-sub35.5%

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

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

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

        \[\leadsto \frac{\sqrt{\frac{x + 1}{x}} - \color{blue}{1}}{\sqrt{1 + x}} \]
    6. Applied egg-rr35.5%

      \[\leadsto \frac{\color{blue}{\sqrt{\frac{x + 1}{x}} - 1}}{\sqrt{1 + x}} \]
    7. Taylor expanded in x around inf 98.1%

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

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

Alternative 8: 98.2% accurate, 1.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{1 + x}}\\


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.47999999999999998 < x

    1. Initial program 35.4%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x}}}{\sqrt{1 + x}}} \]
    5. Step-by-step derivation
      1. div-sub35.5%

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

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

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

        \[\leadsto \frac{\sqrt{\frac{x + 1}{x}} - \color{blue}{1}}{\sqrt{1 + x}} \]
    6. Applied egg-rr35.5%

      \[\leadsto \frac{\color{blue}{\sqrt{\frac{x + 1}{x}} - 1}}{\sqrt{1 + x}} \]
    7. Taylor expanded in x around inf 98.1%

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

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

Alternative 9: 98.1% accurate, 1.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{x}}{\sqrt{x}}\\


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

    1. Initial program 99.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.680000000000000049 < x

    1. Initial program 35.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{x}} \cdot \frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}} \]
      6. associate-*l/99.2%

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

        \[\leadsto \frac{\color{blue}{\frac{\frac{1}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x + 1}}}}{\sqrt{x}} \]
      8. associate-/l/99.2%

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

        \[\leadsto \frac{\frac{1}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x + 1} \cdot \sqrt{x}}}}{\sqrt{x}} \]
      10. rem-square-sqrt99.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
  6. Step-by-step derivation
    1. expm1-log1p-u41.4%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{-0.5}\right)\right)} \]
    2. expm1-log1p44.6%

      \[\leadsto \color{blue}{{x}^{-0.5}} \]
  9. Simplified44.6%

    \[\leadsto \color{blue}{{x}^{-0.5}} \]
  10. Final simplification44.6%

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

Alternative 11: 1.9% accurate, 209.0× speedup?

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

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

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

    \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{1} \]
  4. Taylor expanded in x around inf 2.0%

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

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

Alternative 12: 5.7% accurate, 209.0× speedup?

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

\\
2
\end{array}
Derivation
  1. Initial program 64.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{2} \]
  7. Final simplification5.8%

    \[\leadsto 2 \]
  8. Add Preprocessing

Developer target: 98.9% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2024020 
(FPCore (x)
  :name "2isqrt (example 3.6)"
  :precision binary64

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

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