\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\]
↓
\[\frac{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}}{\sqrt{x} + \sqrt{1 + x}}
\]
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
↓
(FPCore (x)
:precision binary64
(/ (/ 1.0 (hypot x (sqrt x))) (+ (sqrt x) (sqrt (+ 1.0 x)))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
↓
double code(double x) {
return (1.0 / hypot(x, sqrt(x))) / (sqrt(x) + sqrt((1.0 + x)));
}
public static double code(double x) {
return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
↓
public static double code(double x) {
return (1.0 / Math.hypot(x, Math.sqrt(x))) / (Math.sqrt(x) + Math.sqrt((1.0 + x)));
}
def code(x):
return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
↓
def code(x):
return (1.0 / math.hypot(x, math.sqrt(x))) / (math.sqrt(x) + math.sqrt((1.0 + x)))
function code(x)
return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0))))
end
↓
function code(x)
return Float64(Float64(1.0 / hypot(x, sqrt(x))) / Float64(sqrt(x) + sqrt(Float64(1.0 + x))))
end
function tmp = code(x)
tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
end
↓
function tmp = code(x)
tmp = (1.0 / hypot(x, sqrt(x))) / (sqrt(x) + sqrt((1.0 + x)));
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_] := N[(N[(1.0 / N[Sqrt[x ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
↓
\frac{\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right)}}{\sqrt{x} + \sqrt{1 + x}}
Alternatives
| Alternative 1 |
|---|
| Error | 1.08% |
|---|
| Cost | 26948 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{1 + x}\\
t_1 := \frac{-1}{t_0}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + t_1 \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{1}{\left(\sqrt{x} + t_0\right) \cdot \left(x + 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} + t_1\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.68% |
|---|
| Cost | 26820 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{1 + x}\\
t_1 := \frac{-1}{t_0}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + t_1 \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{\frac{1}{x}}{\sqrt{x} + t_0}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} + t_1\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.7% |
|---|
| Cost | 26756 |
|---|
\[\begin{array}{l}
t_0 := \frac{-1}{\sqrt{1 + x}}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + t_0 \leq 5 \cdot 10^{-13}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{\sqrt{x} \cdot 0.5}{1 + x}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} + t_0\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.61% |
|---|
| Cost | 13760 |
|---|
\[\frac{\frac{1}{x}}{\left(1 + x\right) \cdot \left({x}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)}
\]
| Alternative 5 |
|---|
| Error | 0.69% |
|---|
| Cost | 13380 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 60000000:\\
\;\;\;\;{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{\sqrt{x} \cdot 0.5}{1 + x}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 1.55% |
|---|
| Cost | 7236 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;{x}^{-0.5} + \left(-1 + x \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} \cdot \frac{\sqrt{x} \cdot 0.5}{1 + x}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 31.24% |
|---|
| Cost | 7172 |
|---|
\[\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}}{1 + {x}^{-0.5}}\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 32.11% |
|---|
| Cost | 6916 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 4.6 \cdot 10^{+153}:\\
\;\;\;\;\frac{1}{x + \sqrt{x}}\\
\mathbf{else}:\\
\;\;\;\;-1 + \left(1 - {x}^{-0.5}\right)\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 47.35% |
|---|
| Cost | 6788 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.58:\\
\;\;\;\;{x}^{-0.5} + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x + 0.5}\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 47.91% |
|---|
| Cost | 6720 |
|---|
\[\frac{1}{x + \sqrt{x}}
\]
| Alternative 11 |
|---|
| Error | 92.57% |
|---|
| Cost | 320 |
|---|
\[\frac{1}{x + 0.5}
\]
| Alternative 12 |
|---|
| Error | 98.06% |
|---|
| Cost | 64 |
|---|
\[-1
\]
| Alternative 13 |
|---|
| Error | 94.23% |
|---|
| Cost | 64 |
|---|
\[2
\]