(FPCore (x y) :precision binary64 (- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))
(FPCore (x y)
:precision binary64
(if (<= (* -2.0 x) -0.26266776566857986)
(fma (/ -2.0 (expm1 (* x -4.0))) (- (expm1 (* -2.0 x))) -1.0)
(if (<= (* -2.0 x) 6.3780832365879e-6)
(fma (pow x 3.0) -0.3333333333333333 x)
(log (/ (exp (/ 2.0 (+ 1.0 (exp (* -2.0 x))))) E)))))double code(double x, double y) {
return (2.0 / (1.0 + exp((-2.0 * x)))) - 1.0;
}
double code(double x, double y) {
double tmp;
if ((-2.0 * x) <= -0.26266776566857986) {
tmp = fma((-2.0 / expm1((x * -4.0))), -expm1((-2.0 * x)), -1.0);
} else if ((-2.0 * x) <= 6.3780832365879e-6) {
tmp = fma(pow(x, 3.0), -0.3333333333333333, x);
} else {
tmp = log((exp((2.0 / (1.0 + exp((-2.0 * x))))) / ((double) M_E)));
}
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) tmp = 0.0 if (Float64(-2.0 * x) <= -0.26266776566857986) tmp = fma(Float64(-2.0 / expm1(Float64(x * -4.0))), Float64(-expm1(Float64(-2.0 * x))), -1.0); elseif (Float64(-2.0 * x) <= 6.3780832365879e-6) tmp = fma((x ^ 3.0), -0.3333333333333333, x); else tmp = log(Float64(exp(Float64(2.0 / Float64(1.0 + exp(Float64(-2.0 * x))))) / exp(1))); 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_] := If[LessEqual[N[(-2.0 * x), $MachinePrecision], -0.26266776566857986], N[(N[(-2.0 / N[(Exp[N[(x * -4.0), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] * (-N[(Exp[N[(-2.0 * x), $MachinePrecision]] - 1), $MachinePrecision]) + -1.0), $MachinePrecision], If[LessEqual[N[(-2.0 * x), $MachinePrecision], 6.3780832365879e-6], N[(N[Power[x, 3.0], $MachinePrecision] * -0.3333333333333333 + x), $MachinePrecision], N[Log[N[(N[Exp[N[(2.0 / N[(1.0 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / E), $MachinePrecision]], $MachinePrecision]]]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \leq -0.26266776566857986:\\
\;\;\;\;\mathsf{fma}\left(\frac{-2}{\mathsf{expm1}\left(x \cdot -4\right)}, -\mathsf{expm1}\left(-2 \cdot x\right), -1\right)\\
\mathbf{elif}\;-2 \cdot x \leq 6.3780832365879 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left({x}^{3}, -0.3333333333333333, x\right)\\
\mathbf{else}:\\
\;\;\;\;\log \left(\frac{e^{\frac{2}{1 + e^{-2 \cdot x}}}}{e}\right)\\
\end{array}



Bits error versus x



Bits error versus y
if (*.f64 -2 x) < -0.26266776566857986Initial program 0.0
Applied add-cube-cbrt_binary640.0
Applied flip-+_binary640.0
Applied associate-/r/_binary640.0
Applied prod-diff_binary640.0
Simplified0.0
Simplified0.0
Taylor expanded in x around inf 0.0
Simplified0.0
if -0.26266776566857986 < (*.f64 -2 x) < 6.37808323658789988e-6Initial program 59.0
Taylor expanded in x around 0 0.1
Simplified0.1
if 6.37808323658789988e-6 < (*.f64 -2 x) Initial program 0.2
Applied add-log-exp_binary640.2
Applied add-log-exp_binary640.2
Applied diff-log_binary640.1
Taylor expanded in x around inf 0.1
Final simplification0.1
herbie shell --seed 2022131
(FPCore (x y)
:name "Logistic function from Lakshay Garg"
:precision binary64
(- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))