2isqrt (example 3.6)

Percentage Accurate: 38.5% → 99.6%
Time: 15.8s
Alternatives: 8
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 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}{x}}{1 + \sqrt{\frac{x + 1}{x}}} \cdot {\left(x + 1\right)}^{-0.5} \end{array} \]
(FPCore (x)
 :precision binary64
 (* (/ (/ 1.0 x) (+ 1.0 (sqrt (/ (+ x 1.0) x)))) (pow (+ x 1.0) -0.5)))
double code(double x) {
	return ((1.0 / x) / (1.0 + sqrt(((x + 1.0) / x)))) * pow((x + 1.0), -0.5);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = ((1.0d0 / x) / (1.0d0 + sqrt(((x + 1.0d0) / x)))) * ((x + 1.0d0) ** (-0.5d0))
end function
public static double code(double x) {
	return ((1.0 / x) / (1.0 + Math.sqrt(((x + 1.0) / x)))) * Math.pow((x + 1.0), -0.5);
}
def code(x):
	return ((1.0 / x) / (1.0 + math.sqrt(((x + 1.0) / x)))) * math.pow((x + 1.0), -0.5)
function code(x)
	return Float64(Float64(Float64(1.0 / x) / Float64(1.0 + sqrt(Float64(Float64(x + 1.0) / x)))) * (Float64(x + 1.0) ^ -0.5))
end
function tmp = code(x)
	tmp = ((1.0 / x) / (1.0 + sqrt(((x + 1.0) / x)))) * ((x + 1.0) ^ -0.5);
end
code[x_] := N[(N[(N[(1.0 / x), $MachinePrecision] / N[(1.0 + N[Sqrt[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

      \[\leadsto \color{blue}{\left(1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    3. *-un-lft-identity37.2%

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

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

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

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

      \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
    8. associate-*l/37.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\left(\frac{x + 1}{x} + -1\right) \cdot {\left(x + 1\right)}^{-0.5}}{\left(\sqrt{\frac{x + 1}{x}} + 1\right) \cdot 1}} \]
  9. Step-by-step derivation
    1. *-commutative37.3%

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

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

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

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

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

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

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

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

Alternative 2: 99.2% accurate, 1.7× speedup?

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

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

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

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

      \[\leadsto \color{blue}{\left(1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    3. *-un-lft-identity37.2%

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

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

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

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

      \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
    8. associate-*l/37.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\left(0.5 + \frac{0.0625}{{x}^{2}}\right) - \left(0.125 \cdot \frac{1}{x} + 0.0390625 \cdot \frac{1}{{x}^{3}}\right)}{x}} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
  8. Step-by-step derivation
    1. associate--r+99.2%

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

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

      \[\leadsto \frac{\color{blue}{\left(\frac{0.0625}{{x}^{2}} + \left(0.5 - 0.125 \cdot \frac{1}{x}\right)\right)} - 0.0390625 \cdot \frac{1}{{x}^{3}}}{x} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
    4. sub-neg99.2%

      \[\leadsto \frac{\left(\frac{0.0625}{{x}^{2}} + \color{blue}{\left(0.5 + \left(-0.125 \cdot \frac{1}{x}\right)\right)}\right) - 0.0390625 \cdot \frac{1}{{x}^{3}}}{x} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
    5. associate-*r/99.2%

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

      \[\leadsto \frac{\left(\frac{0.0625}{{x}^{2}} + \left(0.5 + \left(-\frac{\color{blue}{0.125}}{x}\right)\right)\right) - 0.0390625 \cdot \frac{1}{{x}^{3}}}{x} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
    7. distribute-neg-frac99.2%

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

      \[\leadsto \frac{\left(\frac{0.0625}{{x}^{2}} + \left(0.5 + \frac{\color{blue}{-0.125}}{x}\right)\right) - 0.0390625 \cdot \frac{1}{{x}^{3}}}{x} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
    9. associate-*r/99.2%

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

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

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

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

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

Alternative 3: 99.0% accurate, 1.8× speedup?

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

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

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

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

      \[\leadsto \color{blue}{\left(1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    3. *-un-lft-identity37.2%

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

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

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

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

      \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
    8. associate-*l/37.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\left(0.5 + \frac{0.0625}{{x}^{2}}\right) - \left(0.125 \cdot \frac{1}{x} + 0.0390625 \cdot \frac{1}{{x}^{3}}\right)}{x}} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
  8. Step-by-step derivation
    1. associate--r+99.2%

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

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

      \[\leadsto \frac{\color{blue}{\left(\frac{0.0625}{{x}^{2}} + \left(0.5 - 0.125 \cdot \frac{1}{x}\right)\right)} - 0.0390625 \cdot \frac{1}{{x}^{3}}}{x} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
    4. sub-neg99.2%

      \[\leadsto \frac{\left(\frac{0.0625}{{x}^{2}} + \color{blue}{\left(0.5 + \left(-0.125 \cdot \frac{1}{x}\right)\right)}\right) - 0.0390625 \cdot \frac{1}{{x}^{3}}}{x} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
    5. associate-*r/99.2%

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

      \[\leadsto \frac{\left(\frac{0.0625}{{x}^{2}} + \left(0.5 + \left(-\frac{\color{blue}{0.125}}{x}\right)\right)\right) - 0.0390625 \cdot \frac{1}{{x}^{3}}}{x} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
    7. distribute-neg-frac99.2%

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

      \[\leadsto \frac{\left(\frac{0.0625}{{x}^{2}} + \left(0.5 + \frac{\color{blue}{-0.125}}{x}\right)\right) - 0.0390625 \cdot \frac{1}{{x}^{3}}}{x} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
    9. associate-*r/99.2%

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

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

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

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

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

Alternative 4: 98.7% accurate, 1.9× speedup?

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

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

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

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

      \[\leadsto \color{blue}{\left(1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    3. *-un-lft-identity37.2%

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

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

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

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

      \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
    8. associate-*l/37.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 37.0% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.5 \cdot 10^{+122}:\\
\;\;\;\;{x}^{-0.5}\\

\mathbf{else}:\\
\;\;\;\;\frac{-0.0390625}{{x}^{4}}\\


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

    1. Initial program 12.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
    6. Step-by-step derivation
      1. rem-exp-log7.5%

        \[\leadsto \sqrt{\frac{1}{\color{blue}{e^{\log x}}}} \]
      2. exp-neg7.5%

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

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

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

        \[\leadsto e^{\color{blue}{-\log x \cdot 0.5}} \]
      6. distribute-rgt-neg-in7.5%

        \[\leadsto e^{\color{blue}{\log x \cdot \left(-0.5\right)}} \]
      7. metadata-eval7.5%

        \[\leadsto e^{\log x \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow7.5%

        \[\leadsto \color{blue}{{x}^{-0.5}} \]
    7. Simplified7.5%

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

    if 8.50000000000000003e122 < x

    1. Initial program 53.8%

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

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

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

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

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

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

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

        \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      8. associate-*l/53.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\left(0.5 + \frac{0.0625}{{x}^{2}}\right) - \left(0.125 \cdot \frac{1}{x} + 0.0390625 \cdot \frac{1}{{x}^{3}}\right)}{x}} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
    8. Step-by-step derivation
      1. associate--r+99.7%

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

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

        \[\leadsto \frac{\color{blue}{\left(\frac{0.0625}{{x}^{2}} + \left(0.5 - 0.125 \cdot \frac{1}{x}\right)\right)} - 0.0390625 \cdot \frac{1}{{x}^{3}}}{x} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
      4. sub-neg99.7%

        \[\leadsto \frac{\left(\frac{0.0625}{{x}^{2}} + \color{blue}{\left(0.5 + \left(-0.125 \cdot \frac{1}{x}\right)\right)}\right) - 0.0390625 \cdot \frac{1}{{x}^{3}}}{x} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
      5. associate-*r/99.7%

        \[\leadsto \frac{\left(\frac{0.0625}{{x}^{2}} + \left(0.5 + \left(-\color{blue}{\frac{0.125 \cdot 1}{x}}\right)\right)\right) - 0.0390625 \cdot \frac{1}{{x}^{3}}}{x} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
      6. metadata-eval99.7%

        \[\leadsto \frac{\left(\frac{0.0625}{{x}^{2}} + \left(0.5 + \left(-\frac{\color{blue}{0.125}}{x}\right)\right)\right) - 0.0390625 \cdot \frac{1}{{x}^{3}}}{x} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
      7. distribute-neg-frac99.7%

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

        \[\leadsto \frac{\left(\frac{0.0625}{{x}^{2}} + \left(0.5 + \frac{\color{blue}{-0.125}}{x}\right)\right) - 0.0390625 \cdot \frac{1}{{x}^{3}}}{x} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
      9. associate-*r/99.7%

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

        \[\leadsto \frac{\left(\frac{0.0625}{{x}^{2}} + \left(0.5 + \frac{-0.125}{x}\right)\right) - \frac{\color{blue}{0.0390625}}{{x}^{3}}}{x} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
    9. Simplified99.7%

      \[\leadsto \color{blue}{\frac{\left(\frac{0.0625}{{x}^{2}} + \left(0.5 + \frac{-0.125}{x}\right)\right) - \frac{0.0390625}{{x}^{3}}}{x}} \cdot \frac{{\left(1 + x\right)}^{-0.5}}{1} \]
    10. Taylor expanded in x around 0 53.8%

      \[\leadsto \color{blue}{\frac{-0.0390625}{{x}^{4}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification35.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 8.5 \cdot 10^{+122}:\\ \;\;\;\;{x}^{-0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.0390625}{{x}^{4}}\\ \end{array} \]
  5. 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 37.1%

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

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

      \[\leadsto \color{blue}{\left(1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1\right) \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    3. *-un-lft-identity37.2%

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

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

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

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

      \[\leadsto \left(\sqrt{1 + x} - \sqrt{x}\right) \cdot \color{blue}{\left(\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
    8. associate-*l/37.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 97.7% accurate, 2.0× speedup?

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

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

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

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

    \[\leadsto \color{blue}{\frac{\left(0.125 \cdot \sqrt{\frac{1}{{x}^{3}}} + 0.5 \cdot \sqrt{\frac{1}{x}}\right) - 0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}}{x}} \]
  5. Step-by-step derivation
    1. Simplified98.6%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(0.125, {x}^{-1.5}, 0.5 \cdot \left({x}^{-0.5} - {x}^{-1.5}\right)\right)}{x}} \]
    2. Taylor expanded in x around inf 97.4%

      \[\leadsto \frac{\color{blue}{0.5 \cdot \sqrt{\frac{1}{x}}}}{x} \]
    3. Final simplification97.4%

      \[\leadsto \frac{0.5 \cdot \sqrt{\frac{1}{x}}}{x} \]
    4. Add Preprocessing

    Alternative 8: 5.6% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
    6. Step-by-step derivation
      1. rem-exp-log5.7%

        \[\leadsto \sqrt{\frac{1}{\color{blue}{e^{\log x}}}} \]
      2. exp-neg5.7%

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

        \[\leadsto \color{blue}{{\left(e^{-\log x}\right)}^{0.5}} \]
      4. exp-prod5.7%

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

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

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

        \[\leadsto e^{\log x \cdot \color{blue}{-0.5}} \]
      8. exp-to-pow5.7%

        \[\leadsto \color{blue}{{x}^{-0.5}} \]
    7. Simplified5.7%

      \[\leadsto \color{blue}{{x}^{-0.5}} \]
    8. Final simplification5.7%

      \[\leadsto {x}^{-0.5} \]
    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 2024074 
    (FPCore (x)
      :name "2isqrt (example 3.6)"
      :precision binary64
      :pre (and (> x 1.0) (< x 1e+308))
    
      :alt
      (/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))
    
      (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))