2isqrt (example 3.6)

Percentage Accurate: 38.5% → 99.6%
Time: 16.4s
Alternatives: 8
Speedup: 1.9×

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}} \]
    2. div-inv33.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{-1 + \left(\left(-x\right) - \color{blue}{-1 \cdot x}\right)}{x}}{-1 + \left(-x\right)} \cdot \frac{1}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}} \]
    4. neg-mul-181.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.6% accurate, 1.0× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}} \]
    2. div-inv33.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{-1 + \left(\left(-x\right) - \color{blue}{-1 \cdot x}\right)}{x}}{-1 + \left(-x\right)} \cdot \frac{1}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}} \]
    4. neg-mul-181.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 97.7% accurate, 1.8× speedup?

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

\\
\frac{\frac{-1}{-1 - x}}{x \cdot \left(2 \cdot \sqrt{\frac{1}{x}}\right)}
\end{array}
Derivation
  1. Initial program 33.0%

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}} \]
    2. div-inv33.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{-1 + \left(\left(-x\right) - \color{blue}{-1 \cdot x}\right)}{x}}{-1 + \left(-x\right)} \cdot \frac{1}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}} \]
    4. neg-mul-181.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\frac{-1}{-1 - x}}{\color{blue}{\left(2 \cdot \sqrt{\frac{1}{x}}\right)} \cdot x} \]
  12. Final simplification98.8%

    \[\leadsto \frac{\frac{-1}{-1 - x}}{x \cdot \left(2 \cdot \sqrt{\frac{1}{x}}\right)} \]
  13. Add Preprocessing

Alternative 4: 97.7% accurate, 1.9× speedup?

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

\\
\frac{\frac{-1}{-1 - x}}{\sqrt{x} \cdot 2}
\end{array}
Derivation
  1. Initial program 33.0%

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}} \]
    2. div-inv33.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\frac{-1 + \left(\left(-x\right) - \color{blue}{-1 \cdot x}\right)}{x}}{-1 + \left(-x\right)} \cdot \frac{1}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}} \]
    4. neg-mul-181.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\frac{-1}{-1 - x}}{\color{blue}{2 \cdot \sqrt{x}}} \]
  12. Final simplification98.7%

    \[\leadsto \frac{\frac{-1}{-1 - x}}{\sqrt{x} \cdot 2} \]
  13. Add Preprocessing

Alternative 5: 37.7% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 7.9% accurate, 2.0× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}} \]
    2. div-inv33.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{x + {x}^{\color{blue}{0.5}}} \]
    5. pow1/27.8%

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

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

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

    \[\leadsto \frac{1}{x + \sqrt{x}} \]
  9. Add Preprocessing

Alternative 7: 3.2% accurate, 2.0× speedup?

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\sqrt{x}} - \left(e^{\mathsf{log1p}\left({\color{blue}{\left(1 + x\right)}}^{\left(\frac{-1}{2}\right)}\right)} - 1\right) \]
    6. metadata-eval6.0%

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

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

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \sqrt{\frac{1}{x}}} \]
  8. Step-by-step derivation
    1. mul-1-neg3.1%

      \[\leadsto \color{blue}{-\sqrt{\frac{1}{x}}} \]
    2. rem-exp-log3.1%

      \[\leadsto -\sqrt{\frac{1}{\color{blue}{e^{\log x}}}} \]
    3. exp-neg3.1%

      \[\leadsto -\sqrt{\color{blue}{e^{-\log x}}} \]
    4. unpow1/23.1%

      \[\leadsto -\color{blue}{{\left(e^{-\log x}\right)}^{0.5}} \]
    5. exp-prod3.1%

      \[\leadsto -\color{blue}{e^{\left(-\log x\right) \cdot 0.5}} \]
    6. distribute-lft-neg-out3.1%

      \[\leadsto -e^{\color{blue}{-\log x \cdot 0.5}} \]
    7. distribute-rgt-neg-in3.1%

      \[\leadsto -e^{\color{blue}{\log x \cdot \left(-0.5\right)}} \]
    8. metadata-eval3.1%

      \[\leadsto -e^{\log x \cdot \color{blue}{-0.5}} \]
    9. exp-to-pow3.1%

      \[\leadsto -\color{blue}{{x}^{-0.5}} \]
  9. Simplified3.1%

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

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

Alternative 8: 5.7% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(-{\left(\sqrt[3]{\sqrt{1 + x}}\right)}^{-1}, {\left(\sqrt[3]{1 + x}\right)}^{-1}, {\left(\sqrt[3]{\sqrt{1 + x}}\right)}^{-1} \cdot {\left(\sqrt[3]{1 + x}\right)}^{-1}\right) + \color{blue}{\left(1 \cdot {x}^{-0.5} + \left(-{\left(\sqrt[3]{\sqrt{1 + x}}\right)}^{-1} \cdot {\left(\sqrt[3]{1 + x}\right)}^{-1}\right)\right)} \]
    3. *-lft-identity6.2%

      \[\leadsto \mathsf{fma}\left(-{\left(\sqrt[3]{\sqrt{1 + x}}\right)}^{-1}, {\left(\sqrt[3]{1 + x}\right)}^{-1}, {\left(\sqrt[3]{\sqrt{1 + x}}\right)}^{-1} \cdot {\left(\sqrt[3]{1 + x}\right)}^{-1}\right) + \left(\color{blue}{{x}^{-0.5}} + \left(-{\left(\sqrt[3]{\sqrt{1 + x}}\right)}^{-1} \cdot {\left(\sqrt[3]{1 + x}\right)}^{-1}\right)\right) \]
  6. Simplified15.4%

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

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

    \[\leadsto \sqrt{\frac{1}{x}} \]
  9. Add Preprocessing

Developer target: 98.4% accurate, 1.0× speedup?

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

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

Reproduce

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

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

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