\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
t_0 := e^{-2 \cdot x}\\
\mathbf{if}\;-2 \cdot x \leq -1.3115628904211583:\\
\;\;\;\;\mathsf{expm1}\left(\log 2 - \mathsf{log1p}\left(t_0\right)\right)\\
\mathbf{elif}\;-2 \cdot x \leq 5.061423180174997 \cdot 10^{-11}:\\
\;\;\;\;\mathsf{fma}\left({x}^{3}, -0.3333333333333333, x\right)\\
\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := \frac{\sqrt{2}}{\sqrt{t_0 + 1}}\\
\mathsf{fma}\left(t_1, t_1, -1\right)
\end{array}\\
\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 (exp (* -2.0 x))))
(if (<= (* -2.0 x) -1.3115628904211583)
(expm1 (- (log 2.0) (log1p t_0)))
(if (<= (* -2.0 x) 5.061423180174997e-11)
(fma (pow x 3.0) -0.3333333333333333 x)
(let* ((t_1 (/ (sqrt 2.0) (sqrt (+ t_0 1.0))))) (fma t_1 t_1 -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 = exp(-2.0 * x);
double tmp;
if ((-2.0 * x) <= -1.3115628904211583) {
tmp = expm1(log(2.0) - log1p(t_0));
} else if ((-2.0 * x) <= 5.061423180174997e-11) {
tmp = fma(pow(x, 3.0), -0.3333333333333333, x);
} else {
double t_1 = sqrt(2.0) / sqrt(t_0 + 1.0);
tmp = fma(t_1, t_1, -1.0);
}
return tmp;
}



Bits error versus x



Bits error versus y
if (*.f64 -2 x) < -1.31156289042115826Initial program 0.0
Applied add-exp-log_binary640.0
Applied add-exp-log_binary640.0
Applied div-exp_binary640.0
Simplified0.0
Applied expm1-log1p-u_binary640.0
Simplified0.0
if -1.31156289042115826 < (*.f64 -2 x) < 5.0614231801749972e-11Initial program 59.4
Taylor expanded in x around 0 0.1
Simplified0.1
if 5.0614231801749972e-11 < (*.f64 -2 x) Initial program 0.4
Applied add-sqr-sqrt_binary640.5
Applied add-sqr-sqrt_binary640.5
Applied times-frac_binary640.5
Applied fma-neg_binary640.5
Simplified0.5
Final simplification0.2
herbie shell --seed 2022067
(FPCore (x y)
:name "Logistic function from Lakshay Garg"
:precision binary64
(- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))