2isqrt (example 3.6)

Percentage Accurate: 69.2% → 99.8%
Time: 11.6s
Alternatives: 12
Speedup: 1.8×

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: 69.2% accurate, 1.0× speedup?

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

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

Alternative 1: 99.8% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{\color{blue}{1 + x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
    9. pow1/271.3%

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\frac{1}{\color{blue}{{x}^{0.5}}} + \frac{1}{\sqrt{x + 1}}} \]
    10. pow-flip71.2%

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}} \]
    12. inv-pow71.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.9% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 40.7%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{1}}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
      7. add-sqr-sqrt40.7%

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

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{\color{blue}{1 + x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
      9. pow1/240.7%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\color{blue}{2 \cdot \sqrt{\frac{1}{x}}}} \]
    5. Step-by-step derivation
      1. *-un-lft-identity40.7%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{\frac{1 + x}{1}} - x \cdot 1}{x \cdot \frac{1 + x}{1}}}{\sqrt{\frac{1}{x}}} \]
      7. /-rgt-identity41.9%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{1}}{x \cdot \frac{1 + x}{1}}}{\sqrt{\frac{1}{x}}} \]
      12. metadata-eval86.2%

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{1}{x} \cdot \frac{1}{\frac{1 + x}{1}}}}{\sqrt{\frac{1}{x}}} \]
      14. un-div-inv86.8%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{\frac{1}{x}}{\frac{1 + x}{1}}}}{\sqrt{\frac{1}{x}}} \]
      15. /-rgt-identity86.8%

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

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

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

        \[\leadsto 0.5 \cdot \frac{\frac{\frac{1}{x}}{1 + x}}{{x}^{\color{blue}{-0.5}}} \]
    6. Applied egg-rr86.7%

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

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

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

    if 1.99999999999999992e-23 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1))))

    1. Initial program 99.5%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. expm1-log1p-u92.4%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 99.3% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{\color{blue}{1 + x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
    9. pow1/271.3%

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\frac{1}{\color{blue}{{x}^{0.5}}} + \frac{1}{\sqrt{x + 1}}} \]
    10. pow-flip71.2%

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}} \]
    12. inv-pow71.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.3% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.5%

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

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

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

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

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

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

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

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

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

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

        \[\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/299.9%

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

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

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

        \[\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) \]
    3. Applied egg-rr99.9%

      \[\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)} \]
    4. Step-by-step derivation
      1. +-commutative99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.5e7 < x

    1. Initial program 40.7%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{1}}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
      7. add-sqr-sqrt40.7%

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

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{\color{blue}{1 + x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
      9. pow1/240.7%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\color{blue}{2 \cdot \sqrt{\frac{1}{x}}}} \]
    5. Step-by-step derivation
      1. *-un-lft-identity40.7%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{\frac{1 + x}{1}} - x \cdot 1}{x \cdot \frac{1 + x}{1}}}{\sqrt{\frac{1}{x}}} \]
      7. /-rgt-identity41.9%

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{1}}{x \cdot \frac{1 + x}{1}}}{\sqrt{\frac{1}{x}}} \]
      12. metadata-eval86.2%

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{1}{x} \cdot \frac{1}{\frac{1 + x}{1}}}}{\sqrt{\frac{1}{x}}} \]
      14. un-div-inv86.8%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{\frac{1}{x}}{\frac{1 + x}{1}}}}{\sqrt{\frac{1}{x}}} \]
      15. /-rgt-identity86.8%

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

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

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

        \[\leadsto 0.5 \cdot \frac{\frac{\frac{1}{x}}{1 + x}}{{x}^{\color{blue}{-0.5}}} \]
    6. Applied egg-rr86.7%

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

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

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

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

Alternative 5: 98.5% accurate, 1.8× speedup?

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

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

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


\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. 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) \]
    3. 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)} \]
    4. 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}} \]
    5. Simplified100.0%

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

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

    if 0.680000000000000049 < x

    1. Initial program 41.1%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{1}}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
      7. add-sqr-sqrt41.1%

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

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{\color{blue}{1 + x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
      9. pow1/241.1%

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}} \]
      12. inv-pow41.1%

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\color{blue}{2 \cdot \sqrt{\frac{1}{x}}}} \]
    5. Step-by-step derivation
      1. *-un-lft-identity40.6%

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

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

        \[\leadsto \color{blue}{0.5} \cdot \frac{\frac{1}{x} - \frac{1}{1 + x}}{\sqrt{\frac{1}{x}}} \]
      4. clear-num40.6%

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

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

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{\frac{1 + x}{1}} - x \cdot 1}{x \cdot \frac{1 + x}{1}}}{\sqrt{\frac{1}{x}}} \]
      7. /-rgt-identity41.8%

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\frac{\color{blue}{1 \cdot 1}}{x \cdot \frac{1 + x}{1}}}{\sqrt{\frac{1}{x}}} \]
      13. frac-times86.2%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{1}{x} \cdot \frac{1}{\frac{1 + x}{1}}}}{\sqrt{\frac{1}{x}}} \]
      14. un-div-inv86.3%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{\frac{\frac{1}{x}}{\frac{1 + x}{1}}}}{\sqrt{\frac{1}{x}}} \]
      15. /-rgt-identity86.3%

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

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

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

        \[\leadsto 0.5 \cdot \frac{\frac{\frac{1}{x}}{1 + x}}{{x}^{\color{blue}{-0.5}}} \]
    6. Applied egg-rr86.3%

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

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

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

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

Alternative 6: 91.2% accurate, 1.8× speedup?

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

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

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


\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. 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) \]
    3. 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)} \]
    4. 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}} \]
    5. Simplified100.0%

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

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

    if 0.680000000000000049 < x

    1. Initial program 41.1%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{1}}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
      7. add-sqr-sqrt41.1%

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

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{\color{blue}{1 + x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
      9. pow1/241.1%

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}} \]
      12. inv-pow41.1%

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\color{blue}{2 \cdot \sqrt{\frac{1}{x}}}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u40.6%

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

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{\frac{1}{x} - \frac{1}{1 + x}}{2 \cdot \sqrt{\frac{1}{x}}}\right)} - 1} \]
    6. Applied egg-rr40.3%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\sqrt{x} \cdot \frac{\frac{\frac{-1}{x}}{1 + x}}{-2}\right)} - 1} \]
    7. Step-by-step derivation
      1. expm1-def86.3%

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

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

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

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

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

Alternative 7: 53.6% accurate, 2.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{x}\\


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

    1. Initial program 99.6%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. 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) \]
    3. 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)} \]
    4. 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}} \]
    5. Simplified100.0%

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

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

    if 0.819999999999999951 < x

    1. Initial program 41.1%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{1}}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
      7. add-sqr-sqrt41.1%

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

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{\color{blue}{1 + x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
      9. pow1/241.1%

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}} \]
      12. inv-pow41.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{x + {x}^{\color{blue}{0.5}}} \]
    6. Simplified8.0%

      \[\leadsto \color{blue}{\frac{1}{x + {x}^{0.5}}} \]
    7. Taylor expanded in x around inf 8.0%

      \[\leadsto \frac{1}{\color{blue}{x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification54.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.82:\\ \;\;\;\;{x}^{-0.5} + -1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x}\\ \end{array} \]

Alternative 8: 53.0% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{\color{blue}{1 + x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
    9. pow1/271.3%

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\frac{1}{\color{blue}{{x}^{0.5}}} + \frac{1}{\sqrt{x + 1}}} \]
    10. pow-flip71.2%

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}} \]
    12. inv-pow71.2%

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{x} + {x}^{-0.5} \cdot x} \]
    3. pow-plus54.2%

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

      \[\leadsto \frac{1}{x + {x}^{\color{blue}{0.5}}} \]
  6. Simplified54.2%

    \[\leadsto \color{blue}{\frac{1}{x + {x}^{0.5}}} \]
  7. Step-by-step derivation
    1. expm1-log1p-u50.6%

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

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

      \[\leadsto e^{\mathsf{log1p}\left(\frac{1}{x + \color{blue}{\sqrt{x}}}\right)} - 1 \]
  8. Applied egg-rr66.1%

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

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

      \[\leadsto \color{blue}{\frac{1}{x + \sqrt{x}}} \]
  10. Simplified54.2%

    \[\leadsto \color{blue}{\frac{1}{x + \sqrt{x}}} \]
  11. Final simplification54.2%

    \[\leadsto \frac{1}{x + \sqrt{x}} \]

Alternative 9: 51.1% 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 71.5%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{\left({x}^{0.25}\right)}^{-1} \cdot {\left({x}^{0.25}\right)}^{-1}} - \frac{1}{\sqrt{x + 1}} \]
  4. Step-by-step derivation
    1. pow-sqr62.2%

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

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

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

    \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
  7. Step-by-step derivation
    1. inv-pow51.9%

      \[\leadsto \sqrt{\color{blue}{{x}^{-1}}} \]
    2. sqrt-pow152.0%

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

      \[\leadsto {x}^{\color{blue}{-0.5}} \]
    4. expm1-log1p-u48.3%

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

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

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

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

      \[\leadsto \color{blue}{{x}^{-0.5}} \]
  10. Simplified52.0%

    \[\leadsto \color{blue}{{x}^{-0.5}} \]
  11. Final simplification52.0%

    \[\leadsto {x}^{-0.5} \]

Alternative 10: 3.9% accurate, 69.7× speedup?

\[\begin{array}{l} \\ x \cdot 0.5 \end{array} \]
(FPCore (x) :precision binary64 (* x 0.5))
double code(double x) {
	return 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 x * 0.5;
}
def code(x):
	return x * 0.5
function code(x)
	return Float64(x * 0.5)
end
function tmp = code(x)
	tmp = x * 0.5;
end
code[x_] := N[(x * 0.5), $MachinePrecision]
\begin{array}{l}

\\
x \cdot 0.5
\end{array}
Derivation
  1. Initial program 71.5%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Taylor expanded in x around 0 52.7%

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

    \[\leadsto \color{blue}{0.5 \cdot x} \]
  4. Step-by-step derivation
    1. *-commutative4.0%

      \[\leadsto \color{blue}{x \cdot 0.5} \]
  5. Simplified4.0%

    \[\leadsto \color{blue}{x \cdot 0.5} \]
  6. Final simplification4.0%

    \[\leadsto x \cdot 0.5 \]

Alternative 11: 7.3% accurate, 69.7× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{\color{blue}{1 + x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}} \]
    9. pow1/271.3%

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{\frac{1}{\color{blue}{{x}^{0.5}}} + \frac{1}{\sqrt{x + 1}}} \]
    10. pow-flip71.2%

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

      \[\leadsto \frac{\frac{1}{x} - \frac{1}{1 + x}}{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}} \]
    12. inv-pow71.2%

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{x} + {x}^{-0.5} \cdot x} \]
    3. pow-plus54.2%

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

      \[\leadsto \frac{1}{x + {x}^{\color{blue}{0.5}}} \]
  6. Simplified54.2%

    \[\leadsto \color{blue}{\frac{1}{x + {x}^{0.5}}} \]
  7. Taylor expanded in x around inf 7.5%

    \[\leadsto \frac{1}{\color{blue}{x}} \]
  8. Final simplification7.5%

    \[\leadsto \frac{1}{x} \]

Alternative 12: 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 71.5%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Taylor expanded in x around 0 52.0%

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

    \[\leadsto \color{blue}{-1} \]
  4. Final simplification1.9%

    \[\leadsto -1 \]

Developer target: 99.1% 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 2023322 
(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)))))