\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\]
↓
\[\frac{\frac{-1}{x \cdot \left({\left(x + 1\right)}^{-0.5} + {x}^{-0.5}\right)}}{-1 - x}
\]
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
↓
(FPCore (x)
:precision binary64
(/ (/ -1.0 (* x (+ (pow (+ x 1.0) -0.5) (pow x -0.5)))) (- -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 / (x * (pow((x + 1.0), -0.5) + pow(x, -0.5)))) / (-1.0 - x);
}
real(8) function code(x)
real(8), intent (in) :: x
code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
↓
real(8) function code(x)
real(8), intent (in) :: x
code = ((-1.0d0) / (x * (((x + 1.0d0) ** (-0.5d0)) + (x ** (-0.5d0))))) / ((-1.0d0) - x)
end function
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 / (x * (Math.pow((x + 1.0), -0.5) + Math.pow(x, -0.5)))) / (-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 / (x * (math.pow((x + 1.0), -0.5) + math.pow(x, -0.5)))) / (-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 / Float64(x * Float64((Float64(x + 1.0) ^ -0.5) + (x ^ -0.5)))) / 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 / (x * (((x + 1.0) ^ -0.5) + (x ^ -0.5)))) / (-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[(x * N[(N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision] + N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
↓
\frac{\frac{-1}{x \cdot \left({\left(x + 1\right)}^{-0.5} + {x}^{-0.5}\right)}}{-1 - x}
Alternatives
| Alternative 1 |
|---|
| Error | 0.65% |
|---|
| Cost | 27204 |
|---|
\[\begin{array}{l}
t_0 := \sqrt{x + 1}\\
t_1 := \frac{-1}{t_0}\\
\mathbf{if}\;\frac{1}{\sqrt{x}} + t_1 \leq 10^{-12}:\\
\;\;\;\;\frac{\left(1 + \left(x - x\right)\right) \cdot \frac{1}{x}}{\sqrt{x} + t_0}\\
\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} + t_1\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.66% |
|---|
| Cost | 13760 |
|---|
\[\frac{\frac{-1}{x}}{\left({\left(x + 1\right)}^{-0.5} + {x}^{-0.5}\right) \cdot \left(-1 - x\right)}
\]
| Alternative 3 |
|---|
| Error | 8.53% |
|---|
| Cost | 13444 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 38000000:\\
\;\;\;\;{x}^{-0.5} + \frac{-1}{\sqrt{x + 1}}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{x} \cdot 0.5\right) \cdot \frac{\frac{1 + \left(x - x\right)}{x}}{x + 1}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 8.53% |
|---|
| Cost | 13380 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 47000000:\\
\;\;\;\;{x}^{-0.5} - {\left(x + 1\right)}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{x} \cdot 0.5\right) \cdot \frac{\frac{1 + \left(x - x\right)}{x}}{x + 1}\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 9.41% |
|---|
| Cost | 7492 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 1.2:\\
\;\;\;\;{x}^{-0.5} - \frac{1}{1 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{x} \cdot 0.5\right) \cdot \frac{\frac{1 + \left(x - x\right)}{x}}{x + 1}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 10.09% |
|---|
| Cost | 7236 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 1.2:\\
\;\;\;\;{x}^{-0.5} - \frac{1}{1 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{x} \cdot 0.5\right) \cdot \frac{-1}{x \cdot \left(-1 - x\right)}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 10.15% |
|---|
| Cost | 7172 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 1.7:\\
\;\;\;\;{x}^{-0.5} - \frac{1}{1 + x \cdot 0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{x} \cdot 0.5\right) \cdot \frac{1}{x \cdot x}\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 10.17% |
|---|
| Cost | 7108 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;{x}^{-0.5} - \left(1 + x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{x} \cdot 0.5\right) \cdot \frac{1}{x \cdot x}\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 31.22% |
|---|
| Cost | 7044 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 2:\\
\;\;\;\;{x}^{-0.5} - \left(1 + x \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;{\left(x \cdot x\right)}^{-0.25}\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 45.92% |
|---|
| Cost | 6788 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.6:\\
\;\;\;\;-1 + {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + \left(x - x\right)\right) \cdot \left(\frac{1}{x} + \frac{-0.5}{x \cdot x}\right)\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 31.53% |
|---|
| Cost | 6788 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.8:\\
\;\;\;\;-1 + {x}^{-0.5}\\
\mathbf{else}:\\
\;\;\;\;{\left(x \cdot x\right)}^{-0.25}\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 48.53% |
|---|
| Cost | 6528 |
|---|
\[{x}^{-0.5}
\]
| Alternative 13 |
|---|
| Error | 92.6% |
|---|
| Cost | 704 |
|---|
\[\left(1 + \left(x - x\right)\right) \cdot \frac{1}{x + 0.5}
\]
| Alternative 14 |
|---|
| Error | 92.62% |
|---|
| Cost | 576 |
|---|
\[\left(1 + \left(x - x\right)\right) \cdot \frac{1}{x}
\]