\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
t_0 := e^{-2 \cdot x}\\
\mathbf{if}\;-2 \cdot x \leq -0.2058449771208138:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{log1p}\left(\log \left(e^{\frac{2}{1 + t_0} - 1}\right)\right)\right)\\
\mathbf{elif}\;-2 \cdot x \leq 6.329283615984725 \cdot 10^{-12}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\log \left(e^{\frac{2}{\mathsf{fma}\left(1, 1, t_0\right)} - 1}\right)\\
\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) -0.2058449771208138)
(expm1 (log1p (log (exp (- (/ 2.0 (+ 1.0 t_0)) 1.0)))))
(if (<= (* -2.0 x) 6.329283615984725e-12)
x
(log (exp (- (/ 2.0 (fma 1.0 1.0 t_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 = exp(-2.0 * x);
double tmp;
if ((-2.0 * x) <= -0.2058449771208138) {
tmp = expm1(log1p(log(exp((2.0 / (1.0 + t_0)) - 1.0))));
} else if ((-2.0 * x) <= 6.329283615984725e-12) {
tmp = x;
} else {
tmp = log(exp((2.0 / fma(1.0, 1.0, t_0)) - 1.0));
}
return tmp;
}



Bits error versus x



Bits error versus y
if (*.f64 -2 x) < -0.20584497712081379Initial program 0.0
Applied add-log-exp_binary640.0
Applied add-log-exp_binary640.0
Applied diff-log_binary640.0
Simplified0.0
Applied expm1-log1p-u_binary640.0
if -0.20584497712081379 < (*.f64 -2 x) < 6.3292836159847248e-12Initial program 59.5
Taylor expanded in x around 0 0.3
if 6.3292836159847248e-12 < (*.f64 -2 x) Initial program 0.7
Applied add-log-exp_binary640.7
Applied add-log-exp_binary640.7
Applied diff-log_binary640.7
Simplified0.7
Applied *-un-lft-identity_binary640.7
Applied fma-def_binary640.7
Final simplification0.3
herbie shell --seed 2021224
(FPCore (x y)
:name "Logistic function from Lakshay Garg"
:precision binary64
(- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))