\[\frac{2}{1 + e^{-2 \cdot x}} - 1
\]
↓
\[\begin{array}{l}
t_0 := 1 + {\left(e^{x}\right)}^{-2}\\
\mathbf{if}\;\frac{2}{1 + e^{-2 \cdot x}} \leq 1.000005:\\
\;\;\;\;\mathsf{expm1}\left(x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(8, {t_0}^{-3}, -1\right)}{\mathsf{fma}\left(4, {t_0}^{-2}, 1\right) + \frac{2}{t_0}}\\
\end{array}
\]
(FPCore (x y) :precision binary64 (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))
↓
(FPCore (x y)
:precision binary64
(let* ((t_0 (+ 1.0 (pow (exp x) -2.0))))
(if (<= (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.000005)
(expm1 x)
(/
(fma 8.0 (pow t_0 -3.0) -1.0)
(+ (fma 4.0 (pow t_0 -2.0) 1.0) (/ 2.0 t_0))))))double code(double x, double y) {
return (2.0 / (1.0 + exp((-2.0 * x)))) - 1.0;
}
↓
double code(double x, double y) {
double t_0 = 1.0 + pow(exp(x), -2.0);
double tmp;
if ((2.0 / (1.0 + exp((-2.0 * x)))) <= 1.000005) {
tmp = expm1(x);
} else {
tmp = fma(8.0, pow(t_0, -3.0), -1.0) / (fma(4.0, pow(t_0, -2.0), 1.0) + (2.0 / t_0));
}
return tmp;
}
function code(x, y)
return Float64(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) - 1.0)
end
↓
function code(x, y)
t_0 = Float64(1.0 + (exp(x) ^ -2.0))
tmp = 0.0
if (Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x)))) <= 1.000005)
tmp = expm1(x);
else
tmp = Float64(fma(8.0, (t_0 ^ -3.0), -1.0) / Float64(fma(4.0, (t_0 ^ -2.0), 1.0) + Float64(2.0 / t_0)));
end
return tmp
end
code[x_, y_] := N[(N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]
↓
code[x_, y_] := Block[{t$95$0 = N[(1.0 + N[Power[N[Exp[x], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1.000005], N[(Exp[x] - 1), $MachinePrecision], N[(N[(8.0 * N[Power[t$95$0, -3.0], $MachinePrecision] + -1.0), $MachinePrecision] / N[(N[(4.0 * N[Power[t$95$0, -2.0], $MachinePrecision] + 1.0), $MachinePrecision] + N[(2.0 / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\frac{2}{1 + e^{-2 \cdot x}} - 1
↓
\begin{array}{l}
t_0 := 1 + {\left(e^{x}\right)}^{-2}\\
\mathbf{if}\;\frac{2}{1 + e^{-2 \cdot x}} \leq 1.000005:\\
\;\;\;\;\mathsf{expm1}\left(x\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(8, {t_0}^{-3}, -1\right)}{\mathsf{fma}\left(4, {t_0}^{-2}, 1\right) + \frac{2}{t_0}}\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.5 |
|---|
| Cost | 39684 |
|---|
\[\begin{array}{l}
t_0 := 1 + {\left(e^{x}\right)}^{-2}\\
\mathbf{if}\;-2 \cdot x \leq -1 \cdot 10^{-5}:\\
\;\;\;\;\frac{\mathsf{fma}\left(4, {t_0}^{-2}, -1\right)}{1 + \frac{2}{t_0}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(x\right)\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.5 |
|---|
| Cost | 26180 |
|---|
\[\begin{array}{l}
\mathbf{if}\;-2 \cdot x \leq -1 \cdot 10^{-5}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(1\right) - \mathsf{log1p}\left(e^{-2 \cdot x}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(x\right)\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.5 |
|---|
| Cost | 13892 |
|---|
\[\begin{array}{l}
t_0 := \frac{2}{1 + e^{-2 \cdot x}}\\
\mathbf{if}\;t_0 \leq 1.000005:\\
\;\;\;\;\mathsf{expm1}\left(x\right)\\
\mathbf{else}:\\
\;\;\;\;t_0 + -1\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 14.0 |
|---|
| Cost | 6724 |
|---|
\[\begin{array}{l}
\mathbf{if}\;-2 \cdot x \leq -5 \cdot 10^{-15}:\\
\;\;\;\;\frac{1}{\frac{2 + x}{2 \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(x\right)\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 14.3 |
|---|
| Cost | 836 |
|---|
\[\begin{array}{l}
\mathbf{if}\;-2 \cdot x \leq 0.002:\\
\;\;\;\;x \cdot \frac{2}{2 + x}\\
\mathbf{else}:\\
\;\;\;\;-1 + \frac{2}{2 + -2 \cdot x}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 28.5 |
|---|
| Cost | 452 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.04099080273022204:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{-4}{x}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 29.4 |
|---|
| Cost | 448 |
|---|
\[x \cdot \frac{2}{2 + x}
\]
| Alternative 8 |
|---|
| Error | 28.5 |
|---|
| Cost | 196 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 0.04099080273022204:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 30.7 |
|---|
| Cost | 64 |
|---|
\[x
\]