\[1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
\]
↓
\[\begin{array}{l}
t_0 := 0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.2:\\
\;\;\;\;\mathsf{fma}\left(0.0673828125, {x}^{6}, \mathsf{fma}\left(-0.0859375, {x}^{4}, x \cdot \left(x \cdot 0.125\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25 + \frac{-0.25}{1 + x \cdot x}}{t_0 + {t_0}^{1.5}}\\
\end{array}
\]
(FPCore (x)
:precision binary64
(- 1.0 (sqrt (* 0.5 (+ 1.0 (/ 1.0 (hypot 1.0 x)))))))
↓
(FPCore (x)
:precision binary64
(let* ((t_0 (+ 0.5 (/ 0.5 (hypot 1.0 x)))))
(if (<= (hypot 1.0 x) 1.2)
(fma
0.0673828125
(pow x 6.0)
(fma -0.0859375 (pow x 4.0) (* x (* x 0.125))))
(/ (+ 0.25 (/ -0.25 (+ 1.0 (* x x)))) (+ t_0 (pow t_0 1.5))))))double code(double x) {
return 1.0 - sqrt((0.5 * (1.0 + (1.0 / hypot(1.0, x)))));
}
↓
double code(double x) {
double t_0 = 0.5 + (0.5 / hypot(1.0, x));
double tmp;
if (hypot(1.0, x) <= 1.2) {
tmp = fma(0.0673828125, pow(x, 6.0), fma(-0.0859375, pow(x, 4.0), (x * (x * 0.125))));
} else {
tmp = (0.25 + (-0.25 / (1.0 + (x * x)))) / (t_0 + pow(t_0, 1.5));
}
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)
t_0 = Float64(0.5 + Float64(0.5 / hypot(1.0, x)))
tmp = 0.0
if (hypot(1.0, x) <= 1.2)
tmp = fma(0.0673828125, (x ^ 6.0), fma(-0.0859375, (x ^ 4.0), Float64(x * Float64(x * 0.125))));
else
tmp = Float64(Float64(0.25 + Float64(-0.25 / Float64(1.0 + Float64(x * x)))) / Float64(t_0 + (t_0 ^ 1.5)));
end
return 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_] := Block[{t$95$0 = N[(0.5 + N[(0.5 / N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sqrt[1.0 ^ 2 + x ^ 2], $MachinePrecision], 1.2], N[(0.0673828125 * N[Power[x, 6.0], $MachinePrecision] + N[(-0.0859375 * N[Power[x, 4.0], $MachinePrecision] + N[(x * N[(x * 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.25 + N[(-0.25 / N[(1.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[Power[t$95$0, 1.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
1 - \sqrt{0.5 \cdot \left(1 + \frac{1}{\mathsf{hypot}\left(1, x\right)}\right)}
↓
\begin{array}{l}
t_0 := 0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.2:\\
\;\;\;\;\mathsf{fma}\left(0.0673828125, {x}^{6}, \mathsf{fma}\left(-0.0859375, {x}^{4}, x \cdot \left(x \cdot 0.125\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25 + \frac{-0.25}{1 + x \cdot x}}{t_0 + {t_0}^{1.5}}\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.16% |
|---|
| Cost | 27332 |
|---|
\[\begin{array}{l}
t_0 := 0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.2:\\
\;\;\;\;0.125 \cdot {x}^{2} + \left(0.0673828125 \cdot {x}^{6} + -0.0859375 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25 + \frac{-0.25}{1 + x \cdot x}}{t_0 + {t_0}^{1.5}}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.16% |
|---|
| Cost | 26948 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.2:\\
\;\;\;\;0.125 \cdot {x}^{2} + \left(0.0673828125 \cdot {x}^{6} + -0.0859375 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 - \sqrt{\frac{0.25}{1 + x \cdot x}}}{1 + \sqrt{0.5 + \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.16% |
|---|
| Cost | 26884 |
|---|
\[\begin{array}{l}
t_0 := \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.2:\\
\;\;\;\;0.125 \cdot {x}^{2} + \left(0.0673828125 \cdot {x}^{6} + -0.0859375 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + \sqrt{0.5 + t_0}} \cdot \left(0.5 - t_0\right)\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.16% |
|---|
| Cost | 26756 |
|---|
\[\begin{array}{l}
t_0 := \frac{0.5}{\mathsf{hypot}\left(1, x\right)}\\
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.2:\\
\;\;\;\;0.125 \cdot {x}^{2} + \left(0.0673828125 \cdot {x}^{6} + -0.0859375 \cdot {x}^{4}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 - t_0}{1 + \sqrt{0.5 + t_0}}\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 0.91% |
|---|
| Cost | 26692 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.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}{x}}}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 0.99% |
|---|
| Cost | 20292 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 1.2:\\
\;\;\;\;-0.0859375 \cdot {x}^{4} + x \cdot \left(x \cdot 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 - \frac{0.5}{\mathsf{hypot}\left(1, x\right)}}{1 + \sqrt{0.5 + \frac{-0.5}{x}}}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 1.06% |
|---|
| Cost | 13828 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\mathsf{hypot}\left(1, x\right) \leq 2:\\
\;\;\;\;-0.0859375 \cdot {x}^{4} + x \cdot \left(x \cdot 0.125\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 - \frac{-0.5}{x}}{1 + \sqrt{0.5 + \frac{-0.5}{x}}}\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 1.41% |
|---|
| Cost | 7305 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.1 \lor \neg \left(x \leq 1.12\right):\\
\;\;\;\;\frac{0.5}{1 + \sqrt{0.5}}\\
\mathbf{else}:\\
\;\;\;\;-0.0859375 \cdot {x}^{4} + x \cdot \left(x \cdot 0.125\right)\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 1.67% |
|---|
| Cost | 6985 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \lor \neg \left(x \leq 1.52\right):\\
\;\;\;\;\frac{0.5}{1 + \sqrt{0.5}}\\
\mathbf{else}:\\
\;\;\;\;0.125 \cdot \left(x \cdot x\right)\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 2.42% |
|---|
| Cost | 6857 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.5 \lor \neg \left(x \leq 1.52\right):\\
\;\;\;\;1 - \sqrt{0.5}\\
\mathbf{else}:\\
\;\;\;\;0.125 \cdot \left(x \cdot x\right)\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 41.98% |
|---|
| Cost | 969 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -9.5 \cdot 10^{-5} \lor \neg \left(x \leq 0.00011\right):\\
\;\;\;\;\frac{0.25 + \frac{-0.25}{1 + x \cdot x}}{2}\\
\mathbf{else}:\\
\;\;\;\;0.125 \cdot \left(x \cdot x\right)\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 41.99% |
|---|
| Cost | 584 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;0.125\\
\mathbf{elif}\;x \leq 1:\\
\;\;\;\;0.125 \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;0.125\\
\end{array}
\]
| Alternative 13 |
|---|
| Error | 88.54% |
|---|
| Cost | 64 |
|---|
\[0.125
\]