\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+15}:\\
\;\;\;\;\frac{{\left(\mathsf{fma}\left(x, x, x\right)\right)}^{-0.5}}{\sqrt{1 + x} + \sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\]
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
↓
(FPCore (x)
:precision binary64
(if (<= x 5e+15)
(/ (pow (fma x x x) -0.5) (+ (sqrt (+ 1.0 x)) (sqrt x)))
(* 0.5 (pow x -1.5))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
↓
double code(double x) {
double tmp;
if (x <= 5e+15) {
tmp = pow(fma(x, x, x), -0.5) / (sqrt((1.0 + x)) + sqrt(x));
} else {
tmp = 0.5 * pow(x, -1.5);
}
return tmp;
}
function code(x)
return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0))))
end
↓
function code(x)
tmp = 0.0
if (x <= 5e+15)
tmp = Float64((fma(x, x, x) ^ -0.5) / Float64(sqrt(Float64(1.0 + x)) + sqrt(x)));
else
tmp = Float64(0.5 * (x ^ -1.5));
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_] := If[LessEqual[x, 5e+15], N[(N[Power[N[(x * x + x), $MachinePrecision], -0.5], $MachinePrecision] / N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Power[x, -1.5], $MachinePrecision]), $MachinePrecision]]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
↓
\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+15}:\\
\;\;\;\;\frac{{\left(\mathsf{fma}\left(x, x, x\right)\right)}^{-0.5}}{\sqrt{1 + x} + \sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.1 |
|---|
| Cost | 27588 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 10^{-5}:\\
\;\;\;\;\frac{\frac{1}{\left(0.5 + \left(x + \frac{0.0625}{x \cdot x}\right)\right) + \frac{-0.125}{x}}}{t_0 + \sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.2 |
|---|
| Cost | 27204 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{1}{\left(x + 0.5\right) + \frac{-0.125}{x}}}{t_0 + \sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.2 |
|---|
| Cost | 26948 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{1}{x + 0.5}}{t_0 + \sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.2 |
|---|
| Cost | 26948 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{-1}{t_0 + \sqrt{x}}}{-0.5 - x}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 0.3 |
|---|
| Cost | 26692 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{1 + x}} \leq 10^{-15}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 0.3 |
|---|
| Cost | 26304 |
|---|
\[\frac{\frac{-1}{\sqrt{1 + x} + \sqrt{x}}}{-\mathsf{hypot}\left(x, \sqrt{x}\right)}
\]
| Alternative 7 |
|---|
| Error | 0.2 |
|---|
| Cost | 20164 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 5 \cdot 10^{+15}:\\
\;\;\;\;\frac{\frac{1}{\sqrt{x + x \cdot x}}}{\sqrt{1 + x} + \sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 0.9 |
|---|
| Cost | 7044 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;{x}^{-0.5} - \left(1 + x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 2.0 |
|---|
| Cost | 6788 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.5:\\
\;\;\;\;{x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 1.1 |
|---|
| Cost | 6788 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;-1 + {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot {x}^{-1.5}\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 31.3 |
|---|
| Cost | 6528 |
|---|
\[{x}^{-0.5}
\]
| Alternative 12 |
|---|
| Error | 59.3 |
|---|
| Cost | 320 |
|---|
\[\frac{1}{x + 0.5}
\]
| Alternative 13 |
|---|
| Error | 59.3 |
|---|
| Cost | 192 |
|---|
\[\frac{1}{x}
\]
| Alternative 14 |
|---|
| Error | 62.8 |
|---|
| Cost | 64 |
|---|
\[-1
\]
| Alternative 15 |
|---|
| Error | 60.3 |
|---|
| Cost | 64 |
|---|
\[2
\]