
(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.8%
div-inv99.7%
exp-prod85.4%
neg-mul-185.4%
exp-prod85.4%
pow-pow99.7%
div-inv99.8%
Applied egg-rr99.8%
add-exp-log99.7%
log-rec99.7%
log1p-expm1-u99.7%
log1p-define99.7%
pow-exp99.8%
expm1-log1p-u99.8%
neg-mul-199.8%
distribute-neg-frac299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x s) :precision binary32 (/ 1.0 (+ (pow (exp -1.0) (/ x s)) 1.0)))
float code(float x, float s) {
return 1.0f / (powf(expf(-1.0f), (x / s)) + 1.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / ((exp((-1.0e0)) ** (x / s)) + 1.0e0)
end function
function code(x, s) return Float32(Float32(1.0) / Float32((exp(Float32(-1.0)) ^ Float32(x / s)) + Float32(1.0))) end
function tmp = code(x, s) tmp = single(1.0) / ((exp(single(-1.0)) ^ (x / s)) + single(1.0)); end
\begin{array}{l}
\\
\frac{1}{{\left(e^{-1}\right)}^{\left(\frac{x}{s}\right)} + 1}
\end{array}
Initial program 99.8%
div-inv99.7%
exp-prod85.4%
neg-mul-185.4%
exp-prod85.4%
pow-pow99.7%
div-inv99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x s) :precision binary32 (/ 1.0 (+ (exp (/ (- x) s)) 1.0)))
float code(float x, float s) {
return 1.0f / (expf((-x / s)) + 1.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (exp((-x / s)) + 1.0e0)
end function
function code(x, s) return Float32(Float32(1.0) / Float32(exp(Float32(Float32(-x) / s)) + Float32(1.0))) end
function tmp = code(x, s) tmp = single(1.0) / (exp((-x / s)) + single(1.0)); end
\begin{array}{l}
\\
\frac{1}{e^{\frac{-x}{s}} + 1}
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x s)
:precision binary32
(let* ((t_0 (/ (- x) s)))
(if (<= t_0 -50.0)
(/ 1.0 (* x (/ 2.0 x)))
(if (<= t_0 4.999999840142846e+37)
(/ 1.0 (/ (- 4.0 (* (/ x s) (/ x s))) (+ (/ x s) 2.0)))
(/ -1.0 (* x (- (/ -1.0 s) (+ (/ 1.0 s) (+ (/ 2.0 x) (/ 1.0 s))))))))))
float code(float x, float s) {
float t_0 = -x / s;
float tmp;
if (t_0 <= -50.0f) {
tmp = 1.0f / (x * (2.0f / x));
} else if (t_0 <= 4.999999840142846e+37f) {
tmp = 1.0f / ((4.0f - ((x / s) * (x / s))) / ((x / s) + 2.0f));
} else {
tmp = -1.0f / (x * ((-1.0f / s) - ((1.0f / s) + ((2.0f / x) + (1.0f / s)))));
}
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 = -x / s
if (t_0 <= (-50.0e0)) then
tmp = 1.0e0 / (x * (2.0e0 / x))
else if (t_0 <= 4.999999840142846e+37) then
tmp = 1.0e0 / ((4.0e0 - ((x / s) * (x / s))) / ((x / s) + 2.0e0))
else
tmp = (-1.0e0) / (x * (((-1.0e0) / s) - ((1.0e0 / s) + ((2.0e0 / x) + (1.0e0 / s)))))
end if
code = tmp
end function
function code(x, s) t_0 = Float32(Float32(-x) / s) tmp = Float32(0.0) if (t_0 <= Float32(-50.0)) tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(2.0) / x))); elseif (t_0 <= Float32(4.999999840142846e+37)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(4.0) - Float32(Float32(x / s) * Float32(x / s))) / Float32(Float32(x / s) + Float32(2.0)))); else tmp = Float32(Float32(-1.0) / Float32(x * Float32(Float32(Float32(-1.0) / s) - Float32(Float32(Float32(1.0) / s) + Float32(Float32(Float32(2.0) / x) + Float32(Float32(1.0) / s)))))); end return tmp end
function tmp_2 = code(x, s) t_0 = -x / s; tmp = single(0.0); if (t_0 <= single(-50.0)) tmp = single(1.0) / (x * (single(2.0) / x)); elseif (t_0 <= single(4.999999840142846e+37)) tmp = single(1.0) / ((single(4.0) - ((x / s) * (x / s))) / ((x / s) + single(2.0))); else tmp = single(-1.0) / (x * ((single(-1.0) / s) - ((single(1.0) / s) + ((single(2.0) / x) + (single(1.0) / s))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-x}{s}\\
\mathbf{if}\;t\_0 \leq -50:\\
\;\;\;\;\frac{1}{x \cdot \frac{2}{x}}\\
\mathbf{elif}\;t\_0 \leq 4.999999840142846 \cdot 10^{+37}:\\
\;\;\;\;\frac{1}{\frac{4 - \frac{x}{s} \cdot \frac{x}{s}}{\frac{x}{s} + 2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{x \cdot \left(\frac{-1}{s} - \left(\frac{1}{s} + \left(\frac{2}{x} + \frac{1}{s}\right)\right)\right)}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -50Initial program 100.0%
Taylor expanded in x around 0 5.3%
mul-1-neg5.3%
unsub-neg5.3%
Simplified5.3%
Taylor expanded in x around inf 5.3%
associate-*r/5.3%
metadata-eval5.3%
Simplified5.3%
Taylor expanded in x around 0 28.1%
if -50 < (/.f32 (neg.f32 x) s) < 4.99999984e37Initial program 99.5%
Taylor expanded in x around 0 51.8%
mul-1-neg51.8%
unsub-neg51.8%
Simplified51.8%
sub-neg51.8%
neg-mul-151.8%
rem-log-exp92.2%
pow-exp92.2%
flip-+46.6%
metadata-eval46.6%
pow-exp46.6%
rem-log-exp46.6%
neg-mul-146.6%
pow-exp46.6%
rem-log-exp47.2%
neg-mul-147.2%
distribute-neg-frac247.2%
distribute-neg-frac247.2%
pow-exp47.2%
rem-log-exp76.3%
neg-mul-176.3%
distribute-neg-frac276.3%
Applied egg-rr76.3%
if 4.99999984e37 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in x around 0 97.6%
mul-1-neg97.6%
unsub-neg97.6%
Simplified97.6%
Taylor expanded in x around inf 97.6%
associate-*r/97.6%
metadata-eval97.6%
Simplified97.6%
add-sqr-sqrt-0.0%
*-un-lft-identity-0.0%
prod-diff-0.0%
associate-/r/-0.0%
clear-num-0.0%
fma-define-0.0%
add-sqr-sqrt97.6%
distribute-frac-neg297.6%
add-sqr-sqrt-0.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod97.6%
add-sqr-sqrt97.6%
/-rgt-identity97.6%
clear-num97.6%
Applied egg-rr100.0%
+-commutative100.0%
fma-undefine100.0%
*-rgt-identity100.0%
associate-+l+100.0%
+-commutative100.0%
Simplified100.0%
Final simplification59.9%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) -50.0) (/ 1.0 (* x (/ 2.0 x))) (/ -1.0 (/ -1.0 (/ s (- (* s 2.0) x))))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= -50.0f) {
tmp = 1.0f / (x * (2.0f / x));
} else {
tmp = -1.0f / (-1.0f / (s / ((s * 2.0f) - x)));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((-x / s) <= (-50.0e0)) then
tmp = 1.0e0 / (x * (2.0e0 / x))
else
tmp = (-1.0e0) / ((-1.0e0) / (s / ((s * 2.0e0) - x)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(-x) / s) <= Float32(-50.0)) tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(2.0) / x))); else tmp = Float32(Float32(-1.0) / Float32(Float32(-1.0) / Float32(s / Float32(Float32(s * Float32(2.0)) - x)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(-50.0)) tmp = single(1.0) / (x * (single(2.0) / x)); else tmp = single(-1.0) / (single(-1.0) / (s / ((s * single(2.0)) - x))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq -50:\\
\;\;\;\;\frac{1}{x \cdot \frac{2}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{-1}{\frac{s}{s \cdot 2 - x}}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -50Initial program 100.0%
Taylor expanded in x around 0 5.3%
mul-1-neg5.3%
unsub-neg5.3%
Simplified5.3%
Taylor expanded in x around inf 5.3%
associate-*r/5.3%
metadata-eval5.3%
Simplified5.3%
Taylor expanded in x around 0 28.1%
if -50 < (/.f32 (neg.f32 x) s) Initial program 99.6%
Taylor expanded in x around 0 60.1%
mul-1-neg60.1%
unsub-neg60.1%
Simplified60.1%
Taylor expanded in x around inf 59.5%
associate-*r/59.5%
metadata-eval59.5%
Simplified59.5%
frac-sub47.1%
associate-*r/50.4%
*-commutative50.4%
*-rgt-identity50.4%
Applied egg-rr50.4%
*-commutative50.4%
associate-/l*47.0%
*-commutative47.0%
Simplified47.0%
associate-*r/50.4%
*-commutative50.4%
*-commutative50.4%
times-frac60.1%
*-inverses60.1%
metadata-eval60.1%
div-inv60.1%
clear-num60.1%
clear-num60.1%
Applied egg-rr60.1%
Final simplification47.5%
(FPCore (x s) :precision binary32 (if (<= (- x) 4.9999998413276127e-20) 0.5 (* (* x s) (/ (/ 1.0 x) (- (* s 2.0) x)))))
float code(float x, float s) {
float tmp;
if (-x <= 4.9999998413276127e-20f) {
tmp = 0.5f;
} else {
tmp = (x * s) * ((1.0f / x) / ((s * 2.0f) - x));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (-x <= 4.9999998413276127e-20) then
tmp = 0.5e0
else
tmp = (x * s) * ((1.0e0 / x) / ((s * 2.0e0) - x))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(4.9999998413276127e-20)) tmp = Float32(0.5); else tmp = Float32(Float32(x * s) * Float32(Float32(Float32(1.0) / x) / Float32(Float32(s * Float32(2.0)) - x))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-x <= single(4.9999998413276127e-20)) tmp = single(0.5); else tmp = (x * s) * ((single(1.0) / x) / ((s * single(2.0)) - x)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq 4.9999998413276127 \cdot 10^{-20}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot s\right) \cdot \frac{\frac{1}{x}}{s \cdot 2 - x}\\
\end{array}
\end{array}
if (neg.f32 x) < 4.99999984e-20Initial program 99.8%
Taylor expanded in x around 0 48.4%
if 4.99999984e-20 < (neg.f32 x) Initial program 99.7%
Taylor expanded in x around 0 42.0%
mul-1-neg42.0%
unsub-neg42.0%
Simplified42.0%
Taylor expanded in x around inf 42.0%
associate-*r/42.0%
metadata-eval42.0%
Simplified42.0%
associate-/r*37.8%
frac-sub39.8%
associate-/r/47.1%
*-commutative47.1%
*-rgt-identity47.1%
Applied egg-rr47.1%
Final simplification47.9%
(FPCore (x s) :precision binary32 (if (<= (- x) 4.999999999099794e-24) 0.5 (/ -1.0 (/ (* x (- x (* s 2.0))) (* x s)))))
float code(float x, float s) {
float tmp;
if (-x <= 4.999999999099794e-24f) {
tmp = 0.5f;
} else {
tmp = -1.0f / ((x * (x - (s * 2.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 <= 4.999999999099794e-24) then
tmp = 0.5e0
else
tmp = (-1.0e0) / ((x * (x - (s * 2.0e0))) / (x * s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(4.999999999099794e-24)) tmp = Float32(0.5); else tmp = Float32(Float32(-1.0) / Float32(Float32(x * Float32(x - Float32(s * Float32(2.0)))) / Float32(x * s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-x <= single(4.999999999099794e-24)) tmp = single(0.5); else tmp = single(-1.0) / ((x * (x - (s * single(2.0)))) / (x * s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq 4.999999999099794 \cdot 10^{-24}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{x \cdot \left(x - s \cdot 2\right)}{x \cdot s}}\\
\end{array}
\end{array}
if (neg.f32 x) < 5e-24Initial program 99.8%
Taylor expanded in x around 0 48.0%
if 5e-24 < (neg.f32 x) Initial program 99.7%
Taylor expanded in x around 0 42.7%
mul-1-neg42.7%
unsub-neg42.7%
Simplified42.7%
Taylor expanded in x around inf 42.7%
associate-*r/42.7%
metadata-eval42.7%
Simplified42.7%
*-commutative42.7%
frac-sub44.7%
associate-*l/53.9%
*-commutative53.9%
*-rgt-identity53.9%
Applied egg-rr53.9%
Final simplification50.1%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) -50.0) (/ 1.0 (* x (/ 2.0 x))) (/ -1.0 (/ (- x (* s 2.0)) s))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= -50.0f) {
tmp = 1.0f / (x * (2.0f / x));
} else {
tmp = -1.0f / ((x - (s * 2.0f)) / s);
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((-x / s) <= (-50.0e0)) then
tmp = 1.0e0 / (x * (2.0e0 / x))
else
tmp = (-1.0e0) / ((x - (s * 2.0e0)) / s)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(-x) / s) <= Float32(-50.0)) tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(2.0) / x))); else tmp = Float32(Float32(-1.0) / Float32(Float32(x - Float32(s * Float32(2.0))) / s)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(-50.0)) tmp = single(1.0) / (x * (single(2.0) / x)); else tmp = single(-1.0) / ((x - (s * single(2.0))) / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq -50:\\
\;\;\;\;\frac{1}{x \cdot \frac{2}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{x - s \cdot 2}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -50Initial program 100.0%
Taylor expanded in x around 0 5.3%
mul-1-neg5.3%
unsub-neg5.3%
Simplified5.3%
Taylor expanded in x around inf 5.3%
associate-*r/5.3%
metadata-eval5.3%
Simplified5.3%
Taylor expanded in x around 0 28.1%
if -50 < (/.f32 (neg.f32 x) s) Initial program 99.6%
Taylor expanded in x around 0 60.1%
mul-1-neg60.1%
unsub-neg60.1%
Simplified60.1%
Taylor expanded in s around 0 60.1%
*-commutative60.1%
Simplified60.1%
Final simplification47.5%
(FPCore (x s) :precision binary32 (if (<= (/ x (- s)) -50.0) (/ 1.0 (* x (/ 2.0 x))) (/ 1.0 (- 2.0 (/ x s)))))
float code(float x, float s) {
float tmp;
if ((x / -s) <= -50.0f) {
tmp = 1.0f / (x * (2.0f / x));
} else {
tmp = 1.0f / (2.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 / -s) <= (-50.0e0)) then
tmp = 1.0e0 / (x * (2.0e0 / x))
else
tmp = 1.0e0 / (2.0e0 - (x / s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(x / Float32(-s)) <= Float32(-50.0)) tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(2.0) / x))); else tmp = Float32(Float32(1.0) / Float32(Float32(2.0) - Float32(x / s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((x / -s) <= single(-50.0)) tmp = single(1.0) / (x * (single(2.0) / x)); else tmp = single(1.0) / (single(2.0) - (x / s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{-s} \leq -50:\\
\;\;\;\;\frac{1}{x \cdot \frac{2}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -50Initial program 100.0%
Taylor expanded in x around 0 5.3%
mul-1-neg5.3%
unsub-neg5.3%
Simplified5.3%
Taylor expanded in x around inf 5.3%
associate-*r/5.3%
metadata-eval5.3%
Simplified5.3%
Taylor expanded in x around 0 28.1%
if -50 < (/.f32 (neg.f32 x) s) Initial program 99.6%
Taylor expanded in x around 0 60.1%
mul-1-neg60.1%
unsub-neg60.1%
Simplified60.1%
Final simplification47.5%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) 0.5) 0.5 (/ -1.0 (/ x s))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= 0.5f) {
tmp = 0.5f;
} else {
tmp = -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 / s) <= 0.5e0) then
tmp = 0.5e0
else
tmp = (-1.0e0) / (x / s)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(-x) / s) <= Float32(0.5)) tmp = Float32(0.5); else tmp = Float32(Float32(-1.0) / Float32(x / s)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(0.5)) tmp = single(0.5); else tmp = single(-1.0) / (x / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq 0.5:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{x}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 0.5Initial program 99.9%
Taylor expanded in x around 0 50.1%
if 0.5 < (/.f32 (neg.f32 x) s) Initial program 99.5%
Taylor expanded in x around 0 38.1%
mul-1-neg38.1%
unsub-neg38.1%
Simplified38.1%
Taylor expanded in x around inf 38.0%
mul-1-neg38.0%
distribute-frac-neg238.0%
Simplified38.0%
Final simplification45.7%
(FPCore (x s) :precision binary32 (if (<= x -0.00019999999494757503) (/ s (- x)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -0.00019999999494757503f) {
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.00019999999494757503e0)) 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.00019999999494757503)) tmp = Float32(s / Float32(-x)); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-0.00019999999494757503)) tmp = s / -x; else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.00019999999494757503:\\
\;\;\;\;\frac{s}{-x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.99999995e-4Initial program 100.0%
Taylor expanded in x around 0 48.4%
mul-1-neg48.4%
unsub-neg48.4%
Simplified48.4%
Taylor expanded in x around inf 42.7%
associate-*r/42.7%
neg-mul-142.7%
Simplified42.7%
if -1.99999995e-4 < x Initial program 99.7%
Taylor expanded in x around 0 44.6%
Final simplification44.1%
(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.8%
Taylor expanded in x around 0 34.6%
Final simplification34.6%
herbie shell --seed 2024076
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))