\[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
\]
↓
\[\begin{array}{l}
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 2:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot -0.0859375 + 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 + \frac{-0.5}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}\\
\end{array}
\]
(FPCore (x)
:precision binary64
(- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))
↓
(FPCore (x)
:precision binary64
(if (<= (hypot 1.0 x) 2.0)
(* (* x x) (+ (* (* x x) -0.0859375) 0.125))
(/
(+ 0.5 (/ -0.5 (hypot 1.0 x)))
(+ 1.0 (sqrt (+ 0.5 (/ 0.5 (hypot 1.0 x))))))))double code(double x) {
return 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))));
}
↓
double code(double x) {
double tmp;
if (hypot(1.0, x) <= 2.0) {
tmp = (x * x) * (((x * x) * -0.0859375) + 0.125);
} else {
tmp = (0.5 + (-0.5 / hypot(1.0, x))) / (1.0 + sqrt((0.5 + (0.5 / hypot(1.0, x)))));
}
return tmp;
}
public static double code(double x) {
return 1.0 - Math.sqrt((0.5 * (1.0 + (1.0 / Math.hypot(1.0, x)))));
}
↓
public static double code(double x) {
double tmp;
if (Math.hypot(1.0, x) <= 2.0) {
tmp = (x * x) * (((x * x) * -0.0859375) + 0.125);
} else {
tmp = (0.5 + (-0.5 / Math.hypot(1.0, x))) / (1.0 + Math.sqrt((0.5 + (0.5 / Math.hypot(1.0, x)))));
}
return tmp;
}
def code(x):
return 1.0 - math.sqrt((0.5 * (1.0 + (1.0 / math.hypot(1.0, x)))))
↓
def code(x):
tmp = 0
if math.hypot(1.0, x) <= 2.0:
tmp = (x * x) * (((x * x) * -0.0859375) + 0.125)
else:
tmp = (0.5 + (-0.5 / math.hypot(1.0, x))) / (1.0 + math.sqrt((0.5 + (0.5 / math.hypot(1.0, x)))))
return tmp
function code(x)
return Float64(1.0 - sqrt(Float64(0.5 * Float64(1.0 + Float64(1.0 / hypot(1.0, x))))))
end
↓
function code(x)
tmp = 0.0
if (hypot(1.0, x) <= 2.0)
tmp = Float64(Float64(x * x) * Float64(Float64(Float64(x * x) * -0.0859375) + 0.125));
else
tmp = Float64(Float64(0.5 + Float64(-0.5 / hypot(1.0, x))) / Float64(1.0 + sqrt(Float64(0.5 + Float64(0.5 / hypot(1.0, x))))));
end
return tmp
end
function tmp = code(x)
tmp = 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))));
end
↓
function tmp_2 = code(x)
tmp = 0.0;
if (hypot(1.0, x) <= 2.0)
tmp = (x * x) * (((x * x) * -0.0859375) + 0.125);
else
tmp = (0.5 + (-0.5 / hypot(1.0, x))) / (1.0 + sqrt((0.5 + (0.5 / hypot(1.0, x)))));
end
tmp_2 = tmp;
end
code[x_] := N[(1.0 - N[Sqrt[N[(0.5 * N[(1.0 + N[(1.0 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
↓
code[x_] := If[LessEqual[N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision], 2.0], N[(N[(x * x), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * -0.0859375), $MachinePrecision] + 0.125), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 + N[(-0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Sqrt[N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
↓
\begin{array}{l}
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 2:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot -0.0859375 + 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 + \frac{-0.5}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Accuracy | 99.3% |
|---|
| Cost | 13444 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.0029:\\
\;\;\;\;1 - \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}\\
\mathbf{elif}\;x \leq 1.1:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot -0.0859375 + 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 + \frac{-0.5}{x}}{1 + \sqrt{0.5 + \frac{0.5}{x}}}\\
\end{array}
\]
| Alternative 2 |
|---|
| Accuracy | 99.1% |
|---|
| Cost | 7496 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.1:\\
\;\;\;\;\frac{0.5}{1 + \sqrt{0.5}}\\
\mathbf{elif}\;x \leq 1.1:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot -0.0859375 + 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 + \frac{-0.5}{x}}{1 + \sqrt{0.5 + \frac{0.5}{x}}}\\
\end{array}
\]
| Alternative 3 |
|---|
| Accuracy | 98.8% |
|---|
| Cost | 6985 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \lor \neg \left(x \leq 1.1\right):\\
\;\;\;\;\frac{0.5}{1 + \sqrt{0.5}}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot -0.0859375 + 0.125\right)\\
\end{array}
\]
| Alternative 4 |
|---|
| Accuracy | 98.0% |
|---|
| Cost | 6857 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \lor \neg \left(x \leq 1.1\right):\\
\;\;\;\;1 - \sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot -0.0859375 + 0.125\right)\\
\end{array}
\]
| Alternative 5 |
|---|
| Accuracy | 50.5% |
|---|
| Cost | 320 |
|---|
\[\left(x \cdot x\right) \cdot 0.125
\]
| Alternative 6 |
|---|
| Accuracy | 50.5% |
|---|
| Cost | 320 |
|---|
\[x \cdot \left(x \cdot 0.125\right)
\]