\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\]
↓
\[\begin{array}{l}
t_0 := \sqrt{1 + x} + \sqrt{x}\\
\mathbf{if}\;x \leq 2 \cdot 10^{+63}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(x, x, x\right)}}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{t_0}}{-0.5 - x}\\
\end{array}
\]
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
↓
(FPCore (x)
:precision binary64
(let* ((t_0 (+ (sqrt (+ 1.0 x)) (sqrt x))))
(if (<= x 2e+63)
(/ (sqrt (/ 1.0 (fma x x x))) t_0)
(/ (/ -1.0 t_0) (- -0.5 x)))))double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
↓
double code(double x) {
double t_0 = sqrt((1.0 + x)) + sqrt(x);
double tmp;
if (x <= 2e+63) {
tmp = sqrt((1.0 / fma(x, x, x))) / t_0;
} else {
tmp = (-1.0 / t_0) / (-0.5 - x);
}
return tmp;
}
function code(x)
return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0))))
end
↓
function code(x)
t_0 = Float64(sqrt(Float64(1.0 + x)) + sqrt(x))
tmp = 0.0
if (x <= 2e+63)
tmp = Float64(sqrt(Float64(1.0 / fma(x, x, x))) / t_0);
else
tmp = Float64(Float64(-1.0 / t_0) / Float64(-0.5 - x));
end
return tmp
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]
↓
code[x_] := Block[{t$95$0 = N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2e+63], N[(N[Sqrt[N[(1.0 / N[(x * x + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(-1.0 / t$95$0), $MachinePrecision] / N[(-0.5 - x), $MachinePrecision]), $MachinePrecision]]]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
↓
\begin{array}{l}
t_0 := \sqrt{1 + x} + \sqrt{x}\\
\mathbf{if}\;x \leq 2 \cdot 10^{+63}:\\
\;\;\;\;\frac{\sqrt{\frac{1}{\mathsf{fma}\left(x, x, x\right)}}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{t_0}}{-0.5 - x}\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.34% |
|---|
| Cost | 26948 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{t_0} \leq 10^{-9}:\\
\;\;\;\;\frac{\frac{1}{x + 0.5}}{t_0 + \sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.67% |
|---|
| Cost | 26820 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{t_0} \leq 10^{-12}:\\
\;\;\;\;\frac{\frac{1}{x}}{t_0 + \sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 7.75% |
|---|
| Cost | 26692 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{1 + x}} \leq 10^{-12}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{1 + x}}{2 \cdot \sqrt{\frac{1}{x}}}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.41% |
|---|
| Cost | 26304 |
|---|
\[\frac{\frac{-1}{\sqrt{1 + x} + \sqrt{x}}}{-\mathsf{hypot}\left(x, \sqrt{x}\right)}
\]
| Alternative 5 |
|---|
| Error | 1.03% |
|---|
| Cost | 26240 |
|---|
\[\frac{1}{\left(\sqrt{1 + x} + \sqrt{x}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)}
\]
| Alternative 6 |
|---|
| Error | 0.41% |
|---|
| Cost | 20164 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{1 + x} + \sqrt{x}\\
\mathbf{if}\;x \leq 2 \cdot 10^{+63}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x + x \cdot x}}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{t_0}}{-0.5 - x}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 0.58% |
|---|
| Cost | 13892 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 2 \cdot 10^{+30}:\\
\;\;\;\;\frac{\frac{1}{x + x \cdot x}}{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-1}{\sqrt{1 + x} + \sqrt{x}}}{-0.5 - x}\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 8.59% |
|---|
| Cost | 7364 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{\frac{1}{x}}{1 + x}}{2 \cdot \sqrt{\frac{1}{x}}}\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 30.79% |
|---|
| Cost | 7236 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{x} \cdot \left(\frac{0.5}{-1 - x} + \frac{0.5}{x}\right)\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 9.44% |
|---|
| Cost | 7236 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x \cdot x}}{2 \cdot \sqrt{\frac{1}{x}}}\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 30.72% |
|---|
| Cost | 7044 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(x + {x}^{0.5}\right)}\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 32.57% |
|---|
| Cost | 6848 |
|---|
\[\frac{1}{\sqrt{x + x \cdot x}}
\]
| Alternative 13 |
|---|
| Error | 46.05% |
|---|
| Cost | 6788 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.65:\\
\;\;\;\;-1 + {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + 0.5}\\
\end{array}
\]
| Alternative 14 |
|---|
| Error | 33.04% |
|---|
| Cost | 6784 |
|---|
\[1 + \left(-1 + {x}^{-0.5}\right)
\]
| Alternative 15 |
|---|
| Error | 48.58% |
|---|
| Cost | 6528 |
|---|
\[{x}^{-0.5}
\]
| Alternative 16 |
|---|
| Error | 92.59% |
|---|
| Cost | 320 |
|---|
\[\frac{1}{x + 0.5}
\]
| Alternative 17 |
|---|
| Error | 98.08% |
|---|
| Cost | 64 |
|---|
\[-1
\]
| Alternative 18 |
|---|
| Error | 94.21% |
|---|
| Cost | 64 |
|---|
\[2
\]