
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
float code(float x, float s) {
return 1.0f / (1.0f + expf((-x / s)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (1.0e0 + exp((-x / s)))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-x) / s)))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + exp((-x / s))); end
\begin{array}{l}
\\
\frac{1}{1 + e^{\frac{-x}{s}}}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
float code(float x, float s) {
return 1.0f / (1.0f + expf((-x / s)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (1.0e0 + exp((-x / s)))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-x) / s)))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + exp((-x / s))); end
\begin{array}{l}
\\
\frac{1}{1 + e^{\frac{-x}{s}}}
\end{array}
(FPCore (x s) :precision binary32 (exp (- (log1p (exp (/ (- x) s))))))
float code(float x, float s) {
return expf(-log1pf(expf((-x / s))));
}
function code(x, s) return exp(Float32(-log1p(exp(Float32(Float32(-x) / s))))) end
\begin{array}{l}
\\
e^{-\mathsf{log1p}\left(e^{\frac{-x}{s}}\right)}
\end{array}
Initial program 99.7%
inv-powN/A
pow-to-expN/A
*-commutativeN/A
log-powN/A
inv-powN/A
exp-lowering-exp.f32N/A
log-recN/A
neg-lowering-neg.f32N/A
log1p-defineN/A
log1p-lowering-log1p.f32N/A
exp-lowering-exp.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3299.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x s)
:precision binary32
(/
1.0
(+
1.0
(*
(exp (/ -0.3333333333333333 (/ s x)))
(exp (* -0.6666666666666666 (/ x s)))))))
float code(float x, float s) {
return 1.0f / (1.0f + (expf((-0.3333333333333333f / (s / x))) * expf((-0.6666666666666666f * (x / s)))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (1.0e0 + (exp(((-0.3333333333333333e0) / (s / x))) * exp(((-0.6666666666666666e0) * (x / s)))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(exp(Float32(Float32(-0.3333333333333333) / Float32(s / x))) * exp(Float32(Float32(-0.6666666666666666) * Float32(x / s)))))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + (exp((single(-0.3333333333333333) / (s / x))) * exp((single(-0.6666666666666666) * (x / s))))); end
\begin{array}{l}
\\
\frac{1}{1 + e^{\frac{-0.3333333333333333}{\frac{s}{x}}} \cdot e^{-0.6666666666666666 \cdot \frac{x}{s}}}
\end{array}
Initial program 99.7%
*-lft-identityN/A
exp-prodN/A
pow-lowering-pow.f32N/A
exp-1-eN/A
E-lowering-E.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3299.7%
Applied egg-rr99.7%
pow-lowering-pow.f32N/A
E-lowering-E.f32N/A
clear-numN/A
frac-2negN/A
metadata-evalN/A
distribute-frac-neg2N/A
frac-2negN/A
/-lowering-/.f32N/A
/-lowering-/.f3299.7%
Applied egg-rr99.7%
Applied egg-rr99.7%
Taylor expanded in x around 0
*-lowering-*.f32N/A
/-lowering-/.f3299.7%
Simplified99.7%
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (pow E (/ -1.0 (/ s x))))))
float code(float x, float s) {
return 1.0f / (1.0f + powf(((float) M_E), (-1.0f / (s / x))));
}
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + (Float32(exp(1)) ^ Float32(Float32(-1.0) / Float32(s / x))))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + (single(2.71828182845904523536) ^ (single(-1.0) / (s / x)))); end
\begin{array}{l}
\\
\frac{1}{1 + {e}^{\left(\frac{-1}{\frac{s}{x}}\right)}}
\end{array}
Initial program 99.7%
*-lft-identityN/A
exp-prodN/A
pow-lowering-pow.f32N/A
exp-1-eN/A
E-lowering-E.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3299.7%
Applied egg-rr99.7%
pow-lowering-pow.f32N/A
E-lowering-E.f32N/A
clear-numN/A
frac-2negN/A
metadata-evalN/A
distribute-frac-neg2N/A
frac-2negN/A
/-lowering-/.f32N/A
/-lowering-/.f3299.7%
Applied egg-rr99.7%
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
float code(float x, float s) {
return 1.0f / (1.0f + expf((-x / s)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (1.0e0 + exp((-x / s)))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-x) / s)))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + exp((-x / s))); end
\begin{array}{l}
\\
\frac{1}{1 + e^{\frac{-x}{s}}}
\end{array}
Initial program 99.7%
(FPCore (x s)
:precision binary32
(if (<= x -2.0000000063421537e-30)
(/
1.0
(+
2.0
(*
x
(+
(/ -1.0 s)
(* x (/ (+ 0.5 (/ (* x -0.16666666666666666) s)) (* s s)))))))
0.5))
float code(float x, float s) {
float tmp;
if (x <= -2.0000000063421537e-30f) {
tmp = 1.0f / (2.0f + (x * ((-1.0f / s) + (x * ((0.5f + ((x * -0.16666666666666666f) / s)) / (s * s))))));
} else {
tmp = 0.5f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-2.0000000063421537e-30)) then
tmp = 1.0e0 / (2.0e0 + (x * (((-1.0e0) / s) + (x * ((0.5e0 + ((x * (-0.16666666666666666e0)) / s)) / (s * s))))))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-2.0000000063421537e-30)) tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(x * Float32(Float32(Float32(-1.0) / s) + Float32(x * Float32(Float32(Float32(0.5) + Float32(Float32(x * Float32(-0.16666666666666666)) / s)) / Float32(s * s))))))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-2.0000000063421537e-30)) tmp = single(1.0) / (single(2.0) + (x * ((single(-1.0) / s) + (x * ((single(0.5) + ((x * single(-0.16666666666666666)) / s)) / (s * s)))))); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.0000000063421537 \cdot 10^{-30}:\\
\;\;\;\;\frac{1}{2 + x \cdot \left(\frac{-1}{s} + x \cdot \frac{0.5 + \frac{x \cdot -0.16666666666666666}{s}}{s \cdot s}\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -2e-30Initial program 99.6%
*-lft-identityN/A
exp-prodN/A
pow-lowering-pow.f32N/A
exp-1-eN/A
E-lowering-E.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3299.6%
Applied egg-rr99.6%
Taylor expanded in x around 0
Simplified86.0%
Taylor expanded in s around inf
/-lowering-/.f32N/A
+-lowering-+.f32N/A
associate-*r/N/A
/-lowering-/.f32N/A
*-commutativeN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3287.3%
Simplified87.3%
if -2e-30 < x Initial program 99.8%
Taylor expanded in x around 0
Simplified49.8%
(FPCore (x s)
:precision binary32
(if (<= x -3.0000000817356035e-27)
(/
1.0
(+
2.0
(* x (+ (/ -1.0 s) (* x (/ (* x -0.16666666666666666) (* s (* s s))))))))
0.5))
float code(float x, float s) {
float tmp;
if (x <= -3.0000000817356035e-27f) {
tmp = 1.0f / (2.0f + (x * ((-1.0f / s) + (x * ((x * -0.16666666666666666f) / (s * (s * s)))))));
} else {
tmp = 0.5f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-3.0000000817356035e-27)) then
tmp = 1.0e0 / (2.0e0 + (x * (((-1.0e0) / s) + (x * ((x * (-0.16666666666666666e0)) / (s * (s * s)))))))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-3.0000000817356035e-27)) tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(x * Float32(Float32(Float32(-1.0) / s) + Float32(x * Float32(Float32(x * Float32(-0.16666666666666666)) / Float32(s * Float32(s * s)))))))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-3.0000000817356035e-27)) tmp = single(1.0) / (single(2.0) + (x * ((single(-1.0) / s) + (x * ((x * single(-0.16666666666666666)) / (s * (s * s))))))); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.0000000817356035 \cdot 10^{-27}:\\
\;\;\;\;\frac{1}{2 + x \cdot \left(\frac{-1}{s} + x \cdot \frac{x \cdot -0.16666666666666666}{s \cdot \left(s \cdot s\right)}\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -3.00000008e-27Initial program 99.6%
*-lft-identityN/A
exp-prodN/A
pow-lowering-pow.f32N/A
exp-1-eN/A
E-lowering-E.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3299.7%
Applied egg-rr99.7%
Taylor expanded in x around 0
Simplified87.4%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f32N/A
*-commutativeN/A
*-lowering-*.f32N/A
cube-multN/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3286.0%
Simplified86.0%
if -3.00000008e-27 < x Initial program 99.7%
Taylor expanded in x around 0
Simplified51.4%
(FPCore (x s) :precision binary32 (if (<= x -2.0000000063421537e-30) (/ 1.0 (+ 2.0 (* x (+ (/ -1.0 s) (* x (/ 0.5 (* s s))))))) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -2.0000000063421537e-30f) {
tmp = 1.0f / (2.0f + (x * ((-1.0f / s) + (x * (0.5f / (s * s))))));
} else {
tmp = 0.5f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-2.0000000063421537e-30)) then
tmp = 1.0e0 / (2.0e0 + (x * (((-1.0e0) / s) + (x * (0.5e0 / (s * s))))))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-2.0000000063421537e-30)) tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(x * Float32(Float32(Float32(-1.0) / s) + Float32(x * Float32(Float32(0.5) / Float32(s * s))))))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-2.0000000063421537e-30)) tmp = single(1.0) / (single(2.0) + (x * ((single(-1.0) / s) + (x * (single(0.5) / (s * s)))))); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.0000000063421537 \cdot 10^{-30}:\\
\;\;\;\;\frac{1}{2 + x \cdot \left(\frac{-1}{s} + x \cdot \frac{0.5}{s \cdot s}\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -2e-30Initial program 99.6%
*-lft-identityN/A
exp-prodN/A
pow-lowering-pow.f32N/A
exp-1-eN/A
E-lowering-E.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3299.6%
Applied egg-rr99.6%
pow-lowering-pow.f32N/A
E-lowering-E.f32N/A
clear-numN/A
frac-2negN/A
metadata-evalN/A
distribute-frac-neg2N/A
frac-2negN/A
/-lowering-/.f32N/A
/-lowering-/.f3299.6%
Applied egg-rr99.6%
Taylor expanded in s around inf
Simplified83.7%
if -2e-30 < x Initial program 99.8%
Taylor expanded in x around 0
Simplified49.8%
(FPCore (x s) :precision binary32 (if (<= x -2.0000000063421537e-30) (/ 1.0 (+ 2.0 (* x (* x (/ 0.5 (* s s)))))) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -2.0000000063421537e-30f) {
tmp = 1.0f / (2.0f + (x * (x * (0.5f / (s * s)))));
} else {
tmp = 0.5f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-2.0000000063421537e-30)) then
tmp = 1.0e0 / (2.0e0 + (x * (x * (0.5e0 / (s * s)))))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-2.0000000063421537e-30)) tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(x * Float32(x * Float32(Float32(0.5) / Float32(s * s)))))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-2.0000000063421537e-30)) tmp = single(1.0) / (single(2.0) + (x * (x * (single(0.5) / (s * s))))); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.0000000063421537 \cdot 10^{-30}:\\
\;\;\;\;\frac{1}{2 + x \cdot \left(x \cdot \frac{0.5}{s \cdot s}\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -2e-30Initial program 99.6%
*-lft-identityN/A
exp-prodN/A
pow-lowering-pow.f32N/A
exp-1-eN/A
E-lowering-E.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3299.6%
Applied egg-rr99.6%
pow-lowering-pow.f32N/A
E-lowering-E.f32N/A
clear-numN/A
frac-2negN/A
metadata-evalN/A
distribute-frac-neg2N/A
frac-2negN/A
/-lowering-/.f32N/A
/-lowering-/.f3299.6%
Applied egg-rr99.6%
Taylor expanded in s around inf
Simplified83.7%
Taylor expanded in s around 0
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
*-lowering-*.f32N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3281.7%
Simplified81.7%
if -2e-30 < x Initial program 99.8%
Taylor expanded in x around 0
Simplified49.8%
(FPCore (x s) :precision binary32 (if (<= x -6.000000314464115e-23) (/ 1.0 (/ (* 0.5 (* x x)) (* s s))) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -6.000000314464115e-23f) {
tmp = 1.0f / ((0.5f * (x * x)) / (s * s));
} else {
tmp = 0.5f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-6.000000314464115e-23)) then
tmp = 1.0e0 / ((0.5e0 * (x * x)) / (s * s))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-6.000000314464115e-23)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(0.5) * Float32(x * x)) / Float32(s * s))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-6.000000314464115e-23)) tmp = single(1.0) / ((single(0.5) * (x * x)) / (s * s)); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.000000314464115 \cdot 10^{-23}:\\
\;\;\;\;\frac{1}{\frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -6.00000031e-23Initial program 99.6%
*-lft-identityN/A
exp-prodN/A
pow-lowering-pow.f32N/A
exp-1-eN/A
E-lowering-E.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3299.6%
Applied egg-rr99.6%
pow-lowering-pow.f32N/A
E-lowering-E.f32N/A
clear-numN/A
frac-2negN/A
metadata-evalN/A
distribute-frac-neg2N/A
frac-2negN/A
/-lowering-/.f32N/A
/-lowering-/.f3299.7%
Applied egg-rr99.7%
Taylor expanded in s around inf
Simplified83.9%
Taylor expanded in x around inf
associate-*r/N/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-outN/A
/-lowering-/.f32N/A
distribute-rgt-outN/A
metadata-evalN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3272.1%
Simplified72.1%
if -6.00000031e-23 < x Initial program 99.8%
Taylor expanded in x around 0
Simplified50.0%
Final simplification59.2%
(FPCore (x s) :precision binary32 (if (<= x -6.000000314464115e-23) (/ (* 2.0 (* s s)) (* x x)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -6.000000314464115e-23f) {
tmp = (2.0f * (s * s)) / (x * x);
} else {
tmp = 0.5f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-6.000000314464115e-23)) then
tmp = (2.0e0 * (s * s)) / (x * x)
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-6.000000314464115e-23)) tmp = Float32(Float32(Float32(2.0) * Float32(s * s)) / Float32(x * x)); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-6.000000314464115e-23)) tmp = (single(2.0) * (s * s)) / (x * x); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.000000314464115 \cdot 10^{-23}:\\
\;\;\;\;\frac{2 \cdot \left(s \cdot s\right)}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -6.00000031e-23Initial program 99.6%
*-lft-identityN/A
exp-prodN/A
pow-lowering-pow.f32N/A
exp-1-eN/A
E-lowering-E.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3299.6%
Applied egg-rr99.6%
pow-lowering-pow.f32N/A
E-lowering-E.f32N/A
clear-numN/A
frac-2negN/A
metadata-evalN/A
distribute-frac-neg2N/A
frac-2negN/A
/-lowering-/.f32N/A
/-lowering-/.f3299.7%
Applied egg-rr99.7%
Taylor expanded in s around inf
Simplified83.9%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3270.6%
Simplified70.6%
if -6.00000031e-23 < x Initial program 99.8%
Taylor expanded in x around 0
Simplified50.0%
(FPCore (x s) :precision binary32 (if (<= x 2.000000036005019e-35) (/ 1.0 (- 2.0 (/ x s))) 0.5))
float code(float x, float s) {
float tmp;
if (x <= 2.000000036005019e-35f) {
tmp = 1.0f / (2.0f - (x / s));
} else {
tmp = 0.5f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 2.000000036005019e-35) then
tmp = 1.0e0 / (2.0e0 - (x / s))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(2.000000036005019e-35)) tmp = Float32(Float32(1.0) / Float32(Float32(2.0) - Float32(x / s))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(2.000000036005019e-35)) tmp = single(1.0) / (single(2.0) - (x / s)); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.000000036005019 \cdot 10^{-35}:\\
\;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < 2.00000004e-35Initial program 99.5%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f3252.6%
Simplified52.6%
if 2.00000004e-35 < x Initial program 99.9%
Taylor expanded in x around 0
Simplified42.9%
(FPCore (x s) :precision binary32 0.5)
float code(float x, float s) {
return 0.5f;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.5e0
end function
function code(x, s) return Float32(0.5) end
function tmp = code(x, s) tmp = single(0.5); end
\begin{array}{l}
\\
0.5
\end{array}
Initial program 99.7%
Taylor expanded in x around 0
Simplified34.7%
herbie shell --seed 2024161
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))