2isqrt (example 3.6)

Percentage Accurate: 38.4% → 99.1%
Time: 23.6s
Alternatives: 6
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 6 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.4% 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.1% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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. *-commutative40.0%

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

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

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

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

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

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

      \[\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. *-inverses40.0%

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

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

    \[\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. /-rgt-identity40.0%

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

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

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

      \[\leadsto e^{\color{blue}{\log \left({\left(1 + x\right)}^{-0.5}\right) + \log \left(\frac{\sqrt{1 + x}}{\sqrt{x}} + -1\right)}} \]
    5. log-pow40.0%

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

      \[\leadsto e^{-0.5 \cdot \color{blue}{\mathsf{log1p}\left(x\right)} + \log \left(\frac{\sqrt{1 + x}}{\sqrt{x}} + -1\right)} \]
    7. sqrt-undiv40.0%

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

    \[\leadsto \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right) + \log \left(\sqrt{\frac{1 + x}{x}} + -1\right)}} \]
  9. Step-by-step derivation
    1. prod-exp40.0%

      \[\leadsto \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right)} \cdot e^{\log \left(\sqrt{\frac{1 + x}{x}} + -1\right)}} \]
    2. *-commutative40.0%

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

      \[\leadsto e^{\color{blue}{\log \left(1 + x\right)} \cdot -0.5} \cdot e^{\log \left(\sqrt{\frac{1 + x}{x}} + -1\right)} \]
    4. exp-to-pow40.0%

      \[\leadsto \color{blue}{{\left(1 + x\right)}^{-0.5}} \cdot e^{\log \left(\sqrt{\frac{1 + x}{x}} + -1\right)} \]
    5. rem-exp-log40.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 98.8% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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. *-commutative40.0%

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

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

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

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

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

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

      \[\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. *-inverses40.0%

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

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

    \[\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. /-rgt-identity40.0%

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

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

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

      \[\leadsto e^{\color{blue}{\log \left({\left(1 + x\right)}^{-0.5}\right) + \log \left(\frac{\sqrt{1 + x}}{\sqrt{x}} + -1\right)}} \]
    5. log-pow40.0%

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

      \[\leadsto e^{-0.5 \cdot \color{blue}{\mathsf{log1p}\left(x\right)} + \log \left(\frac{\sqrt{1 + x}}{\sqrt{x}} + -1\right)} \]
    7. sqrt-undiv40.0%

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

    \[\leadsto \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right) + \log \left(\sqrt{\frac{1 + x}{x}} + -1\right)}} \]
  9. Step-by-step derivation
    1. prod-exp40.0%

      \[\leadsto \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right)} \cdot e^{\log \left(\sqrt{\frac{1 + x}{x}} + -1\right)}} \]
    2. *-commutative40.0%

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

      \[\leadsto e^{\color{blue}{\log \left(1 + x\right)} \cdot -0.5} \cdot e^{\log \left(\sqrt{\frac{1 + x}{x}} + -1\right)} \]
    4. exp-to-pow40.0%

      \[\leadsto \color{blue}{{\left(1 + x\right)}^{-0.5}} \cdot e^{\log \left(\sqrt{\frac{1 + x}{x}} + -1\right)} \]
    5. rem-exp-log40.0%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto {\left(1 + x\right)}^{-0.5} \cdot \color{blue}{\left(0.5 \cdot \frac{1}{x} - 0.125 \cdot \frac{1}{{x}^{2}}\right)} \]
  15. Step-by-step derivation
    1. sub-neg98.7%

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

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

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

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

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

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

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

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

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

Alternative 3: 37.5% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.6 \cdot 10^{+153}:\\
\;\;\;\;\frac{1}{x + \sqrt{x}}\\

\mathbf{else}:\\
\;\;\;\;0\\


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

    1. Initial program 9.9%

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

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

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

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

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

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

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

        \[\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-sqrt10.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. +-commutative10.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. inv-pow10.1%

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

        \[\leadsto \left(\frac{1}{x} - \frac{1}{1 + x}\right) \cdot \frac{1}{\color{blue}{{x}^{\left(\frac{-1}{2}\right)}} + \frac{1}{\sqrt{x + 1}}} \]
      12. metadata-eval10.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. pow1/210.1%

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

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

        \[\leadsto \left(\frac{1}{x} - \frac{1}{1 + x}\right) \cdot \frac{1}{{x}^{-0.5} + {\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}} \]
      16. metadata-eval10.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-rr10.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-2neg10.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-eval10.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-sub13.0%

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

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

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

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

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

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

      \[\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. Taylor expanded in x around 0 8.2%

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

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

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

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

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

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

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

    if 4.6000000000000003e153 < x

    1. Initial program 67.8%

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

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification39.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.6 \cdot 10^{+153}:\\ \;\;\;\;\frac{1}{x + \sqrt{x}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 97.7% accurate, 1.9× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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. *-commutative40.0%

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

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

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

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

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

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

      \[\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. *-inverses40.0%

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

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

    \[\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. /-rgt-identity40.0%

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

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

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

      \[\leadsto e^{\color{blue}{\log \left({\left(1 + x\right)}^{-0.5}\right) + \log \left(\frac{\sqrt{1 + x}}{\sqrt{x}} + -1\right)}} \]
    5. log-pow40.0%

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

      \[\leadsto e^{-0.5 \cdot \color{blue}{\mathsf{log1p}\left(x\right)} + \log \left(\frac{\sqrt{1 + x}}{\sqrt{x}} + -1\right)} \]
    7. sqrt-undiv40.0%

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

    \[\leadsto \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right) + \log \left(\sqrt{\frac{1 + x}{x}} + -1\right)}} \]
  9. Step-by-step derivation
    1. prod-exp40.0%

      \[\leadsto \color{blue}{e^{-0.5 \cdot \mathsf{log1p}\left(x\right)} \cdot e^{\log \left(\sqrt{\frac{1 + x}{x}} + -1\right)}} \]
    2. *-commutative40.0%

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

      \[\leadsto e^{\color{blue}{\log \left(1 + x\right)} \cdot -0.5} \cdot e^{\log \left(\sqrt{\frac{1 + x}{x}} + -1\right)} \]
    4. exp-to-pow40.0%

      \[\leadsto \color{blue}{{\left(1 + x\right)}^{-0.5}} \cdot e^{\log \left(\sqrt{\frac{1 + x}{x}} + -1\right)} \]
    5. rem-exp-log40.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 37.5% accurate, 26.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.6 \cdot 10^{+153}:\\
\;\;\;\;\frac{1}{x}\\

\mathbf{else}:\\
\;\;\;\;0\\


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

    1. Initial program 9.9%

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

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

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

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

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

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

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

        \[\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-sqrt10.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. +-commutative10.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. inv-pow10.1%

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

        \[\leadsto \left(\frac{1}{x} - \frac{1}{1 + x}\right) \cdot \frac{1}{\color{blue}{{x}^{\left(\frac{-1}{2}\right)}} + \frac{1}{\sqrt{x + 1}}} \]
      12. metadata-eval10.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. pow1/210.1%

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

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

        \[\leadsto \left(\frac{1}{x} - \frac{1}{1 + x}\right) \cdot \frac{1}{{x}^{-0.5} + {\color{blue}{\left(1 + x\right)}}^{\left(-0.5\right)}} \]
      16. metadata-eval10.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-rr10.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 8.2%

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

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

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

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

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

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

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

    if 4.6000000000000003e153 < x

    1. Initial program 67.8%

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

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification39.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.6 \cdot 10^{+153}:\\ \;\;\;\;\frac{1}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 35.5% accurate, 209.0× speedup?

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

\\
0
\end{array}
Derivation
  1. Initial program 40.0%

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

    \[\leadsto \color{blue}{0} \]
  4. Final simplification37.4%

    \[\leadsto 0 \]
  5. 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 2024046 
(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)))))