
(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 11 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(x / Float32(-s)))))) end
\begin{array}{l}
\\
e^{-\mathsf{log1p}\left(e^{\frac{x}{-s}}\right)}
\end{array}
Initial program 99.9%
distribute-frac-neg99.9%
exp-neg99.9%
Applied egg-rr99.9%
add-exp-log99.9%
log-rec99.9%
log1p-expm1-u99.9%
log1p-define99.9%
rec-exp100.0%
expm1-log1p-u100.0%
distribute-neg-frac2100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (/ 1.0 (exp (/ x s))))))
float code(float x, float s) {
return 1.0f / (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 + (1.0e0 / exp((x / s))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) / exp(Float32(x / s))))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + (single(1.0) / exp((x / s)))); end
\begin{array}{l}
\\
\frac{1}{1 + \frac{1}{e^{\frac{x}{s}}}}
\end{array}
Initial program 99.9%
distribute-frac-neg99.9%
exp-neg99.9%
Applied egg-rr99.9%
Final simplification99.9%
(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(x / Float32(-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.9%
Final simplification99.9%
(FPCore (x s)
:precision binary32
(let* ((t_0 (+ 1.0 (/ s x))))
(if (<= x -1.999999936531045e-21)
(+ t_0 -1.0)
(if (<= x 2.00000009162741e-18) (/ (+ (* x 0.25) (* s 0.5)) s) t_0))))
float code(float x, float s) {
float t_0 = 1.0f + (s / x);
float tmp;
if (x <= -1.999999936531045e-21f) {
tmp = t_0 + -1.0f;
} else if (x <= 2.00000009162741e-18f) {
tmp = ((x * 0.25f) + (s * 0.5f)) / s;
} else {
tmp = t_0;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: tmp
t_0 = 1.0e0 + (s / x)
if (x <= (-1.999999936531045e-21)) then
tmp = t_0 + (-1.0e0)
else if (x <= 2.00000009162741e-18) then
tmp = ((x * 0.25e0) + (s * 0.5e0)) / s
else
tmp = t_0
end if
code = tmp
end function
function code(x, s) t_0 = Float32(Float32(1.0) + Float32(s / x)) tmp = Float32(0.0) if (x <= Float32(-1.999999936531045e-21)) tmp = Float32(t_0 + Float32(-1.0)); elseif (x <= Float32(2.00000009162741e-18)) tmp = Float32(Float32(Float32(x * Float32(0.25)) + Float32(s * Float32(0.5))) / s); else tmp = t_0; end return tmp end
function tmp_2 = code(x, s) t_0 = single(1.0) + (s / x); tmp = single(0.0); if (x <= single(-1.999999936531045e-21)) tmp = t_0 + single(-1.0); elseif (x <= single(2.00000009162741e-18)) tmp = ((x * single(0.25)) + (s * single(0.5))) / s; else tmp = t_0; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{s}{x}\\
\mathbf{if}\;x \leq -1.999999936531045 \cdot 10^{-21}:\\
\;\;\;\;t\_0 + -1\\
\mathbf{elif}\;x \leq 2.00000009162741 \cdot 10^{-18}:\\
\;\;\;\;\frac{x \cdot 0.25 + s \cdot 0.5}{s}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.9999999e-21Initial program 99.9%
Taylor expanded in x around 0 44.6%
mul-1-neg44.6%
unsub-neg44.6%
Simplified44.6%
Taylor expanded in x around inf 39.9%
associate-*r/39.9%
neg-mul-139.9%
Simplified39.9%
clear-num42.1%
associate-/r/39.9%
add-sqr-sqrt-0.0%
sqrt-unprod54.3%
sqr-neg54.3%
sqrt-unprod38.9%
add-sqr-sqrt38.9%
Applied egg-rr38.9%
associate-*l/38.9%
*-un-lft-identity38.9%
expm1-log1p-u38.8%
expm1-undefine89.3%
log1p-define89.3%
add-exp-log89.4%
Applied egg-rr89.4%
if -1.9999999e-21 < x < 2.00000009e-18Initial program 99.7%
Taylor expanded in x around 0 77.2%
associate-*r/77.2%
Simplified77.2%
Taylor expanded in s around 0 77.2%
if 2.00000009e-18 < x Initial program 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 98.5%
+-commutative98.5%
Simplified98.5%
frac-2neg98.5%
metadata-eval98.5%
div-inv98.5%
distribute-neg-in98.5%
distribute-frac-neg298.5%
add-sqr-sqrt-0.0%
sqrt-unprod98.5%
sqr-neg98.5%
sqrt-unprod98.5%
add-sqr-sqrt98.5%
metadata-eval98.5%
Applied egg-rr98.5%
mul-1-neg98.5%
distribute-neg-frac298.5%
+-commutative98.5%
distribute-neg-in98.5%
metadata-eval98.5%
sub-neg98.5%
Simplified98.5%
Taylor expanded in x around inf 96.9%
Final simplification89.5%
(FPCore (x s) :precision binary32 (if (<= x -0.03999999910593033) (/ 1.0 (/ x s)) (if (<= x 2.00000009162741e-18) (+ 0.5 (/ (* x 0.25) s)) (+ 1.0 (/ s x)))))
float code(float x, float s) {
float tmp;
if (x <= -0.03999999910593033f) {
tmp = 1.0f / (x / s);
} else if (x <= 2.00000009162741e-18f) {
tmp = 0.5f + ((x * 0.25f) / s);
} else {
tmp = 1.0f + (s / x);
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-0.03999999910593033e0)) then
tmp = 1.0e0 / (x / s)
else if (x <= 2.00000009162741e-18) then
tmp = 0.5e0 + ((x * 0.25e0) / s)
else
tmp = 1.0e0 + (s / x)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-0.03999999910593033)) tmp = Float32(Float32(1.0) / Float32(x / s)); elseif (x <= Float32(2.00000009162741e-18)) tmp = Float32(Float32(0.5) + Float32(Float32(x * Float32(0.25)) / s)); else tmp = Float32(Float32(1.0) + Float32(s / x)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-0.03999999910593033)) tmp = single(1.0) / (x / s); elseif (x <= single(2.00000009162741e-18)) tmp = single(0.5) + ((x * single(0.25)) / s); else tmp = single(1.0) + (s / x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.03999999910593033:\\
\;\;\;\;\frac{1}{\frac{x}{s}}\\
\mathbf{elif}\;x \leq 2.00000009162741 \cdot 10^{-18}:\\
\;\;\;\;0.5 + \frac{x \cdot 0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{s}{x}\\
\end{array}
\end{array}
if x < -0.0399999991Initial program 100.0%
Taylor expanded in x around 0 50.9%
mul-1-neg50.9%
unsub-neg50.9%
Simplified50.9%
Taylor expanded in x around inf 48.1%
associate-*r/48.1%
neg-mul-148.1%
Simplified48.1%
clear-num50.9%
inv-pow50.9%
add-sqr-sqrt-0.0%
sqrt-unprod59.9%
sqr-neg59.9%
sqrt-unprod50.9%
add-sqr-sqrt50.9%
Applied egg-rr50.9%
unpow-150.9%
Simplified50.9%
if -0.0399999991 < x < 2.00000009e-18Initial program 99.7%
Taylor expanded in x around 0 62.0%
associate-*r/62.0%
Simplified62.0%
if 2.00000009e-18 < x Initial program 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 98.5%
+-commutative98.5%
Simplified98.5%
frac-2neg98.5%
metadata-eval98.5%
div-inv98.5%
distribute-neg-in98.5%
distribute-frac-neg298.5%
add-sqr-sqrt-0.0%
sqrt-unprod98.5%
sqr-neg98.5%
sqrt-unprod98.5%
add-sqr-sqrt98.5%
metadata-eval98.5%
Applied egg-rr98.5%
mul-1-neg98.5%
distribute-neg-frac298.5%
+-commutative98.5%
distribute-neg-in98.5%
metadata-eval98.5%
sub-neg98.5%
Simplified98.5%
Taylor expanded in x around inf 96.9%
Final simplification72.0%
(FPCore (x s)
:precision binary32
(let* ((t_0 (+ 1.0 (/ s x))))
(if (<= x -1.999999936531045e-21)
(+ t_0 -1.0)
(if (<= x 2.00000009162741e-18) (+ 0.5 (/ (* x 0.25) s)) t_0))))
float code(float x, float s) {
float t_0 = 1.0f + (s / x);
float tmp;
if (x <= -1.999999936531045e-21f) {
tmp = t_0 + -1.0f;
} else if (x <= 2.00000009162741e-18f) {
tmp = 0.5f + ((x * 0.25f) / s);
} else {
tmp = t_0;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: tmp
t_0 = 1.0e0 + (s / x)
if (x <= (-1.999999936531045e-21)) then
tmp = t_0 + (-1.0e0)
else if (x <= 2.00000009162741e-18) then
tmp = 0.5e0 + ((x * 0.25e0) / s)
else
tmp = t_0
end if
code = tmp
end function
function code(x, s) t_0 = Float32(Float32(1.0) + Float32(s / x)) tmp = Float32(0.0) if (x <= Float32(-1.999999936531045e-21)) tmp = Float32(t_0 + Float32(-1.0)); elseif (x <= Float32(2.00000009162741e-18)) tmp = Float32(Float32(0.5) + Float32(Float32(x * Float32(0.25)) / s)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, s) t_0 = single(1.0) + (s / x); tmp = single(0.0); if (x <= single(-1.999999936531045e-21)) tmp = t_0 + single(-1.0); elseif (x <= single(2.00000009162741e-18)) tmp = single(0.5) + ((x * single(0.25)) / s); else tmp = t_0; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{s}{x}\\
\mathbf{if}\;x \leq -1.999999936531045 \cdot 10^{-21}:\\
\;\;\;\;t\_0 + -1\\
\mathbf{elif}\;x \leq 2.00000009162741 \cdot 10^{-18}:\\
\;\;\;\;0.5 + \frac{x \cdot 0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.9999999e-21Initial program 99.9%
Taylor expanded in x around 0 44.6%
mul-1-neg44.6%
unsub-neg44.6%
Simplified44.6%
Taylor expanded in x around inf 39.9%
associate-*r/39.9%
neg-mul-139.9%
Simplified39.9%
clear-num42.1%
associate-/r/39.9%
add-sqr-sqrt-0.0%
sqrt-unprod54.3%
sqr-neg54.3%
sqrt-unprod38.9%
add-sqr-sqrt38.9%
Applied egg-rr38.9%
associate-*l/38.9%
*-un-lft-identity38.9%
expm1-log1p-u38.8%
expm1-undefine89.3%
log1p-define89.3%
add-exp-log89.4%
Applied egg-rr89.4%
if -1.9999999e-21 < x < 2.00000009e-18Initial program 99.7%
Taylor expanded in x around 0 77.2%
associate-*r/77.2%
Simplified77.2%
if 2.00000009e-18 < x Initial program 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 98.5%
+-commutative98.5%
Simplified98.5%
frac-2neg98.5%
metadata-eval98.5%
div-inv98.5%
distribute-neg-in98.5%
distribute-frac-neg298.5%
add-sqr-sqrt-0.0%
sqrt-unprod98.5%
sqr-neg98.5%
sqrt-unprod98.5%
add-sqr-sqrt98.5%
metadata-eval98.5%
Applied egg-rr98.5%
mul-1-neg98.5%
distribute-neg-frac298.5%
+-commutative98.5%
distribute-neg-in98.5%
metadata-eval98.5%
sub-neg98.5%
Simplified98.5%
Taylor expanded in x around inf 96.9%
Final simplification89.5%
(FPCore (x s) :precision binary32 (if (<= x -1.999999936531045e-21) (+ (+ 1.0 (/ s x)) -1.0) (/ 1.0 (+ 1.0 (/ 1.0 (+ 1.0 (/ x s)))))))
float code(float x, float s) {
float tmp;
if (x <= -1.999999936531045e-21f) {
tmp = (1.0f + (s / x)) + -1.0f;
} else {
tmp = 1.0f / (1.0f + (1.0f / (1.0f + (x / s))));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-1.999999936531045e-21)) then
tmp = (1.0e0 + (s / x)) + (-1.0e0)
else
tmp = 1.0e0 / (1.0e0 + (1.0e0 / (1.0e0 + (x / s))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-1.999999936531045e-21)) tmp = Float32(Float32(Float32(1.0) + Float32(s / x)) + Float32(-1.0)); else tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(x / s))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-1.999999936531045e-21)) tmp = (single(1.0) + (s / x)) + single(-1.0); else tmp = single(1.0) / (single(1.0) + (single(1.0) / (single(1.0) + (x / s)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.999999936531045 \cdot 10^{-21}:\\
\;\;\;\;\left(1 + \frac{s}{x}\right) + -1\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + \frac{x}{s}}}\\
\end{array}
\end{array}
if x < -1.9999999e-21Initial program 99.9%
Taylor expanded in x around 0 44.6%
mul-1-neg44.6%
unsub-neg44.6%
Simplified44.6%
Taylor expanded in x around inf 39.9%
associate-*r/39.9%
neg-mul-139.9%
Simplified39.9%
clear-num42.1%
associate-/r/39.9%
add-sqr-sqrt-0.0%
sqrt-unprod54.3%
sqr-neg54.3%
sqrt-unprod38.9%
add-sqr-sqrt38.9%
Applied egg-rr38.9%
associate-*l/38.9%
*-un-lft-identity38.9%
expm1-log1p-u38.8%
expm1-undefine89.3%
log1p-define89.3%
add-exp-log89.4%
Applied egg-rr89.4%
if -1.9999999e-21 < x Initial program 99.9%
distribute-frac-neg99.9%
exp-neg99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 92.7%
+-commutative92.7%
Simplified92.7%
Final simplification91.4%
(FPCore (x s) :precision binary32 (if (<= x -0.03999999910593033) (/ s x) (if (<= x 5.000000229068525e-19) 0.5 (+ 1.0 (/ s x)))))
float code(float x, float s) {
float tmp;
if (x <= -0.03999999910593033f) {
tmp = s / x;
} else if (x <= 5.000000229068525e-19f) {
tmp = 0.5f;
} else {
tmp = 1.0f + (s / x);
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-0.03999999910593033e0)) then
tmp = s / x
else if (x <= 5.000000229068525e-19) then
tmp = 0.5e0
else
tmp = 1.0e0 + (s / x)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-0.03999999910593033)) tmp = Float32(s / x); elseif (x <= Float32(5.000000229068525e-19)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) + Float32(s / x)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-0.03999999910593033)) tmp = s / x; elseif (x <= single(5.000000229068525e-19)) tmp = single(0.5); else tmp = single(1.0) + (s / x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.03999999910593033:\\
\;\;\;\;\frac{s}{x}\\
\mathbf{elif}\;x \leq 5.000000229068525 \cdot 10^{-19}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{s}{x}\\
\end{array}
\end{array}
if x < -0.0399999991Initial program 100.0%
Taylor expanded in x around 0 50.9%
mul-1-neg50.9%
unsub-neg50.9%
Simplified50.9%
Taylor expanded in x around inf 48.1%
associate-*r/48.1%
neg-mul-148.1%
Simplified48.1%
clear-num50.9%
associate-/r/48.1%
add-sqr-sqrt-0.0%
sqrt-unprod58.4%
sqr-neg58.4%
sqrt-unprod48.1%
add-sqr-sqrt48.1%
Applied egg-rr48.1%
Taylor expanded in x around 0 48.1%
if -0.0399999991 < x < 5.00000023e-19Initial program 99.6%
Taylor expanded in x around 0 59.9%
if 5.00000023e-19 < x Initial program 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 98.2%
+-commutative98.2%
Simplified98.2%
frac-2neg98.2%
metadata-eval98.2%
div-inv98.2%
distribute-neg-in98.2%
distribute-frac-neg298.2%
add-sqr-sqrt-0.0%
sqrt-unprod98.0%
sqr-neg98.0%
sqrt-unprod97.9%
add-sqr-sqrt97.9%
metadata-eval97.9%
Applied egg-rr97.9%
mul-1-neg97.9%
distribute-neg-frac297.9%
+-commutative97.9%
distribute-neg-in97.9%
metadata-eval97.9%
sub-neg97.9%
Simplified97.9%
Taylor expanded in x around inf 96.0%
Final simplification70.4%
(FPCore (x s) :precision binary32 (if (<= x -0.03999999910593033) (/ 1.0 (/ x s)) (if (<= x 5.000000229068525e-19) 0.5 (+ 1.0 (/ s x)))))
float code(float x, float s) {
float tmp;
if (x <= -0.03999999910593033f) {
tmp = 1.0f / (x / s);
} else if (x <= 5.000000229068525e-19f) {
tmp = 0.5f;
} else {
tmp = 1.0f + (s / x);
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-0.03999999910593033e0)) then
tmp = 1.0e0 / (x / s)
else if (x <= 5.000000229068525e-19) then
tmp = 0.5e0
else
tmp = 1.0e0 + (s / x)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-0.03999999910593033)) tmp = Float32(Float32(1.0) / Float32(x / s)); elseif (x <= Float32(5.000000229068525e-19)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) + Float32(s / x)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-0.03999999910593033)) tmp = single(1.0) / (x / s); elseif (x <= single(5.000000229068525e-19)) tmp = single(0.5); else tmp = single(1.0) + (s / x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.03999999910593033:\\
\;\;\;\;\frac{1}{\frac{x}{s}}\\
\mathbf{elif}\;x \leq 5.000000229068525 \cdot 10^{-19}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{s}{x}\\
\end{array}
\end{array}
if x < -0.0399999991Initial program 100.0%
Taylor expanded in x around 0 50.9%
mul-1-neg50.9%
unsub-neg50.9%
Simplified50.9%
Taylor expanded in x around inf 48.1%
associate-*r/48.1%
neg-mul-148.1%
Simplified48.1%
clear-num50.9%
inv-pow50.9%
add-sqr-sqrt-0.0%
sqrt-unprod59.9%
sqr-neg59.9%
sqrt-unprod50.9%
add-sqr-sqrt50.9%
Applied egg-rr50.9%
unpow-150.9%
Simplified50.9%
if -0.0399999991 < x < 5.00000023e-19Initial program 99.6%
Taylor expanded in x around 0 59.9%
if 5.00000023e-19 < x Initial program 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 98.2%
+-commutative98.2%
Simplified98.2%
frac-2neg98.2%
metadata-eval98.2%
div-inv98.2%
distribute-neg-in98.2%
distribute-frac-neg298.2%
add-sqr-sqrt-0.0%
sqrt-unprod98.0%
sqr-neg98.0%
sqrt-unprod97.9%
add-sqr-sqrt97.9%
metadata-eval97.9%
Applied egg-rr97.9%
mul-1-neg97.9%
distribute-neg-frac297.9%
+-commutative97.9%
distribute-neg-in97.9%
metadata-eval97.9%
sub-neg97.9%
Simplified97.9%
Taylor expanded in x around inf 96.0%
Final simplification71.3%
(FPCore (x s) :precision binary32 (if (<= x -0.03999999910593033) (/ s x) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -0.03999999910593033f) {
tmp = s / 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 <= (-0.03999999910593033e0)) then
tmp = s / x
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-0.03999999910593033)) tmp = Float32(s / x); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-0.03999999910593033)) tmp = s / x; else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.03999999910593033:\\
\;\;\;\;\frac{s}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -0.0399999991Initial program 100.0%
Taylor expanded in x around 0 50.9%
mul-1-neg50.9%
unsub-neg50.9%
Simplified50.9%
Taylor expanded in x around inf 48.1%
associate-*r/48.1%
neg-mul-148.1%
Simplified48.1%
clear-num50.9%
associate-/r/48.1%
add-sqr-sqrt-0.0%
sqrt-unprod58.4%
sqr-neg58.4%
sqrt-unprod48.1%
add-sqr-sqrt48.1%
Applied egg-rr48.1%
Taylor expanded in x around 0 48.1%
if -0.0399999991 < x Initial program 99.8%
Taylor expanded in x around 0 43.0%
Final simplification44.5%
(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.9%
Taylor expanded in x around 0 32.0%
Final simplification32.0%
herbie shell --seed 2024096
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))