(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.4)
(expm1
(exp
(*
(* 3.0 (log (- (log 2.0) (log1p (exp (* -2.0 x))))))
0.3333333333333333)))
(expm1 (fma -0.5 (pow x 2.0) x))))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.4) {
tmp = expm1(exp(((3.0 * log((log(2.0) - log1p(exp((-2.0 * x)))))) * 0.3333333333333333)));
} else {
tmp = expm1(fma(-0.5, pow(x, 2.0), x));
}
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.4) tmp = expm1(exp(Float64(Float64(3.0 * log(Float64(log(2.0) - log1p(exp(Float64(-2.0 * x)))))) * 0.3333333333333333))); else tmp = expm1(fma(-0.5, (x ^ 2.0), x)); 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.4], N[(Exp[N[Exp[N[(N[(3.0 * N[Log[N[(N[Log[2.0], $MachinePrecision] - N[Log[1 + N[Exp[N[(-2.0 * x), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * 0.3333333333333333), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision], N[(Exp[N[(-0.5 * N[Power[x, 2.0], $MachinePrecision] + x), $MachinePrecision]] - 1), $MachinePrecision]]
\frac{2}{1 + e^{-2 \cdot x}} - 1
\begin{array}{l}
\mathbf{if}\;-2 \cdot x \leq -0.4:\\
\;\;\;\;\mathsf{expm1}\left(e^{\left(3 \cdot \log \left(\log 2 - \mathsf{log1p}\left(e^{-2 \cdot x}\right)\right)\right) \cdot 0.3333333333333333}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(\mathsf{fma}\left(-0.5, {x}^{2}, x\right)\right)\\
\end{array}
if (*.f64 -2 x) < -0.40000000000000002Initial program 100.0%
Simplified100.0%
Applied egg-rr100.0%
Simplified100.0%
if -0.40000000000000002 < (*.f64 -2 x) Initial program 39.1%
Simplified39.2%
Taylor expanded in x around 0 99.7%
Simplified99.7%
herbie shell --seed 2023237
(FPCore (x y)
:name "Logistic function from Lakshay Garg"
:precision binary64
(- (/ 2.0 (+ 1.0 (exp (* -2.0 x)))) 1.0))