2sqrt (example 3.1)

Percentage Accurate: 6.6% → 100.0%
Time: 10.6s
Alternatives: 8
Speedup: 2.0×

Specification

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

\\
\sqrt{x + 1} - \sqrt{x}
\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 8 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: 6.6% accurate, 1.0× speedup?

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

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

Alternative 1: 100.0% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 4.7%

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

      \[\leadsto \color{blue}{\frac{\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \frac{1}{2} \cdot \sqrt{x}}{x}} \]
    4. Step-by-step derivation
      1. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \frac{1}{2} \cdot \sqrt{x}\right), \color{blue}{x}\right) \]
      2. remove-double-negN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right)\right)\right), x\right) \]
      3. mul-1-negN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \left(\mathsf{neg}\left(-1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right)\right), x\right) \]
      4. unsub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} - -1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right), x\right) \]
      5. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}}\right), \left(-1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right), x\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \left(\sqrt{\frac{1}{x}}\right)\right), \left(-1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right), x\right) \]
      7. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\left(\frac{1}{x}\right)\right)\right), \left(-1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right), x\right) \]
      8. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \left(-1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right), x\right) \]
      9. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \left(\left(-1 \cdot \frac{1}{2}\right) \cdot \sqrt{x}\right)\right), x\right) \]
      10. metadata-evalN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \left(\frac{-1}{2} \cdot \sqrt{x}\right)\right), x\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \left(\sqrt{x} \cdot \frac{-1}{2}\right)\right), x\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \mathsf{*.f64}\left(\left(\sqrt{x}\right), \frac{-1}{2}\right)\right), x\right) \]
      13. sqrt-lowering-sqrt.f6499.6%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(x\right), \frac{-1}{2}\right)\right), x\right) \]
    5. Simplified99.6%

      \[\leadsto \color{blue}{\frac{-0.125 \cdot \sqrt{\frac{1}{x}} - \sqrt{x} \cdot -0.5}{x}} \]
    6. Step-by-step derivation
      1. div-subN/A

        \[\leadsto \frac{\frac{-1}{8} \cdot \sqrt{\frac{1}{x}}}{x} - \color{blue}{\frac{\sqrt{x} \cdot \frac{-1}{2}}{x}} \]
      2. --lowering--.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\frac{-1}{8} \cdot \sqrt{\frac{1}{x}}}{x}\right), \color{blue}{\left(\frac{\sqrt{x} \cdot \frac{-1}{2}}{x}\right)}\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\sqrt{\frac{1}{x}} \cdot \frac{-1}{8}}{x}\right), \left(\frac{\color{blue}{\sqrt{x}} \cdot \frac{-1}{2}}{x}\right)\right) \]
      4. associate-/l*N/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\sqrt{\frac{1}{x}} \cdot \frac{\frac{-1}{8}}{x}\right), \left(\frac{\color{blue}{\sqrt{x} \cdot \frac{-1}{2}}}{x}\right)\right) \]
      5. sqrt-divN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\sqrt{1}}{\sqrt{x}} \cdot \frac{\frac{-1}{8}}{x}\right), \left(\frac{\color{blue}{\sqrt{x}} \cdot \frac{-1}{2}}{x}\right)\right) \]
      6. metadata-evalN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{1}{\sqrt{x}} \cdot \frac{\frac{-1}{8}}{x}\right), \left(\frac{\sqrt{\color{blue}{x}} \cdot \frac{-1}{2}}{x}\right)\right) \]
      7. frac-timesN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{1 \cdot \frac{-1}{8}}{\sqrt{x} \cdot x}\right), \left(\frac{\color{blue}{\sqrt{x} \cdot \frac{-1}{2}}}{x}\right)\right) \]
      8. metadata-evalN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\frac{-1}{8}}{\sqrt{x} \cdot x}\right), \left(\frac{\color{blue}{\sqrt{x}} \cdot \frac{-1}{2}}{x}\right)\right) \]
      9. rem-square-sqrtN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\frac{-1}{8}}{\sqrt{x} \cdot \left(\sqrt{x} \cdot \sqrt{x}\right)}\right), \left(\frac{\sqrt{x} \cdot \frac{-1}{2}}{x}\right)\right) \]
      10. cube-multN/A

        \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\frac{-1}{8}}{{\left(\sqrt{x}\right)}^{3}}\right), \left(\frac{\sqrt{x} \cdot \color{blue}{\frac{-1}{2}}}{x}\right)\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left({\left(\sqrt{x}\right)}^{3}\right)\right), \left(\frac{\color{blue}{\sqrt{x} \cdot \frac{-1}{2}}}{x}\right)\right) \]
      12. pow1/2N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left({\left({x}^{\frac{1}{2}}\right)}^{3}\right)\right), \left(\frac{\sqrt{x} \cdot \frac{-1}{2}}{x}\right)\right) \]
      13. pow-powN/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left({x}^{\left(\frac{1}{2} \cdot 3\right)}\right)\right), \left(\frac{\sqrt{x} \cdot \color{blue}{\frac{-1}{2}}}{x}\right)\right) \]
      14. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{pow.f64}\left(x, \left(\frac{1}{2} \cdot 3\right)\right)\right), \left(\frac{\sqrt{x} \cdot \color{blue}{\frac{-1}{2}}}{x}\right)\right) \]
      15. metadata-evalN/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{pow.f64}\left(x, \frac{3}{2}\right)\right), \left(\frac{\sqrt{x} \cdot \frac{-1}{2}}{x}\right)\right) \]
      16. *-rgt-identityN/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{pow.f64}\left(x, \frac{3}{2}\right)\right), \left(\frac{\sqrt{x} \cdot \frac{-1}{2}}{x \cdot \color{blue}{1}}\right)\right) \]
      17. times-fracN/A

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{pow.f64}\left(x, \frac{3}{2}\right)\right), \left(\frac{\sqrt{x}}{x} \cdot \color{blue}{\frac{\frac{-1}{2}}{1}}\right)\right) \]
    7. Applied egg-rr100.0%

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

    if 5.00000000000000024e-5 < (-.f64 (sqrt.f64 (+.f64 x #s(literal 1 binary64))) (sqrt.f64 x))

    1. Initial program 88.4%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Applied egg-rr99.5%

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

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

Alternative 2: 99.9% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 3.9%

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \sqrt{\frac{1}{x}}} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(\sqrt{\frac{1}{x}}\right)}\right) \]
      2. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\left(\frac{1}{x}\right)\right)\right) \]
      3. /-lowering-/.f6499.8%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right) \]
    5. Simplified99.8%

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{x}}} \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sqrt{\frac{1}{x}} \cdot \color{blue}{\frac{1}{2}} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{1}{x}}\right), \color{blue}{\frac{1}{2}}\right) \]
      3. inv-powN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{{x}^{-1}}\right), \frac{1}{2}\right) \]
      4. sqrt-pow1N/A

        \[\leadsto \mathsf{*.f64}\left(\left({x}^{\left(\frac{-1}{2}\right)}\right), \frac{1}{2}\right) \]
      5. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\left({x}^{\frac{-1}{2}}\right), \frac{1}{2}\right) \]
      6. pow-lowering-pow.f64100.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(x, \frac{-1}{2}\right), \frac{1}{2}\right) \]
    7. Applied egg-rr100.0%

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

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

    1. Initial program 78.4%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--N/A

        \[\leadsto \frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\color{blue}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. clear-numN/A

        \[\leadsto \frac{1}{\color{blue}{\frac{\sqrt{x + 1} + \sqrt{x}}{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}}} \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(\frac{\sqrt{x + 1} + \sqrt{x}}{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}\right)}\right) \]
      4. clear-numN/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\frac{1}{\color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}}}\right)\right) \]
      5. flip--N/A

        \[\leadsto \mathsf{/.f64}\left(1, \left(\frac{1}{\sqrt{x + 1} - \color{blue}{\sqrt{x}}}\right)\right) \]
      6. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \color{blue}{\left(\sqrt{x + 1} - \sqrt{x}\right)}\right)\right) \]
      7. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(\left(\sqrt{x + 1}\right), \color{blue}{\left(\sqrt{x}\right)}\right)\right)\right) \]
      8. pow1/2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(\left({\left(x + 1\right)}^{\frac{1}{2}}\right), \left(\sqrt{\color{blue}{x}}\right)\right)\right)\right) \]
      9. pow-lowering-pow.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(\mathsf{pow.f64}\left(\left(x + 1\right), \frac{1}{2}\right), \left(\sqrt{\color{blue}{x}}\right)\right)\right)\right) \]
      10. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{1}{2}\right), \left(\sqrt{x}\right)\right)\right)\right) \]
      11. sqrt-lowering-sqrt.f6478.3%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{1}{2}\right), \mathsf{sqrt.f64}\left(x\right)\right)\right)\right) \]
    4. Applied egg-rr78.3%

      \[\leadsto \color{blue}{\frac{1}{\frac{1}{{\left(x + 1\right)}^{0.5} - \sqrt{x}}}} \]
    5. Step-by-step derivation
      1. unpow1/2N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(\left(\sqrt{x + 1}\right), \mathsf{sqrt.f64}\left(\color{blue}{x}\right)\right)\right)\right) \]
      2. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(\mathsf{sqrt.f64}\left(\left(x + 1\right)\right), \mathsf{sqrt.f64}\left(\color{blue}{x}\right)\right)\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(\mathsf{sqrt.f64}\left(\left(1 + x\right)\right), \mathsf{sqrt.f64}\left(x\right)\right)\right)\right) \]
      4. +-lowering-+.f6478.3%

        \[\leadsto \mathsf{/.f64}\left(1, \mathsf{/.f64}\left(1, \mathsf{\_.f64}\left(\mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(1, x\right)\right), \mathsf{sqrt.f64}\left(x\right)\right)\right)\right) \]
    6. Applied egg-rr78.3%

      \[\leadsto \frac{1}{\frac{1}{\color{blue}{\sqrt{1 + x}} - \sqrt{x}}} \]
    7. Step-by-step derivation
      1. remove-double-divN/A

        \[\leadsto \sqrt{1 + x} - \color{blue}{\sqrt{x}} \]
      2. flip--N/A

        \[\leadsto \frac{\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}}{\color{blue}{\sqrt{1 + x} + \sqrt{x}}} \]
      3. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\left(\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}\right), \color{blue}{\left(\sqrt{1 + x} + \sqrt{x}\right)}\right) \]
      4. rem-square-sqrtN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(1 + x\right) - \sqrt{x} \cdot \sqrt{x}\right), \left(\sqrt{\color{blue}{1 + x}} + \sqrt{x}\right)\right) \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x + 1\right) - \sqrt{x} \cdot \sqrt{x}\right), \left(\sqrt{\color{blue}{1 + x}} + \sqrt{x}\right)\right) \]
      6. rem-square-sqrtN/A

        \[\leadsto \mathsf{/.f64}\left(\left(\left(x + 1\right) - x\right), \left(\sqrt{1 + x} + \sqrt{x}\right)\right) \]
      7. associate--l+N/A

        \[\leadsto \mathsf{/.f64}\left(\left(x + \left(1 - x\right)\right), \left(\color{blue}{\sqrt{1 + x}} + \sqrt{x}\right)\right) \]
      8. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \left(1 - x\right)\right), \left(\color{blue}{\sqrt{1 + x}} + \sqrt{x}\right)\right) \]
      9. --lowering--.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \left(\sqrt{1 + x} + \sqrt{x}\right)\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \left(\sqrt{x} + \color{blue}{\sqrt{1 + x}}\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\left(\sqrt{x}\right), \color{blue}{\left(\sqrt{1 + x}\right)}\right)\right) \]
      12. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \left(\sqrt{\color{blue}{1 + x}}\right)\right)\right) \]
      13. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \mathsf{sqrt.f64}\left(\left(1 + x\right)\right)\right)\right) \]
      14. +-commutativeN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \mathsf{sqrt.f64}\left(\left(x + 1\right)\right)\right)\right) \]
      15. +-lowering-+.f6499.5%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(x, \mathsf{\_.f64}\left(1, x\right)\right), \mathsf{+.f64}\left(\mathsf{sqrt.f64}\left(x\right), \mathsf{sqrt.f64}\left(\mathsf{+.f64}\left(x, 1\right)\right)\right)\right) \]
    8. Applied egg-rr99.5%

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

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

Alternative 3: 99.1% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 60000000:\\
\;\;\;\;\sqrt{x + 1} - \sqrt{x}\\

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


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

    1. Initial program 88.4%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing

    if 6e7 < x

    1. Initial program 4.7%

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \sqrt{\frac{1}{x}}} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(\sqrt{\frac{1}{x}}\right)}\right) \]
      2. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\left(\frac{1}{x}\right)\right)\right) \]
      3. /-lowering-/.f6499.3%

        \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right) \]
    5. Simplified99.3%

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{x}}} \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \sqrt{\frac{1}{x}} \cdot \color{blue}{\frac{1}{2}} \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{1}{x}}\right), \color{blue}{\frac{1}{2}}\right) \]
      3. inv-powN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{{x}^{-1}}\right), \frac{1}{2}\right) \]
      4. sqrt-pow1N/A

        \[\leadsto \mathsf{*.f64}\left(\left({x}^{\left(\frac{-1}{2}\right)}\right), \frac{1}{2}\right) \]
      5. metadata-evalN/A

        \[\leadsto \mathsf{*.f64}\left(\left({x}^{\frac{-1}{2}}\right), \frac{1}{2}\right) \]
      6. pow-lowering-pow.f6499.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(x, \frac{-1}{2}\right), \frac{1}{2}\right) \]
    7. Applied egg-rr99.5%

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

Alternative 4: 99.1% accurate, 1.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \frac{1}{2} \cdot \sqrt{x}}{x}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \frac{1}{2} \cdot \sqrt{x}\right), \color{blue}{x}\right) \]
    2. remove-double-negN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right)\right)\right), x\right) \]
    3. mul-1-negN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \left(\mathsf{neg}\left(-1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right)\right), x\right) \]
    4. unsub-negN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} - -1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right), x\right) \]
    5. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}}\right), \left(-1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right), x\right) \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \left(\sqrt{\frac{1}{x}}\right)\right), \left(-1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right), x\right) \]
    7. sqrt-lowering-sqrt.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\left(\frac{1}{x}\right)\right)\right), \left(-1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right), x\right) \]
    8. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \left(-1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right), x\right) \]
    9. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \left(\left(-1 \cdot \frac{1}{2}\right) \cdot \sqrt{x}\right)\right), x\right) \]
    10. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \left(\frac{-1}{2} \cdot \sqrt{x}\right)\right), x\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \left(\sqrt{x} \cdot \frac{-1}{2}\right)\right), x\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \mathsf{*.f64}\left(\left(\sqrt{x}\right), \frac{-1}{2}\right)\right), x\right) \]
    13. sqrt-lowering-sqrt.f6497.8%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(x\right), \frac{-1}{2}\right)\right), x\right) \]
  5. Simplified97.8%

    \[\leadsto \color{blue}{\frac{-0.125 \cdot \sqrt{\frac{1}{x}} - \sqrt{x} \cdot -0.5}{x}} \]
  6. Step-by-step derivation
    1. div-subN/A

      \[\leadsto \frac{\frac{-1}{8} \cdot \sqrt{\frac{1}{x}}}{x} - \color{blue}{\frac{\sqrt{x} \cdot \frac{-1}{2}}{x}} \]
    2. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\frac{-1}{8} \cdot \sqrt{\frac{1}{x}}}{x}\right), \color{blue}{\left(\frac{\sqrt{x} \cdot \frac{-1}{2}}{x}\right)}\right) \]
    3. *-commutativeN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\sqrt{\frac{1}{x}} \cdot \frac{-1}{8}}{x}\right), \left(\frac{\color{blue}{\sqrt{x}} \cdot \frac{-1}{2}}{x}\right)\right) \]
    4. associate-/l*N/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\sqrt{\frac{1}{x}} \cdot \frac{\frac{-1}{8}}{x}\right), \left(\frac{\color{blue}{\sqrt{x} \cdot \frac{-1}{2}}}{x}\right)\right) \]
    5. sqrt-divN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\sqrt{1}}{\sqrt{x}} \cdot \frac{\frac{-1}{8}}{x}\right), \left(\frac{\color{blue}{\sqrt{x}} \cdot \frac{-1}{2}}{x}\right)\right) \]
    6. metadata-evalN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\frac{1}{\sqrt{x}} \cdot \frac{\frac{-1}{8}}{x}\right), \left(\frac{\sqrt{\color{blue}{x}} \cdot \frac{-1}{2}}{x}\right)\right) \]
    7. frac-timesN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\frac{1 \cdot \frac{-1}{8}}{\sqrt{x} \cdot x}\right), \left(\frac{\color{blue}{\sqrt{x} \cdot \frac{-1}{2}}}{x}\right)\right) \]
    8. metadata-evalN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\frac{-1}{8}}{\sqrt{x} \cdot x}\right), \left(\frac{\color{blue}{\sqrt{x}} \cdot \frac{-1}{2}}{x}\right)\right) \]
    9. rem-square-sqrtN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\frac{-1}{8}}{\sqrt{x} \cdot \left(\sqrt{x} \cdot \sqrt{x}\right)}\right), \left(\frac{\sqrt{x} \cdot \frac{-1}{2}}{x}\right)\right) \]
    10. cube-multN/A

      \[\leadsto \mathsf{\_.f64}\left(\left(\frac{\frac{-1}{8}}{{\left(\sqrt{x}\right)}^{3}}\right), \left(\frac{\sqrt{x} \cdot \color{blue}{\frac{-1}{2}}}{x}\right)\right) \]
    11. /-lowering-/.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left({\left(\sqrt{x}\right)}^{3}\right)\right), \left(\frac{\color{blue}{\sqrt{x} \cdot \frac{-1}{2}}}{x}\right)\right) \]
    12. pow1/2N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left({\left({x}^{\frac{1}{2}}\right)}^{3}\right)\right), \left(\frac{\sqrt{x} \cdot \frac{-1}{2}}{x}\right)\right) \]
    13. pow-powN/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \left({x}^{\left(\frac{1}{2} \cdot 3\right)}\right)\right), \left(\frac{\sqrt{x} \cdot \color{blue}{\frac{-1}{2}}}{x}\right)\right) \]
    14. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{pow.f64}\left(x, \left(\frac{1}{2} \cdot 3\right)\right)\right), \left(\frac{\sqrt{x} \cdot \color{blue}{\frac{-1}{2}}}{x}\right)\right) \]
    15. metadata-evalN/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{pow.f64}\left(x, \frac{3}{2}\right)\right), \left(\frac{\sqrt{x} \cdot \frac{-1}{2}}{x}\right)\right) \]
    16. *-rgt-identityN/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{pow.f64}\left(x, \frac{3}{2}\right)\right), \left(\frac{\sqrt{x} \cdot \frac{-1}{2}}{x \cdot \color{blue}{1}}\right)\right) \]
    17. times-fracN/A

      \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{pow.f64}\left(x, \frac{3}{2}\right)\right), \left(\frac{\sqrt{x}}{x} \cdot \color{blue}{\frac{\frac{-1}{2}}{1}}\right)\right) \]
  7. Applied egg-rr98.2%

    \[\leadsto \color{blue}{\frac{-0.125}{{x}^{1.5}} - {x}^{-0.5} \cdot -0.5} \]
  8. Final simplification98.2%

    \[\leadsto \frac{-0.125}{{x}^{1.5}} - -0.5 \cdot {x}^{-0.5} \]
  9. Add Preprocessing

Alternative 5: 98.7% accurate, 1.0× speedup?

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

\\
\frac{-0.125}{{x}^{1.5}} + \frac{0.5}{\sqrt{x}}
\end{array}
Derivation
  1. Initial program 7.7%

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

    \[\leadsto \color{blue}{\frac{\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \frac{1}{2} \cdot \sqrt{x}}{x}} \]
  4. Step-by-step derivation
    1. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \frac{1}{2} \cdot \sqrt{x}\right), \color{blue}{x}\right) \]
    2. remove-double-negN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right)\right)\right), x\right) \]
    3. mul-1-negN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \left(\mathsf{neg}\left(-1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right)\right), x\right) \]
    4. unsub-negN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} - -1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right), x\right) \]
    5. --lowering--.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}}\right), \left(-1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right), x\right) \]
    6. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \left(\sqrt{\frac{1}{x}}\right)\right), \left(-1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right), x\right) \]
    7. sqrt-lowering-sqrt.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\left(\frac{1}{x}\right)\right)\right), \left(-1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right), x\right) \]
    8. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \left(-1 \cdot \left(\frac{1}{2} \cdot \sqrt{x}\right)\right)\right), x\right) \]
    9. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \left(\left(-1 \cdot \frac{1}{2}\right) \cdot \sqrt{x}\right)\right), x\right) \]
    10. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \left(\frac{-1}{2} \cdot \sqrt{x}\right)\right), x\right) \]
    11. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \left(\sqrt{x} \cdot \frac{-1}{2}\right)\right), x\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \mathsf{*.f64}\left(\left(\sqrt{x}\right), \frac{-1}{2}\right)\right), x\right) \]
    13. sqrt-lowering-sqrt.f6497.8%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{8}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right), \mathsf{*.f64}\left(\mathsf{sqrt.f64}\left(x\right), \frac{-1}{2}\right)\right), x\right) \]
  5. Simplified97.8%

    \[\leadsto \color{blue}{\frac{-0.125 \cdot \sqrt{\frac{1}{x}} - \sqrt{x} \cdot -0.5}{x}} \]
  6. Step-by-step derivation
    1. clear-numN/A

      \[\leadsto \frac{1}{\color{blue}{\frac{x}{\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} - \sqrt{x} \cdot \frac{-1}{2}}}} \]
    2. associate-/r/N/A

      \[\leadsto \frac{1}{x} \cdot \color{blue}{\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} - \sqrt{x} \cdot \frac{-1}{2}\right)} \]
    3. sub-negN/A

      \[\leadsto \frac{1}{x} \cdot \left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \color{blue}{\left(\mathsf{neg}\left(\sqrt{x} \cdot \frac{-1}{2}\right)\right)}\right) \]
    4. +-commutativeN/A

      \[\leadsto \frac{1}{x} \cdot \left(\left(\mathsf{neg}\left(\sqrt{x} \cdot \frac{-1}{2}\right)\right) + \color{blue}{\frac{-1}{8} \cdot \sqrt{\frac{1}{x}}}\right) \]
    5. distribute-rgt-inN/A

      \[\leadsto \left(\mathsf{neg}\left(\sqrt{x} \cdot \frac{-1}{2}\right)\right) \cdot \frac{1}{x} + \color{blue}{\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}}\right) \cdot \frac{1}{x}} \]
    6. distribute-lft-neg-inN/A

      \[\leadsto \left(\mathsf{neg}\left(\left(\sqrt{x} \cdot \frac{-1}{2}\right) \cdot \frac{1}{x}\right)\right) + \color{blue}{\left(\frac{-1}{8} \cdot \sqrt{\frac{1}{x}}\right)} \cdot \frac{1}{x} \]
    7. div-invN/A

      \[\leadsto \left(\mathsf{neg}\left(\frac{\sqrt{x} \cdot \frac{-1}{2}}{x}\right)\right) + \left(\color{blue}{\frac{-1}{8}} \cdot \sqrt{\frac{1}{x}}\right) \cdot \frac{1}{x} \]
    8. div-invN/A

      \[\leadsto \left(\mathsf{neg}\left(\frac{\sqrt{x} \cdot \frac{-1}{2}}{x}\right)\right) + \frac{\frac{-1}{8} \cdot \sqrt{\frac{1}{x}}}{\color{blue}{x}} \]
    9. +-lowering-+.f64N/A

      \[\leadsto \mathsf{+.f64}\left(\left(\mathsf{neg}\left(\frac{\sqrt{x} \cdot \frac{-1}{2}}{x}\right)\right), \color{blue}{\left(\frac{\frac{-1}{8} \cdot \sqrt{\frac{1}{x}}}{x}\right)}\right) \]
  7. Applied egg-rr97.8%

    \[\leadsto \color{blue}{\frac{0.5}{\sqrt{x}} + \frac{-0.125}{{x}^{1.5}}} \]
  8. Final simplification97.8%

    \[\leadsto \frac{-0.125}{{x}^{1.5}} + \frac{0.5}{\sqrt{x}} \]
  9. Add Preprocessing

Alternative 6: 98.1% accurate, 2.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{1}{2} \cdot \sqrt{\frac{1}{x}}} \]
  4. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(\sqrt{\frac{1}{x}}\right)}\right) \]
    2. sqrt-lowering-sqrt.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\left(\frac{1}{x}\right)\right)\right) \]
    3. /-lowering-/.f6497.0%

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right) \]
  5. Simplified97.0%

    \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{x}}} \]
  6. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \sqrt{\frac{1}{x}} \cdot \color{blue}{\frac{1}{2}} \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{\frac{1}{x}}\right), \color{blue}{\frac{1}{2}}\right) \]
    3. inv-powN/A

      \[\leadsto \mathsf{*.f64}\left(\left(\sqrt{{x}^{-1}}\right), \frac{1}{2}\right) \]
    4. sqrt-pow1N/A

      \[\leadsto \mathsf{*.f64}\left(\left({x}^{\left(\frac{-1}{2}\right)}\right), \frac{1}{2}\right) \]
    5. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\left({x}^{\frac{-1}{2}}\right), \frac{1}{2}\right) \]
    6. pow-lowering-pow.f6497.2%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{pow.f64}\left(x, \frac{-1}{2}\right), \frac{1}{2}\right) \]
  7. Applied egg-rr97.2%

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

Alternative 7: 97.8% accurate, 2.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{1}{2} \cdot \sqrt{\frac{1}{x}}} \]
  4. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \color{blue}{\left(\sqrt{\frac{1}{x}}\right)}\right) \]
    2. sqrt-lowering-sqrt.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\left(\frac{1}{x}\right)\right)\right) \]
    3. /-lowering-/.f6497.0%

      \[\leadsto \mathsf{*.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right)\right) \]
  5. Simplified97.0%

    \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{x}}} \]
  6. Step-by-step derivation
    1. sqrt-divN/A

      \[\leadsto \frac{1}{2} \cdot \frac{\sqrt{1}}{\color{blue}{\sqrt{x}}} \]
    2. metadata-evalN/A

      \[\leadsto \frac{1}{2} \cdot \frac{1}{\sqrt{\color{blue}{x}}} \]
    3. un-div-invN/A

      \[\leadsto \frac{\frac{1}{2}}{\color{blue}{\sqrt{x}}} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{\left(\sqrt{x}\right)}\right) \]
    5. sqrt-lowering-sqrt.f6496.8%

      \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \mathsf{sqrt.f64}\left(x\right)\right) \]
  7. Applied egg-rr96.8%

    \[\leadsto \color{blue}{\frac{0.5}{\sqrt{x}}} \]
  8. Add Preprocessing

Alternative 8: 1.6% accurate, 2.0× speedup?

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

\\
1 - \sqrt{x}
\end{array}
Derivation
  1. Initial program 7.7%

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

    \[\leadsto \color{blue}{1 - \sqrt{x}} \]
  4. Step-by-step derivation
    1. --lowering--.f64N/A

      \[\leadsto \mathsf{\_.f64}\left(1, \color{blue}{\left(\sqrt{x}\right)}\right) \]
    2. sqrt-lowering-sqrt.f641.6%

      \[\leadsto \mathsf{\_.f64}\left(1, \mathsf{sqrt.f64}\left(x\right)\right) \]
  5. Simplified1.6%

    \[\leadsto \color{blue}{1 - \sqrt{x}} \]
  6. Add Preprocessing

Developer Target 1: 99.6% accurate, 1.0× speedup?

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

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

Developer Target 2: 98.1% accurate, 2.0× speedup?

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

\\
0.5 \cdot {x}^{-0.5}
\end{array}

Reproduce

?
herbie shell --seed 2024191 
(FPCore (x)
  :name "2sqrt (example 3.1)"
  :precision binary64
  :pre (and (> x 1.0) (< x 1e+308))

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

  :alt
  (! :herbie-platform default (* 1/2 (pow x -1/2)))

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