2isqrt (example 3.6)

Percentage Accurate: 38.9% → 99.3%
Time: 10.9s
Alternatives: 12
Speedup: 2.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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: 38.9% 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.3% accurate, 1.7× speedup?

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

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

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Add Preprocessing
  3. Applied egg-rr39.6%

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

    \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{\left(\frac{1}{2} + \frac{\frac{1}{16}}{{x}^{2}}\right) - \left(\frac{1}{8} \cdot \frac{1}{x} + \frac{5}{128} \cdot \frac{1}{{x}^{3}}\right)}{x}\right)}, \mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, x\right), \frac{-1}{2}\right)\right) \]
  5. Simplified99.5%

    \[\leadsto \color{blue}{\frac{0.5 + \left(\frac{-0.125 + \frac{0.0625}{x}}{x} - \frac{0.0390625}{x \cdot \left(x \cdot x\right)}\right)}{x}} \cdot {\left(1 + x\right)}^{-0.5} \]
  6. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto {\left(1 + x\right)}^{\frac{-1}{2}} \cdot \color{blue}{\frac{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}{x}} \]
    2. clear-numN/A

      \[\leadsto {\left(1 + x\right)}^{\frac{-1}{2}} \cdot \frac{1}{\color{blue}{\frac{x}{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}}} \]
    3. un-div-invN/A

      \[\leadsto \frac{{\left(1 + x\right)}^{\frac{-1}{2}}}{\color{blue}{\frac{x}{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}}} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left({\left(1 + x\right)}^{\frac{-1}{2}}\right), \color{blue}{\left(\frac{x}{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}\right)}\right) \]
    5. +-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\left({\left(x + 1\right)}^{\frac{-1}{2}}\right), \left(\frac{x}{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}\right)\right) \]
    6. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\left(x + 1\right), \frac{-1}{2}\right), \left(\frac{\color{blue}{x}}{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}\right)\right) \]
    7. +-lowering-+.f64N/A

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \color{blue}{\left(\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)\right)}\right)\right) \]
    9. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}\right)\right)\right) \]
    10. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{\left(x \cdot x\right) \cdot \color{blue}{x}}\right)\right)\right)\right) \]
    11. associate-/r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{\frac{5}{128}}{x \cdot x}}{\color{blue}{x}}\right)\right)\right)\right) \]
    12. sub-divN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\left(\frac{-1}{8} + \frac{\frac{1}{16}}{x}\right) - \frac{\frac{5}{128}}{x \cdot x}}{\color{blue}{x}}\right)\right)\right)\right) \]
    13. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(\left(\frac{-1}{8} + \frac{\frac{1}{16}}{x}\right) - \frac{\frac{5}{128}}{x \cdot x}\right), \color{blue}{x}\right)\right)\right)\right) \]
  7. Applied egg-rr99.5%

    \[\leadsto \color{blue}{\frac{{\left(x + 1\right)}^{-0.5}}{\frac{x}{0.5 + \frac{\left(-0.125 + \frac{0.0625}{x}\right) - \frac{0.0390625}{x \cdot x}}{x}}}} \]
  8. Taylor expanded in x around -inf

    \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \color{blue}{\left(-1 \cdot \left(x \cdot \left(-1 \cdot \frac{\frac{1}{2} + -1 \cdot \frac{\frac{1}{8} - \frac{1}{16} \cdot \frac{1}{x}}{x}}{x} - 2\right)\right)\right)}\right) \]
  9. Simplified99.6%

    \[\leadsto \frac{{\left(x + 1\right)}^{-0.5}}{\color{blue}{x \cdot \left(2 + \frac{0.5 + \frac{-0.125 + \frac{0.0625}{x}}{x}}{x}\right)}} \]
  10. Add Preprocessing

Alternative 2: 99.2% accurate, 1.8× speedup?

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

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

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Add Preprocessing
  3. Applied egg-rr39.6%

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

    \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{\left(\frac{1}{2} + \frac{\frac{1}{16}}{{x}^{2}}\right) - \left(\frac{1}{8} \cdot \frac{1}{x} + \frac{5}{128} \cdot \frac{1}{{x}^{3}}\right)}{x}\right)}, \mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, x\right), \frac{-1}{2}\right)\right) \]
  5. Simplified99.5%

    \[\leadsto \color{blue}{\frac{0.5 + \left(\frac{-0.125 + \frac{0.0625}{x}}{x} - \frac{0.0390625}{x \cdot \left(x \cdot x\right)}\right)}{x}} \cdot {\left(1 + x\right)}^{-0.5} \]
  6. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto {\left(1 + x\right)}^{\frac{-1}{2}} \cdot \color{blue}{\frac{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}{x}} \]
    2. clear-numN/A

      \[\leadsto {\left(1 + x\right)}^{\frac{-1}{2}} \cdot \frac{1}{\color{blue}{\frac{x}{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}}} \]
    3. un-div-invN/A

      \[\leadsto \frac{{\left(1 + x\right)}^{\frac{-1}{2}}}{\color{blue}{\frac{x}{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}}} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left({\left(1 + x\right)}^{\frac{-1}{2}}\right), \color{blue}{\left(\frac{x}{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}\right)}\right) \]
    5. +-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\left({\left(x + 1\right)}^{\frac{-1}{2}}\right), \left(\frac{x}{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}\right)\right) \]
    6. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\left(x + 1\right), \frac{-1}{2}\right), \left(\frac{\color{blue}{x}}{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}\right)\right) \]
    7. +-lowering-+.f64N/A

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \color{blue}{\left(\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)\right)}\right)\right) \]
    9. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}\right)\right)\right) \]
    10. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{\left(x \cdot x\right) \cdot \color{blue}{x}}\right)\right)\right)\right) \]
    11. associate-/r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{\frac{5}{128}}{x \cdot x}}{\color{blue}{x}}\right)\right)\right)\right) \]
    12. sub-divN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\left(\frac{-1}{8} + \frac{\frac{1}{16}}{x}\right) - \frac{\frac{5}{128}}{x \cdot x}}{\color{blue}{x}}\right)\right)\right)\right) \]
    13. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(\left(\frac{-1}{8} + \frac{\frac{1}{16}}{x}\right) - \frac{\frac{5}{128}}{x \cdot x}\right), \color{blue}{x}\right)\right)\right)\right) \]
  7. Applied egg-rr99.5%

    \[\leadsto \color{blue}{\frac{{\left(x + 1\right)}^{-0.5}}{\frac{x}{0.5 + \frac{\left(-0.125 + \frac{0.0625}{x}\right) - \frac{0.0390625}{x \cdot x}}{x}}}} \]
  8. Taylor expanded in x around inf

    \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \color{blue}{\left(x \cdot \left(\left(2 + \frac{1}{2} \cdot \frac{1}{x}\right) - \frac{\frac{1}{8}}{{x}^{2}}\right)\right)}\right) \]
  9. Step-by-step derivation
    1. associate-*r/N/A

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

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \left(x \cdot \left(\frac{\frac{1}{2}}{x} + \color{blue}{\left(2 - \frac{\frac{1}{8}}{{x}^{2}}\right)}\right)\right)\right) \]
    5. distribute-lft-inN/A

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \left(x \cdot \frac{\frac{1}{2} \cdot 1}{x} + x \cdot \left(2 - \frac{\frac{1}{8}}{{x}^{2}}\right)\right)\right) \]
    7. associate-*r/N/A

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \left(\left(x \cdot \frac{1}{x}\right) \cdot \frac{1}{2} + \color{blue}{x} \cdot \left(2 - \frac{\frac{1}{8}}{{x}^{2}}\right)\right)\right) \]
    10. rgt-mult-inverseN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \left(1 \cdot \frac{1}{2} + x \cdot \left(2 - \frac{\frac{1}{8}}{{x}^{2}}\right)\right)\right) \]
    11. metadata-evalN/A

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \color{blue}{\left(2 - \frac{\frac{1}{8}}{{x}^{2}}\right)}\right)\right)\right) \]
    14. sub-negN/A

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(2, \color{blue}{\left(\mathsf{neg}\left(\frac{\frac{1}{8}}{{x}^{2}}\right)\right)}\right)\right)\right)\right) \]
    16. distribute-neg-fracN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(2, \left(\frac{\mathsf{neg}\left(\frac{1}{8}\right)}{\color{blue}{{x}^{2}}}\right)\right)\right)\right)\right) \]
    17. metadata-evalN/A

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(2, \mathsf{/.f64}\left(\frac{-1}{8}, \color{blue}{\left({x}^{2}\right)}\right)\right)\right)\right)\right) \]
    19. unpow2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(2, \mathsf{/.f64}\left(\frac{-1}{8}, \left(x \cdot \color{blue}{x}\right)\right)\right)\right)\right)\right) \]
    20. *-lowering-*.f6499.5%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \mathsf{+.f64}\left(2, \mathsf{/.f64}\left(\frac{-1}{8}, \mathsf{*.f64}\left(x, \color{blue}{x}\right)\right)\right)\right)\right)\right) \]
  10. Simplified99.5%

    \[\leadsto \frac{{\left(x + 1\right)}^{-0.5}}{\color{blue}{0.5 + x \cdot \left(2 + \frac{-0.125}{x \cdot x}\right)}} \]
  11. Add Preprocessing

Alternative 3: 99.0% accurate, 1.8× speedup?

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

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

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Add Preprocessing
  3. Applied egg-rr39.6%

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

    \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{\left(\frac{1}{2} + \frac{\frac{1}{16}}{{x}^{2}}\right) - \frac{1}{8} \cdot \frac{1}{x}}{x}\right)}, \mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, x\right), \frac{-1}{2}\right)\right) \]
  5. Simplified99.5%

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

    \[\leadsto \frac{0.5 + \frac{-0.125 + \frac{0.0625}{x}}{x}}{x} \cdot {\left(x + 1\right)}^{-0.5} \]
  7. Add Preprocessing

Alternative 4: 98.8% accurate, 1.9× speedup?

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

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

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Add Preprocessing
  3. Applied egg-rr39.6%

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

    \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{\left(\frac{1}{2} + \frac{\frac{1}{16}}{{x}^{2}}\right) - \left(\frac{1}{8} \cdot \frac{1}{x} + \frac{5}{128} \cdot \frac{1}{{x}^{3}}\right)}{x}\right)}, \mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, x\right), \frac{-1}{2}\right)\right) \]
  5. Simplified99.5%

    \[\leadsto \color{blue}{\frac{0.5 + \left(\frac{-0.125 + \frac{0.0625}{x}}{x} - \frac{0.0390625}{x \cdot \left(x \cdot x\right)}\right)}{x}} \cdot {\left(1 + x\right)}^{-0.5} \]
  6. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto {\left(1 + x\right)}^{\frac{-1}{2}} \cdot \color{blue}{\frac{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}{x}} \]
    2. clear-numN/A

      \[\leadsto {\left(1 + x\right)}^{\frac{-1}{2}} \cdot \frac{1}{\color{blue}{\frac{x}{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}}} \]
    3. un-div-invN/A

      \[\leadsto \frac{{\left(1 + x\right)}^{\frac{-1}{2}}}{\color{blue}{\frac{x}{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}}} \]
    4. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left({\left(1 + x\right)}^{\frac{-1}{2}}\right), \color{blue}{\left(\frac{x}{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}\right)}\right) \]
    5. +-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\left({\left(x + 1\right)}^{\frac{-1}{2}}\right), \left(\frac{x}{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}\right)\right) \]
    6. pow-lowering-pow.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\left(x + 1\right), \frac{-1}{2}\right), \left(\frac{\color{blue}{x}}{\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}\right)\right) \]
    7. +-lowering-+.f64N/A

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \color{blue}{\left(\frac{1}{2} + \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)\right)}\right)\right) \]
    9. +-lowering-+.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{x \cdot \left(x \cdot x\right)}\right)}\right)\right)\right) \]
    10. associate-*r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{5}{128}}{\left(x \cdot x\right) \cdot \color{blue}{x}}\right)\right)\right)\right) \]
    11. associate-/r*N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\frac{-1}{8} + \frac{\frac{1}{16}}{x}}{x} - \frac{\frac{\frac{5}{128}}{x \cdot x}}{\color{blue}{x}}\right)\right)\right)\right) \]
    12. sub-divN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \left(\frac{\left(\frac{-1}{8} + \frac{\frac{1}{16}}{x}\right) - \frac{\frac{5}{128}}{x \cdot x}}{\color{blue}{x}}\right)\right)\right)\right) \]
    13. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{/.f64}\left(\left(\left(\frac{-1}{8} + \frac{\frac{1}{16}}{x}\right) - \frac{\frac{5}{128}}{x \cdot x}\right), \color{blue}{x}\right)\right)\right)\right) \]
  7. Applied egg-rr99.5%

    \[\leadsto \color{blue}{\frac{{\left(x + 1\right)}^{-0.5}}{\frac{x}{0.5 + \frac{\left(-0.125 + \frac{0.0625}{x}\right) - \frac{0.0390625}{x \cdot x}}{x}}}} \]
  8. Taylor expanded in x around inf

    \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \color{blue}{\left(x \cdot \left(2 + \frac{1}{2} \cdot \frac{1}{x}\right)\right)}\right) \]
  9. Step-by-step derivation
    1. distribute-rgt-inN/A

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \left(2 \cdot x + \frac{1}{2} \cdot \color{blue}{\left(\frac{1}{x} \cdot x\right)}\right)\right) \]
    3. lft-mult-inverseN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \left(2 \cdot x + \frac{1}{2} \cdot 1\right)\right) \]
    4. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \left(2 \cdot x + \frac{1}{2}\right)\right) \]
    5. +-commutativeN/A

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{+.f64}\left(\frac{1}{2}, \color{blue}{\left(2 \cdot x\right)}\right)\right) \]
    7. *-commutativeN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{+.f64}\left(\frac{1}{2}, \left(x \cdot \color{blue}{2}\right)\right)\right) \]
    8. *-lowering-*.f6499.4%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(x, \color{blue}{2}\right)\right)\right) \]
  10. Simplified99.4%

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

Alternative 5: 97.8% accurate, 1.9× speedup?

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

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

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Add Preprocessing
  3. Applied egg-rr39.6%

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

    \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{\frac{1}{2}}{x}\right)}, \mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, x\right), \frac{-1}{2}\right)\right) \]
  5. Step-by-step derivation
    1. /-lowering-/.f6499.0%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, x\right), \mathsf{pow.f64}\left(\color{blue}{\mathsf{+.f64}\left(1, x\right)}, \frac{-1}{2}\right)\right) \]
  6. Simplified99.0%

    \[\leadsto \color{blue}{\frac{0.5}{x}} \cdot {\left(1 + x\right)}^{-0.5} \]
  7. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto {\left(1 + x\right)}^{\frac{-1}{2}} \cdot \color{blue}{\frac{\frac{1}{2}}{x}} \]
    2. clear-numN/A

      \[\leadsto {\left(1 + x\right)}^{\frac{-1}{2}} \cdot \frac{1}{\color{blue}{\frac{x}{\frac{1}{2}}}} \]
    3. un-div-invN/A

      \[\leadsto \frac{{\left(1 + x\right)}^{\frac{-1}{2}}}{\color{blue}{\frac{x}{\frac{1}{2}}}} \]
    4. metadata-evalN/A

      \[\leadsto \frac{{\left(1 + x\right)}^{\frac{-1}{2}}}{\frac{x}{\mathsf{neg}\left(\frac{-1}{2}\right)}} \]
    5. distribute-neg-frac2N/A

      \[\leadsto \frac{{\left(1 + x\right)}^{\frac{-1}{2}}}{\mathsf{neg}\left(\frac{x}{\frac{-1}{2}}\right)} \]
    6. /-lowering-/.f64N/A

      \[\leadsto \mathsf{/.f64}\left(\left({\left(1 + x\right)}^{\frac{-1}{2}}\right), \color{blue}{\left(\mathsf{neg}\left(\frac{x}{\frac{-1}{2}}\right)\right)}\right) \]
    7. +-commutativeN/A

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \left(\mathsf{neg}\left(\frac{\color{blue}{x}}{\frac{-1}{2}}\right)\right)\right) \]
    10. distribute-neg-frac2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \left(\frac{x}{\color{blue}{\mathsf{neg}\left(\frac{-1}{2}\right)}}\right)\right) \]
    11. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \left(\frac{x}{\frac{1}{2}}\right)\right) \]
    12. /-lowering-/.f6499.1%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(\mathsf{+.f64}\left(x, 1\right), \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \color{blue}{\frac{1}{2}}\right)\right) \]
  8. Applied egg-rr99.1%

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

Alternative 6: 97.7% accurate, 1.9× speedup?

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

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

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Add Preprocessing
  3. Applied egg-rr39.6%

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

    \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{\frac{1}{2}}{x}\right)}, \mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, x\right), \frac{-1}{2}\right)\right) \]
  5. Step-by-step derivation
    1. /-lowering-/.f6499.0%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, x\right), \mathsf{pow.f64}\left(\color{blue}{\mathsf{+.f64}\left(1, x\right)}, \frac{-1}{2}\right)\right) \]
  6. Simplified99.0%

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

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

Alternative 7: 97.7% accurate, 2.0× speedup?

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{-1}{2} \cdot \sqrt{\frac{1}{x}} - \frac{-1}{2} \cdot \sqrt{x}}{{x}^{2}}} \]
  4. Step-by-step derivation
    1. distribute-lft-out--N/A

      \[\leadsto \frac{\frac{-1}{2} \cdot \left(\sqrt{\frac{1}{x}} - \sqrt{x}\right)}{{\color{blue}{x}}^{2}} \]
    2. unpow2N/A

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{-0.5}{x} \cdot \left(\sqrt{\frac{1}{x}} - \sqrt{x}\right)}{x}} \]
  6. Step-by-step derivation
    1. /-lowering-/.f64N/A

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

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

    \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\color{blue}{\left(-1 \cdot \sqrt{x}\right)}, \mathsf{/.f64}\left(x, \frac{-1}{2}\right)\right), x\right) \]
  9. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\left(\mathsf{neg}\left(\sqrt{x}\right)\right), \mathsf{/.f64}\left(x, \frac{-1}{2}\right)\right), x\right) \]
    2. neg-sub0N/A

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(0, \left(\sqrt{x}\right)\right), \mathsf{/.f64}\left(x, \frac{-1}{2}\right)\right), x\right) \]
    4. sqrt-lowering-sqrt.f6498.9%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{sqrt.f64}\left(x\right)\right), \mathsf{/.f64}\left(x, \frac{-1}{2}\right)\right), x\right) \]
  10. Simplified98.9%

    \[\leadsto \frac{\frac{\color{blue}{0 - \sqrt{x}}}{\frac{x}{-0.5}}}{x} \]
  11. Step-by-step derivation
    1. div-invN/A

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

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

      \[\leadsto \frac{\mathsf{neg}\left(\left(\mathsf{neg}\left(\sqrt{x}\right)\right)\right)}{\mathsf{neg}\left(\frac{x}{\frac{-1}{2}}\right)} \cdot \frac{1}{x} \]
    4. remove-double-negN/A

      \[\leadsto \frac{\sqrt{x}}{\mathsf{neg}\left(\frac{x}{\frac{-1}{2}}\right)} \cdot \frac{1}{x} \]
    5. associate-*l/N/A

      \[\leadsto \frac{\sqrt{x} \cdot \frac{1}{x}}{\color{blue}{\mathsf{neg}\left(\frac{x}{\frac{-1}{2}}\right)}} \]
    6. pow1/2N/A

      \[\leadsto \frac{{x}^{\frac{1}{2}} \cdot \frac{1}{x}}{\mathsf{neg}\left(\frac{\color{blue}{x}}{\frac{-1}{2}}\right)} \]
    7. inv-powN/A

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

      \[\leadsto \frac{{x}^{\frac{1}{2}} \cdot {x}^{\left(\mathsf{neg}\left(1\right)\right)}}{\mathsf{neg}\left(\frac{x}{\frac{-1}{2}}\right)} \]
    9. pow-prod-upN/A

      \[\leadsto \frac{{x}^{\left(\frac{1}{2} + \left(\mathsf{neg}\left(1\right)\right)\right)}}{\mathsf{neg}\left(\color{blue}{\frac{x}{\frac{-1}{2}}}\right)} \]
    10. metadata-evalN/A

      \[\leadsto \frac{{x}^{\left(\frac{1}{2} + -1\right)}}{\mathsf{neg}\left(\frac{x}{\frac{-1}{2}}\right)} \]
    11. metadata-evalN/A

      \[\leadsto \frac{{x}^{\frac{-1}{2}}}{\mathsf{neg}\left(\frac{x}{\color{blue}{\frac{-1}{2}}}\right)} \]
    12. metadata-evalN/A

      \[\leadsto \frac{{x}^{\left(\mathsf{neg}\left(\frac{1}{2}\right)\right)}}{\mathsf{neg}\left(\frac{x}{\color{blue}{\frac{-1}{2}}}\right)} \]
    13. pow-flipN/A

      \[\leadsto \frac{\frac{1}{{x}^{\frac{1}{2}}}}{\mathsf{neg}\left(\color{blue}{\frac{x}{\frac{-1}{2}}}\right)} \]
    14. pow1/2N/A

      \[\leadsto \frac{\frac{1}{\sqrt{x}}}{\mathsf{neg}\left(\frac{x}{\color{blue}{\frac{-1}{2}}}\right)} \]
    15. +-lft-identityN/A

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

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{0 + \sqrt{x}}\right), \color{blue}{\left(\mathsf{neg}\left(\frac{x}{\frac{-1}{2}}\right)\right)}\right) \]
    17. +-lft-identityN/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{\sqrt{x}}\right), \left(\mathsf{neg}\left(\frac{x}{\color{blue}{\frac{-1}{2}}}\right)\right)\right) \]
    18. pow1/2N/A

      \[\leadsto \mathsf{/.f64}\left(\left(\frac{1}{{x}^{\frac{1}{2}}}\right), \left(\mathsf{neg}\left(\frac{x}{\color{blue}{\frac{-1}{2}}}\right)\right)\right) \]
    19. pow-flipN/A

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

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

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(x, \frac{-1}{2}\right), \left(\mathsf{neg}\left(\color{blue}{\frac{x}{\frac{-1}{2}}}\right)\right)\right) \]
    22. distribute-neg-frac2N/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(x, \frac{-1}{2}\right), \left(\frac{x}{\color{blue}{\mathsf{neg}\left(\frac{-1}{2}\right)}}\right)\right) \]
    23. metadata-evalN/A

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(x, \frac{-1}{2}\right), \left(\frac{x}{\frac{1}{2}}\right)\right) \]
    24. /-lowering-/.f6499.0%

      \[\leadsto \mathsf{/.f64}\left(\mathsf{pow.f64}\left(x, \frac{-1}{2}\right), \mathsf{/.f64}\left(x, \color{blue}{\frac{1}{2}}\right)\right) \]
  12. Applied egg-rr99.0%

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

Alternative 8: 97.6% accurate, 2.0× speedup?

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

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

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Add Preprocessing
  3. Applied egg-rr39.6%

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

    \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{\frac{1}{2}}{x}\right)}, \mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, x\right), \frac{-1}{2}\right)\right) \]
  5. Step-by-step derivation
    1. /-lowering-/.f6499.0%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, x\right), \mathsf{pow.f64}\left(\color{blue}{\mathsf{+.f64}\left(1, x\right)}, \frac{-1}{2}\right)\right) \]
  6. Simplified99.0%

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

    \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, x\right), \mathsf{pow.f64}\left(\color{blue}{x}, \frac{-1}{2}\right)\right) \]
  8. Step-by-step derivation
    1. Simplified98.9%

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

    Alternative 9: 37.3% accurate, 2.0× speedup?

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

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

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

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{1}{x}\right)\right) \]
      2. /-lowering-/.f645.4%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(1, x\right)\right) \]
    5. Simplified5.4%

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

        \[\leadsto \sqrt{{x}^{-1}} \]
      2. sqrt-pow1N/A

        \[\leadsto {x}^{\color{blue}{\left(\frac{-1}{2}\right)}} \]
      3. metadata-evalN/A

        \[\leadsto {x}^{\frac{-1}{2}} \]
      4. metadata-evalN/A

        \[\leadsto {x}^{\left(\frac{1}{2} - \color{blue}{1}\right)} \]
      5. pow-divN/A

        \[\leadsto \frac{{x}^{\frac{1}{2}}}{\color{blue}{{x}^{1}}} \]
      6. pow1/2N/A

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

        \[\leadsto \frac{\sqrt{x}}{{x}^{\left(\frac{2}{\color{blue}{2}}\right)}} \]
      8. sqrt-pow1N/A

        \[\leadsto \frac{\sqrt{x}}{\sqrt{{x}^{2}}} \]
      9. pow2N/A

        \[\leadsto \frac{\sqrt{x}}{\sqrt{x \cdot x}} \]
      10. sqrt-undivN/A

        \[\leadsto \sqrt{\frac{x}{x \cdot x}} \]
      11. sqrt-lowering-sqrt.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\left(\frac{x}{x \cdot x}\right)\right) \]
      12. /-lowering-/.f64N/A

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(x, \left(x \cdot x\right)\right)\right) \]
      13. *-lowering-*.f6438.4%

        \[\leadsto \mathsf{sqrt.f64}\left(\mathsf{/.f64}\left(x, \mathsf{*.f64}\left(x, x\right)\right)\right) \]
    7. Applied egg-rr38.4%

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

    Alternative 10: 36.6% accurate, 19.0× speedup?

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

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Applied egg-rr39.6%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, x\right), x\right), \mathsf{+.f64}\left(x, \color{blue}{\left(x \cdot \left(1 + \frac{1}{2} \cdot \frac{1}{x}\right)\right)}\right)\right), \mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, x\right), \frac{-1}{2}\right)\right) \]
    5. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, x\right), x\right), \mathsf{+.f64}\left(x, \left(1 \cdot x + \left(\frac{1}{2} \cdot \frac{1}{x}\right) \cdot x\right)\right)\right), \mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, x\right), \frac{-1}{2}\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, x\right), x\right), \mathsf{+.f64}\left(x, \left(1 \cdot x + \frac{1}{2} \cdot \left(\frac{1}{x} \cdot x\right)\right)\right)\right), \mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, x\right), \frac{-1}{2}\right)\right) \]
      3. lft-mult-inverseN/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, x\right), x\right), \mathsf{+.f64}\left(x, \left(1 \cdot x + \frac{1}{2}\right)\right)\right), \mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, x\right), \frac{-1}{2}\right)\right) \]
      5. *-lft-identityN/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, x\right), x\right), \mathsf{+.f64}\left(x, \mathsf{+.f64}\left(x, \frac{1}{2}\right)\right)\right), \mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, x\right), \frac{-1}{2}\right)\right) \]
    6. Simplified39.3%

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(1, x\right), x\right), \mathsf{+.f64}\left(x, \mathsf{+.f64}\left(x, \frac{1}{2}\right)\right)\right), \color{blue}{1}\right) \]
    8. Step-by-step derivation
      1. Simplified37.6%

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

        \[\leadsto \frac{\left(x + 1\right) - x}{x + \left(x + 0.5\right)} \]
      3. Add Preprocessing

      Alternative 11: 38.1% accurate, 26.1× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 6.4 \cdot 10^{+153}:\\ \;\;\;\;\frac{0.5}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
      (FPCore (x) :precision binary64 (if (<= x 6.4e+153) (/ 0.5 x) 0.0))
      double code(double x) {
      	double tmp;
      	if (x <= 6.4e+153) {
      		tmp = 0.5 / x;
      	} else {
      		tmp = 0.0;
      	}
      	return tmp;
      }
      
      real(8) function code(x)
          real(8), intent (in) :: x
          real(8) :: tmp
          if (x <= 6.4d+153) then
              tmp = 0.5d0 / x
          else
              tmp = 0.0d0
          end if
          code = tmp
      end function
      
      public static double code(double x) {
      	double tmp;
      	if (x <= 6.4e+153) {
      		tmp = 0.5 / x;
      	} else {
      		tmp = 0.0;
      	}
      	return tmp;
      }
      
      def code(x):
      	tmp = 0
      	if x <= 6.4e+153:
      		tmp = 0.5 / x
      	else:
      		tmp = 0.0
      	return tmp
      
      function code(x)
      	tmp = 0.0
      	if (x <= 6.4e+153)
      		tmp = Float64(0.5 / x);
      	else
      		tmp = 0.0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(x)
      	tmp = 0.0;
      	if (x <= 6.4e+153)
      		tmp = 0.5 / x;
      	else
      		tmp = 0.0;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_] := If[LessEqual[x, 6.4e+153], N[(0.5 / x), $MachinePrecision], 0.0]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x \leq 6.4 \cdot 10^{+153}:\\
      \;\;\;\;\frac{0.5}{x}\\
      
      \mathbf{else}:\\
      \;\;\;\;0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < 6.4000000000000003e153

        1. Initial program 6.9%

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

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

          \[\leadsto \mathsf{*.f64}\left(\color{blue}{\left(\frac{\frac{1}{2}}{x}\right)}, \mathsf{pow.f64}\left(\mathsf{+.f64}\left(1, x\right), \frac{-1}{2}\right)\right) \]
        5. Step-by-step derivation
          1. /-lowering-/.f6498.0%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{/.f64}\left(\frac{1}{2}, x\right), \mathsf{pow.f64}\left(\color{blue}{\mathsf{+.f64}\left(1, x\right)}, \frac{-1}{2}\right)\right) \]
        6. Simplified98.0%

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

          \[\leadsto \color{blue}{\frac{\frac{1}{2}}{x}} \]
        8. Step-by-step derivation
          1. /-lowering-/.f648.2%

            \[\leadsto \mathsf{/.f64}\left(\frac{1}{2}, \color{blue}{x}\right) \]
        9. Simplified8.2%

          \[\leadsto \color{blue}{\frac{0.5}{x}} \]

        if 6.4000000000000003e153 < x

        1. Initial program 66.4%

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

          \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(1, \mathsf{sqrt.f64}\left(x\right)\right), \color{blue}{\left(\sqrt{\frac{1}{x}}\right)}\right) \]
        4. Step-by-step derivation
          1. sqrt-lowering-sqrt.f64N/A

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

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

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

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

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

            \[\leadsto 0 \]
        7. Applied egg-rr66.4%

          \[\leadsto \color{blue}{0} \]
      3. Recombined 2 regimes into one program.
      4. Add Preprocessing

      Alternative 12: 36.1% accurate, 209.0× speedup?

      \[\begin{array}{l} \\ 0 \end{array} \]
      (FPCore (x) :precision binary64 0.0)
      double code(double x) {
      	return 0.0;
      }
      
      real(8) function code(x)
          real(8), intent (in) :: x
          code = 0.0d0
      end function
      
      public static double code(double x) {
      	return 0.0;
      }
      
      def code(x):
      	return 0.0
      
      function code(x)
      	return 0.0
      end
      
      function tmp = code(x)
      	tmp = 0.0;
      end
      
      code[x_] := 0.0
      
      \begin{array}{l}
      
      \\
      0
      \end{array}
      
      Derivation
      1. Initial program 38.5%

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

        \[\leadsto \mathsf{\_.f64}\left(\mathsf{/.f64}\left(1, \mathsf{sqrt.f64}\left(x\right)\right), \color{blue}{\left(\sqrt{\frac{1}{x}}\right)}\right) \]
      4. Step-by-step derivation
        1. sqrt-lowering-sqrt.f64N/A

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

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

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

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

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

          \[\leadsto 0 \]
      7. Applied egg-rr37.3%

        \[\leadsto \color{blue}{0} \]
      8. Add Preprocessing

      Developer Target 1: 98.5% 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 2024140 
      (FPCore (x)
        :name "2isqrt (example 3.6)"
        :precision binary64
        :pre (and (> x 1.0) (< x 1e+308))
      
        :alt
        (! :herbie-platform default (/ 1 (+ (* (+ x 1) (sqrt x)) (* x (sqrt (+ x 1))))))
      
        (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))