\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\]
↓
\[\frac{-1}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \cdot \frac{-1}{\sqrt{x} + \mathsf{hypot}\left(1, \sqrt{x}\right)}
\]
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
↓
(FPCore (x)
:precision binary64
(* (/ -1.0 (hypot x (sqrt x))) (/ -1.0 (+ (sqrt x) (hypot 1.0 (sqrt 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))) * (-1.0 / (sqrt(x) + hypot(1.0, sqrt(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))) * (-1.0 / (Math.sqrt(x) + Math.hypot(1.0, Math.sqrt(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))) * (-1.0 / (math.sqrt(x) + math.hypot(1.0, math.sqrt(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(-1.0 / Float64(sqrt(x) + hypot(1.0, sqrt(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))) * (-1.0 / (sqrt(x) + hypot(1.0, sqrt(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[(-1.0 / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[1.0 ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
↓
\frac{-1}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \cdot \frac{-1}{\sqrt{x} + \mathsf{hypot}\left(1, \sqrt{x}\right)}
Alternatives
| Alternative 1 |
|---|
| Error | 0.2 |
|---|
| Cost | 27076 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{x + 1}} \leq 4 \cdot 10^{-8}:\\
\;\;\;\;\frac{\frac{1}{x}}{\sqrt{\frac{1}{x}} \cdot 1.5 + \sqrt{x} \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.3 |
|---|
| Cost | 26948 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{x + 1}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{t_0} \leq 10^{-11}:\\
\;\;\;\;\frac{\frac{1}{x + 0.5}}{\sqrt{x} + t_0}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.4 |
|---|
| Cost | 26692 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{x + 1}} \leq 10^{-13}:\\
\;\;\;\;\frac{{x}^{-0.5}}{x \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.4 |
|---|
| Cost | 13696 |
|---|
\[\frac{\frac{1}{x}}{\left(x + 1\right) \cdot {x}^{-0.5} + \sqrt{x + 1}}
\]
| Alternative 5 |
|---|
| Error | 1.0 |
|---|
| Cost | 7364 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;-1 + \left({x}^{-0.5} + x \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{\left(x + 1\right) \cdot \left(\sqrt{\frac{1}{x}} \cdot 2\right)}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 1.0 |
|---|
| Cost | 7044 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;-1 + \left({x}^{-0.5} + x \cdot 0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{-0.5}}{x \cdot 2}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 1.2 |
|---|
| Cost | 6916 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;-1 + {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{{x}^{-0.5}}{x \cdot 2}\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 30.3 |
|---|
| Cost | 6788 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.6:\\
\;\;\;\;-1 + {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x} - \frac{0.5}{x \cdot x}\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 1.6 |
|---|
| Cost | 6788 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;-1 + {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{{x}^{1.5}}\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 31.9 |
|---|
| Cost | 6528 |
|---|
\[{x}^{-0.5}
\]
| Alternative 11 |
|---|
| Error | 59.2 |
|---|
| Cost | 320 |
|---|
\[\frac{1}{x + 0.5}
\]
| Alternative 12 |
|---|
| Error | 59.3 |
|---|
| Cost | 192 |
|---|
\[\frac{1}{x}
\]
| Alternative 13 |
|---|
| Error | 62.8 |
|---|
| Cost | 64 |
|---|
\[-1
\]