\[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:\\
\;\;\;\;0.125 \cdot {x}^{2} + \left(0.0673828125 \cdot {x}^{6} + -0.0859375 \cdot {x}^{4}\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)
(+
(* 0.125 (pow x 2.0))
(+ (* 0.0673828125 (pow x 6.0)) (* -0.0859375 (pow x 4.0))))
(/
(+ 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 = (0.125 * pow(x, 2.0)) + ((0.0673828125 * pow(x, 6.0)) + (-0.0859375 * pow(x, 4.0)));
} 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 = (0.125 * Math.pow(x, 2.0)) + ((0.0673828125 * Math.pow(x, 6.0)) + (-0.0859375 * Math.pow(x, 4.0)));
} 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 = (0.125 * math.pow(x, 2.0)) + ((0.0673828125 * math.pow(x, 6.0)) + (-0.0859375 * math.pow(x, 4.0)))
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(0.125 * (x ^ 2.0)) + Float64(Float64(0.0673828125 * (x ^ 6.0)) + Float64(-0.0859375 * (x ^ 4.0))));
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 = (0.125 * (x ^ 2.0)) + ((0.0673828125 * (x ^ 6.0)) + (-0.0859375 * (x ^ 4.0)));
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[(0.125 * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.0673828125 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(-0.0859375 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $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:\\
\;\;\;\;0.125 \cdot {x}^{2} + \left(0.0673828125 \cdot {x}^{6} + -0.0859375 \cdot {x}^{4}\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 |
|---|
| Error | 0.3 |
|---|
| Cost | 20360 |
|---|
\[\begin{array}{l}
t_0 := 0.5 + \frac{0.5}{x}\\
t_1 := 0.5 + \frac{-0.5}{x}\\
\mathbf{if}\;x \leq -1.2:\\
\;\;\;\;\frac{t_0}{\frac{1}{t_1} \cdot \left(t_1 \cdot \left(1 + \sqrt{t_1}\right)\right)}\\
\mathbf{elif}\;x \leq 1.2:\\
\;\;\;\;0.125 \cdot {x}^{2} + \left(0.0673828125 \cdot {x}^{6} + -0.0859375 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{1 + \sqrt{t_0}}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.4 |
|---|
| Cost | 13576 |
|---|
\[\begin{array}{l}
t_0 := 0.5 + \frac{0.5}{x}\\
t_1 := 0.5 + \frac{-0.5}{x}\\
\mathbf{if}\;x \leq -1.1:\\
\;\;\;\;\frac{t_0}{\frac{1}{t_1} \cdot \left(t_1 \cdot \left(1 + \sqrt{t_1}\right)\right)}\\
\mathbf{elif}\;x \leq 1.12:\\
\;\;\;\;\mathsf{fma}\left(0.125, x \cdot x, -0.0859375 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{1 + \sqrt{t_0}}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.5 |
|---|
| Cost | 8260 |
|---|
\[\begin{array}{l}
t_0 := 0.5 + \frac{0.5}{x}\\
t_1 := 0.5 + \frac{-0.5}{x}\\
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;\frac{t_0}{\frac{1}{t_1} \cdot \left(t_1 \cdot \left(1 + \sqrt{t_1}\right)\right)}\\
\mathbf{elif}\;x \leq 1.22:\\
\;\;\;\;0.125 \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{1 + \sqrt{t_0}}\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.5 |
|---|
| Cost | 7496 |
|---|
\[\begin{array}{l}
t_0 := 0.5 + \frac{0.5}{x}\\
t_1 := 0.5 + \frac{-0.5}{x}\\
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;\frac{t_0}{1 + \sqrt{t_1}}\\
\mathbf{elif}\;x \leq 1.22:\\
\;\;\;\;0.125 \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1}{1 + \sqrt{t_0}}\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 0.8 |
|---|
| Cost | 7364 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;\frac{0.5 + \frac{0.5}{x}}{1 + \sqrt{0.5 + \frac{-0.5}{x}}}\\
\mathbf{elif}\;x \leq 1.55:\\
\;\;\;\;0.125 \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{1 + \sqrt{0.5}}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 1.0 |
|---|
| Cost | 6985 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \lor \neg \left(x \leq 1.55\right):\\
\;\;\;\;\frac{0.5}{1 + \sqrt{0.5}}\\
\mathbf{else}:\\
\;\;\;\;0.125 \cdot \left(x \cdot x\right)\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 1.0 |
|---|
| Cost | 6984 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;1 - \sqrt{0.5 + \frac{-0.5}{x}}\\
\mathbf{elif}\;x \leq 1.55:\\
\;\;\;\;0.125 \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{1 + \sqrt{0.5}}\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 1.5 |
|---|
| Cost | 6857 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \lor \neg \left(x \leq 1.55\right):\\
\;\;\;\;1 - \sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;0.125 \cdot \left(x \cdot x\right)\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 25.0 |
|---|
| Cost | 585 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.8 \lor \neg \left(x \leq 1.25\right):\\
\;\;\;\;0.25 - \frac{0.25}{x}\\
\mathbf{else}:\\
\;\;\;\;0.125 \cdot \left(x \cdot x\right)\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 26.0 |
|---|
| Cost | 584 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.2:\\
\;\;\;\;0.18181818181818182\\
\mathbf{elif}\;x \leq 1.2:\\
\;\;\;\;0.125 \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;0.18181818181818182\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 26.1 |
|---|
| Cost | 576 |
|---|
\[\frac{1}{5.5 + \frac{8}{x \cdot x}}
\]
| Alternative 12 |
|---|
| Error | 40.8 |
|---|
| Cost | 328 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{-77}:\\
\;\;\;\;0.18181818181818182\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-77}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;0.18181818181818182\\
\end{array}
\]
| Alternative 13 |
|---|
| Error | 56.4 |
|---|
| Cost | 64 |
|---|
\[0.18181818181818182
\]