\[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
\]
↓
\[\begin{array}{l}
\mathbf{if}\;x \leq -3:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 2 + \left(0.3333333333333333 \cdot {x}^{3} + \left(\left(-1 + e^{\mathsf{log1p}\left(0.0003968253968253968 \cdot {x}^{7}\right)}\right) + 0.016666666666666666 \cdot {x}^{5}\right)\right)}{e^{x} + e^{-x}}\\
\end{array}
\]
(FPCore (x)
:precision binary64
(/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))
↓
(FPCore (x)
:precision binary64
(if (<= x -3.0)
-1.0
(/
(+
(* x 2.0)
(+
(* 0.3333333333333333 (pow x 3.0))
(+
(+ -1.0 (exp (log1p (* 0.0003968253968253968 (pow x 7.0)))))
(* 0.016666666666666666 (pow x 5.0)))))
(+ (exp x) (exp (- x))))))double code(double x) {
return (exp(x) - exp(-x)) / (exp(x) + exp(-x));
}
↓
double code(double x) {
double tmp;
if (x <= -3.0) {
tmp = -1.0;
} else {
tmp = ((x * 2.0) + ((0.3333333333333333 * pow(x, 3.0)) + ((-1.0 + exp(log1p((0.0003968253968253968 * pow(x, 7.0))))) + (0.016666666666666666 * pow(x, 5.0))))) / (exp(x) + exp(-x));
}
return tmp;
}
public static double code(double x) {
return (Math.exp(x) - Math.exp(-x)) / (Math.exp(x) + Math.exp(-x));
}
↓
public static double code(double x) {
double tmp;
if (x <= -3.0) {
tmp = -1.0;
} else {
tmp = ((x * 2.0) + ((0.3333333333333333 * Math.pow(x, 3.0)) + ((-1.0 + Math.exp(Math.log1p((0.0003968253968253968 * Math.pow(x, 7.0))))) + (0.016666666666666666 * Math.pow(x, 5.0))))) / (Math.exp(x) + Math.exp(-x));
}
return tmp;
}
def code(x):
return (math.exp(x) - math.exp(-x)) / (math.exp(x) + math.exp(-x))
↓
def code(x):
tmp = 0
if x <= -3.0:
tmp = -1.0
else:
tmp = ((x * 2.0) + ((0.3333333333333333 * math.pow(x, 3.0)) + ((-1.0 + math.exp(math.log1p((0.0003968253968253968 * math.pow(x, 7.0))))) + (0.016666666666666666 * math.pow(x, 5.0))))) / (math.exp(x) + math.exp(-x))
return tmp
function code(x)
return Float64(Float64(exp(x) - exp(Float64(-x))) / Float64(exp(x) + exp(Float64(-x))))
end
↓
function code(x)
tmp = 0.0
if (x <= -3.0)
tmp = -1.0;
else
tmp = Float64(Float64(Float64(x * 2.0) + Float64(Float64(0.3333333333333333 * (x ^ 3.0)) + Float64(Float64(-1.0 + exp(log1p(Float64(0.0003968253968253968 * (x ^ 7.0))))) + Float64(0.016666666666666666 * (x ^ 5.0))))) / Float64(exp(x) + exp(Float64(-x))));
end
return tmp
end
code[x_] := N[(N[(N[Exp[x], $MachinePrecision] - N[Exp[(-x)], $MachinePrecision]), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
↓
code[x_] := If[LessEqual[x, -3.0], -1.0, N[(N[(N[(x * 2.0), $MachinePrecision] + N[(N[(0.3333333333333333 * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(-1.0 + N[Exp[N[Log[1 + N[(0.0003968253968253968 * N[Power[x, 7.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(0.016666666666666666 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}}
↓
\begin{array}{l}
\mathbf{if}\;x \leq -3:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 2 + \left(0.3333333333333333 \cdot {x}^{3} + \left(\left(-1 + e^{\mathsf{log1p}\left(0.0003968253968253968 \cdot {x}^{7}\right)}\right) + 0.016666666666666666 \cdot {x}^{5}\right)\right)}{e^{x} + e^{-x}}\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 98.6% |
|---|
| Cost | 33604.00 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -3:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 2 + \left(0.3333333333333333 \cdot {x}^{3} + \left(0.0003968253968253968 \cdot {x}^{7} + 0.016666666666666666 \cdot {x}^{5}\right)\right)}{e^{x} + e^{-x}}\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 98.5% |
|---|
| Cost | 20868.00 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -2.15:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 2 + \left(0.3333333333333333 \cdot {x}^{3} + 0.016666666666666666 \cdot {x}^{5}\right)}{2 + \left(x \cdot x + 0.08333333333333333 \cdot {x}^{4}\right)}\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 98.4% |
|---|
| Cost | 20356.00 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.3:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;{x}^{7} \cdot -0.05396825396825397 + \left({x}^{3} \cdot -0.3333333333333333 + \left(x + {x}^{5} \cdot 0.13333333333333333\right)\right)\\
\end{array}
\]
| Alternative 4 |
|---|
| Error | 98.4% |
|---|
| Cost | 13636.00 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;{x}^{3} \cdot -0.3333333333333333 + \left(x + {x}^{5} \cdot 0.13333333333333333\right)\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 98.4% |
|---|
| Cost | 7812.00 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.86:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2 + \left(x \cdot x + 0.08333333333333333 \cdot {x}^{4}\right)}\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 98.3% |
|---|
| Cost | 7044.00 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.65:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\frac{-x}{\mathsf{fma}\left(-0.3333333333333333, x \cdot x, -1\right)}\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 98.3% |
|---|
| Cost | 1092.00 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.6:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{-2 + x \cdot \left(x \cdot -0.3333333333333333\right)}{-2 - x \cdot x}\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 98.3% |
|---|
| Cost | 1092.00 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.6:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{-2 - x \cdot x}{-2 + x \cdot \left(x \cdot -0.3333333333333333\right)}}\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 97.8% |
|---|
| Cost | 708.00 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1.25:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;\frac{x + x}{2 + x \cdot x}\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 7.8% |
|---|
| Cost | 196.00 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{-309}:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 97.8% |
|---|
| Cost | 196.00 |
|---|
\[\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;-1\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 5.0% |
|---|
| Cost | 64.00 |
|---|
\[-1
\]