\[\frac{2}{1 + e^{-2 \cdot x}} - 1
\]
↓
\[\begin{array}{l}
t_0 := 2 + \mathsf{expm1}\left(-2 \cdot x\right)\\
t_1 := \frac{2}{t_0}\\
\mathbf{if}\;-2 \cdot x \leq -0.05:\\
\;\;\;\;\frac{\sqrt{t_1 + -1}}{\sqrt{t_1 + 1}} \cdot \sqrt{-1 + \frac{4}{{t_0}^{2}}}\\
\mathbf{elif}\;-2 \cdot x \leq 10^{-8}:\\
\;\;\;\;-0.3333333333333333 \cdot {x}^{3} + \left(x + 0.13333333333333333 \cdot {x}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;-1\\
\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 (+ 2.0 (expm1 (* -2.0 x)))) (t_1 (/ 2.0 t_0)))
(if (<= (* -2.0 x) -0.05)
(*
(/ (sqrt (+ t_1 -1.0)) (sqrt (+ t_1 1.0)))
(sqrt (+ -1.0 (/ 4.0 (pow t_0 2.0)))))
(if (<= (* -2.0 x) 1e-8)
(+
(* -0.3333333333333333 (pow x 3.0))
(+ x (* 0.13333333333333333 (pow x 5.0))))
-1.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 = 2.0 + expm1((-2.0 * x));
double t_1 = 2.0 / t_0;
double tmp;
if ((-2.0 * x) <= -0.05) {
tmp = (sqrt((t_1 + -1.0)) / sqrt((t_1 + 1.0))) * sqrt((-1.0 + (4.0 / pow(t_0, 2.0))));
} else if ((-2.0 * x) <= 1e-8) {
tmp = (-0.3333333333333333 * pow(x, 3.0)) + (x + (0.13333333333333333 * pow(x, 5.0)));
} else {
tmp = -1.0;
}
return tmp;
}
public static double code(double x, double y) {
return (2.0 / (1.0 + Math.exp((-2.0 * x)))) - 1.0;
}
↓
public static double code(double x, double y) {
double t_0 = 2.0 + Math.expm1((-2.0 * x));
double t_1 = 2.0 / t_0;
double tmp;
if ((-2.0 * x) <= -0.05) {
tmp = (Math.sqrt((t_1 + -1.0)) / Math.sqrt((t_1 + 1.0))) * Math.sqrt((-1.0 + (4.0 / Math.pow(t_0, 2.0))));
} else if ((-2.0 * x) <= 1e-8) {
tmp = (-0.3333333333333333 * Math.pow(x, 3.0)) + (x + (0.13333333333333333 * Math.pow(x, 5.0)));
} else {
tmp = -1.0;
}
return tmp;
}
def code(x, y):
return (2.0 / (1.0 + math.exp((-2.0 * x)))) - 1.0
↓
def code(x, y):
t_0 = 2.0 + math.expm1((-2.0 * x))
t_1 = 2.0 / t_0
tmp = 0
if (-2.0 * x) <= -0.05:
tmp = (math.sqrt((t_1 + -1.0)) / math.sqrt((t_1 + 1.0))) * math.sqrt((-1.0 + (4.0 / math.pow(t_0, 2.0))))
elif (-2.0 * x) <= 1e-8:
tmp = (-0.3333333333333333 * math.pow(x, 3.0)) + (x + (0.13333333333333333 * math.pow(x, 5.0)))
else:
tmp = -1.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(2.0 + expm1(Float64(-2.0 * x)))
t_1 = Float64(2.0 / t_0)
tmp = 0.0
if (Float64(-2.0 * x) <= -0.05)
tmp = Float64(Float64(sqrt(Float64(t_1 + -1.0)) / sqrt(Float64(t_1 + 1.0))) * sqrt(Float64(-1.0 + Float64(4.0 / (t_0 ^ 2.0)))));
elseif (Float64(-2.0 * x) <= 1e-8)
tmp = Float64(Float64(-0.3333333333333333 * (x ^ 3.0)) + Float64(x + Float64(0.13333333333333333 * (x ^ 5.0))));
else
tmp = -1.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[(2.0 + N[(Exp[N[(-2.0 * x), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(2.0 / t$95$0), $MachinePrecision]}, If[LessEqual[N[(-2.0 * x), $MachinePrecision], -0.05], N[(N[(N[Sqrt[N[(t$95$1 + -1.0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(-1.0 + N[(4.0 / N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(-2.0 * x), $MachinePrecision], 1e-8], N[(N[(-0.3333333333333333 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(x + N[(0.13333333333333333 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0]]]]
\frac{2}{1 + e^{-2 \cdot x}} - 1
↓
\begin{array}{l}
t_0 := 2 + \mathsf{expm1}\left(-2 \cdot x\right)\\
t_1 := \frac{2}{t_0}\\
\mathbf{if}\;-2 \cdot x \leq -0.05:\\
\;\;\;\;\frac{\sqrt{t_1 + -1}}{\sqrt{t_1 + 1}} \cdot \sqrt{-1 + \frac{4}{{t_0}^{2}}}\\
\mathbf{elif}\;-2 \cdot x \leq 10^{-8}:\\
\;\;\;\;-0.3333333333333333 \cdot {x}^{3} + \left(x + 0.13333333333333333 \cdot {x}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 0.4 |
|---|
| Cost | 27780 |
|---|
\[\begin{array}{l}
t_0 := 2 + \mathsf{expm1}\left(-2 \cdot x\right)\\
\mathbf{if}\;-2 \cdot x \leq -0.05:\\
\;\;\;\;\frac{4}{\left(\frac{2}{t_0} + 1\right) \cdot {t_0}^{2}} + \frac{1}{-1 + \frac{-2}{t_0}}\\
\mathbf{elif}\;-2 \cdot x \leq 10^{-8}:\\
\;\;\;\;-0.3333333333333333 \cdot {x}^{3} + \left(x + 0.13333333333333333 \cdot {x}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 0.4 |
|---|
| Cost | 20740 |
|---|
\[\begin{array}{l}
t_0 := 2 + \mathsf{expm1}\left(-2 \cdot x\right)\\
\mathbf{if}\;-2 \cdot x \leq -0.05:\\
\;\;\;\;\frac{-1 + \frac{4}{{t_0}^{2}}}{\frac{2}{t_0} + 1}\\
\mathbf{elif}\;-2 \cdot x \leq 10^{-8}:\\
\;\;\;\;-0.3333333333333333 \cdot {x}^{3} + \left(x + 0.13333333333333333 \cdot {x}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 0.4 |
|---|
| Cost | 14024 |
|---|
\[\begin{array}{l}
\mathbf{if}\;-2 \cdot x \leq -0.05:\\
\;\;\;\;\frac{2}{2 + \mathsf{expm1}\left(-2 \cdot x\right)} + -1\\
\mathbf{elif}\;-2 \cdot x \leq 10^{-8}:\\
\;\;\;\;-0.3333333333333333 \cdot {x}^{3} + \left(x + 0.13333333333333333 \cdot {x}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 0.4 |
|---|
| Cost | 7236 |
|---|
\[\begin{array}{l}
\mathbf{if}\;-2 \cdot x \leq -0.001:\\
\;\;\;\;\frac{2}{2 + \mathsf{expm1}\left(-2 \cdot x\right)} + -1\\
\mathbf{elif}\;-2 \cdot x \leq 10^{-8}:\\
\;\;\;\;x + \left(x \cdot x\right) \cdot \left(x \cdot -0.3333333333333333\right)\\
\mathbf{else}:\\
\;\;\;\;-1\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 13.3 |
|---|
| Cost | 708 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -0.66:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot 2\right) \cdot \frac{1}{x + 2}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 13.0 |
|---|
| Cost | 584 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2.55:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{-4}{x}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 13.0 |
|---|
| Cost | 328 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;-1\\
\mathbf{elif}\;x \leq 2:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 42.7 |
|---|
| Cost | 196 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq 1.1 \cdot 10^{-308}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 45.9 |
|---|
| Cost | 64 |
|---|
\[-1
\]