
(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(x / Float32(-s)))))) end
\begin{array}{l}
\\
e^{-\mathsf{log1p}\left(e^{\frac{x}{-s}}\right)}
\end{array}
Initial program 99.7%
div-inv99.7%
exp-prod83.1%
neg-mul-183.1%
exp-prod83.1%
pow-pow99.7%
div-inv99.7%
Applied egg-rr99.7%
Applied egg-rr99.8%
(FPCore (x s) :precision binary32 (/ 1.0 (+ (+ (expm1 (/ x (- s))) 1.0) 1.0)))
float code(float x, float s) {
return 1.0f / ((expm1f((x / -s)) + 1.0f) + 1.0f);
}
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(expm1(Float32(x / Float32(-s))) + Float32(1.0)) + Float32(1.0))) end
\begin{array}{l}
\\
\frac{1}{\left(\mathsf{expm1}\left(\frac{x}{-s}\right) + 1\right) + 1}
\end{array}
Initial program 99.7%
div-inv99.7%
exp-prod83.1%
neg-mul-183.1%
exp-prod83.1%
pow-pow99.7%
div-inv99.7%
Applied egg-rr99.7%
pow-exp99.7%
*-commutative99.7%
pow-exp99.7%
inv-pow99.7%
expm1-log1p-u99.7%
log1p-define99.7%
expm1-undefine99.7%
add-exp-log99.7%
rec-exp99.7%
distribute-neg-frac299.7%
Applied egg-rr99.7%
associate--l+99.7%
expm1-define99.8%
Simplified99.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(x / Float32(-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.7%
Final simplification99.7%
(FPCore (x s)
:precision binary32
(if (<= x -5.000000100204387e+20)
(/ 1.0 (/ x s))
(if (<= x 9.999999998199587e-24)
(/ 1.0 (/ (- 4.0 (* (/ x s) (/ x s))) (+ (/ x s) 2.0)))
1.0)))
float code(float x, float s) {
float tmp;
if (x <= -5.000000100204387e+20f) {
tmp = 1.0f / (x / s);
} else if (x <= 9.999999998199587e-24f) {
tmp = 1.0f / ((4.0f - ((x / s) * (x / s))) / ((x / s) + 2.0f));
} else {
tmp = 1.0f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-5.000000100204387e+20)) then
tmp = 1.0e0 / (x / s)
else if (x <= 9.999999998199587e-24) then
tmp = 1.0e0 / ((4.0e0 - ((x / s) * (x / s))) / ((x / s) + 2.0e0))
else
tmp = 1.0e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-5.000000100204387e+20)) tmp = Float32(Float32(1.0) / Float32(x / s)); elseif (x <= Float32(9.999999998199587e-24)) 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(1.0); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-5.000000100204387e+20)) tmp = single(1.0) / (x / s); elseif (x <= single(9.999999998199587e-24)) tmp = single(1.0) / ((single(4.0) - ((x / s) * (x / s))) / ((x / s) + single(2.0))); else tmp = single(1.0); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.000000100204387 \cdot 10^{+20}:\\
\;\;\;\;\frac{1}{\frac{x}{s}}\\
\mathbf{elif}\;x \leq 9.999999998199587 \cdot 10^{-24}:\\
\;\;\;\;\frac{1}{\frac{4 - \frac{x}{s} \cdot \frac{x}{s}}{\frac{x}{s} + 2}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -5.0000001e20Initial program 100.0%
Taylor expanded in x around 0 91.1%
neg-mul-191.1%
unsub-neg91.1%
Simplified91.1%
Taylor expanded in x around inf 84.3%
associate-*r/84.3%
neg-mul-184.3%
Simplified84.3%
clear-num91.1%
inv-pow91.1%
add-sqr-sqrt-0.0%
sqrt-unprod91.1%
sqr-neg91.1%
sqrt-unprod91.1%
add-sqr-sqrt91.1%
Applied egg-rr91.1%
unpow-191.1%
Simplified91.1%
if -5.0000001e20 < x < 1e-23Initial program 99.6%
Taylor expanded in x around 0 58.0%
neg-mul-158.0%
unsub-neg58.0%
Simplified58.0%
*-un-lft-identity58.0%
cancel-sign-sub-inv58.0%
metadata-eval58.0%
add-log-exp91.9%
pow-exp91.9%
flip-+50.0%
metadata-eval50.0%
pow-exp50.0%
add-log-exp50.0%
neg-mul-150.0%
pow-exp50.0%
add-log-exp50.6%
neg-mul-150.6%
distribute-neg-frac250.6%
distribute-neg-frac250.6%
pow-exp50.6%
Applied egg-rr71.6%
if 1e-23 < x Initial program 99.9%
distribute-frac-neg99.9%
exp-neg99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 92.1%
+-commutative92.1%
Simplified92.1%
expm1-log1p-u92.1%
log1p-define92.1%
expm1-undefine92.1%
Applied egg-rr91.4%
associate--l+91.4%
sub-neg91.4%
+-commutative91.4%
metadata-eval91.4%
Simplified91.4%
Taylor expanded in x around inf 94.9%
Final simplification82.3%
(FPCore (x s) :precision binary32 (if (<= x -9.999999974752427e-7) (/ 1.0 (/ x s)) (if (<= x 9.999999998199587e-24) (+ 0.5 (/ (* x 0.25) s)) 1.0)))
float code(float x, float s) {
float tmp;
if (x <= -9.999999974752427e-7f) {
tmp = 1.0f / (x / s);
} else if (x <= 9.999999998199587e-24f) {
tmp = 0.5f + ((x * 0.25f) / s);
} else {
tmp = 1.0f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-9.999999974752427e-7)) then
tmp = 1.0e0 / (x / s)
else if (x <= 9.999999998199587e-24) then
tmp = 0.5e0 + ((x * 0.25e0) / s)
else
tmp = 1.0e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-9.999999974752427e-7)) tmp = Float32(Float32(1.0) / Float32(x / s)); elseif (x <= Float32(9.999999998199587e-24)) tmp = Float32(Float32(0.5) + Float32(Float32(x * Float32(0.25)) / s)); else tmp = Float32(1.0); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-9.999999974752427e-7)) tmp = single(1.0) / (x / s); elseif (x <= single(9.999999998199587e-24)) tmp = single(0.5) + ((x * single(0.25)) / s); else tmp = single(1.0); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.999999974752427 \cdot 10^{-7}:\\
\;\;\;\;\frac{1}{\frac{x}{s}}\\
\mathbf{elif}\;x \leq 9.999999998199587 \cdot 10^{-24}:\\
\;\;\;\;0.5 + \frac{x \cdot 0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < -9.99999997e-7Initial program 100.0%
Taylor expanded in x around 0 48.7%
neg-mul-148.7%
unsub-neg48.7%
Simplified48.7%
Taylor expanded in x around inf 44.5%
associate-*r/44.5%
neg-mul-144.5%
Simplified44.5%
clear-num48.7%
inv-pow48.7%
add-sqr-sqrt-0.0%
sqrt-unprod63.9%
sqr-neg63.9%
sqrt-unprod48.7%
add-sqr-sqrt48.7%
Applied egg-rr48.7%
unpow-148.7%
Simplified48.7%
if -9.99999997e-7 < x < 1e-23Initial program 99.4%
Taylor expanded in x around 0 74.6%
associate-*r/74.6%
Simplified74.6%
if 1e-23 < x Initial program 99.9%
distribute-frac-neg99.9%
exp-neg99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 92.1%
+-commutative92.1%
Simplified92.1%
expm1-log1p-u92.1%
log1p-define92.1%
expm1-undefine92.1%
Applied egg-rr91.4%
associate--l+91.4%
sub-neg91.4%
+-commutative91.4%
metadata-eval91.4%
Simplified91.4%
Taylor expanded in x around inf 94.9%
Final simplification75.6%
(FPCore (x s) :precision binary32 (if (<= x -9.999999974752427e-7) (/ 1.0 (/ x s)) (if (<= x 9.999999998199587e-24) (+ 0.5 (/ (* x 0.25) s)) (+ (/ s x) 1.0))))
float code(float x, float s) {
float tmp;
if (x <= -9.999999974752427e-7f) {
tmp = 1.0f / (x / s);
} else if (x <= 9.999999998199587e-24f) {
tmp = 0.5f + ((x * 0.25f) / s);
} else {
tmp = (s / x) + 1.0f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-9.999999974752427e-7)) then
tmp = 1.0e0 / (x / s)
else if (x <= 9.999999998199587e-24) then
tmp = 0.5e0 + ((x * 0.25e0) / s)
else
tmp = (s / x) + 1.0e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-9.999999974752427e-7)) tmp = Float32(Float32(1.0) / Float32(x / s)); elseif (x <= Float32(9.999999998199587e-24)) tmp = Float32(Float32(0.5) + Float32(Float32(x * Float32(0.25)) / s)); else tmp = Float32(Float32(s / x) + Float32(1.0)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-9.999999974752427e-7)) tmp = single(1.0) / (x / s); elseif (x <= single(9.999999998199587e-24)) tmp = single(0.5) + ((x * single(0.25)) / s); else tmp = (s / x) + single(1.0); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.999999974752427 \cdot 10^{-7}:\\
\;\;\;\;\frac{1}{\frac{x}{s}}\\
\mathbf{elif}\;x \leq 9.999999998199587 \cdot 10^{-24}:\\
\;\;\;\;0.5 + \frac{x \cdot 0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{s}{x} + 1\\
\end{array}
\end{array}
if x < -9.99999997e-7Initial program 100.0%
Taylor expanded in x around 0 48.7%
neg-mul-148.7%
unsub-neg48.7%
Simplified48.7%
Taylor expanded in x around inf 44.5%
associate-*r/44.5%
neg-mul-144.5%
Simplified44.5%
clear-num48.7%
inv-pow48.7%
add-sqr-sqrt-0.0%
sqrt-unprod63.9%
sqr-neg63.9%
sqrt-unprod48.7%
add-sqr-sqrt48.7%
Applied egg-rr48.7%
unpow-148.7%
Simplified48.7%
if -9.99999997e-7 < x < 1e-23Initial program 99.4%
Taylor expanded in x around 0 74.6%
associate-*r/74.6%
Simplified74.6%
if 1e-23 < x Initial program 99.9%
distribute-frac-neg99.9%
exp-neg99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 92.1%
+-commutative92.1%
Simplified92.1%
expm1-log1p-u92.1%
log1p-define92.1%
expm1-undefine92.1%
Applied egg-rr91.4%
associate--l+91.4%
sub-neg91.4%
+-commutative91.4%
metadata-eval91.4%
Simplified91.4%
Taylor expanded in x around inf 90.3%
Final simplification73.9%
(FPCore (x s) :precision binary32 (if (<= x -9.999999974752427e-7) (/ 1.0 (/ x s)) (if (<= x 9.999999998199587e-24) 0.5 (+ (/ s x) 1.0))))
float code(float x, float s) {
float tmp;
if (x <= -9.999999974752427e-7f) {
tmp = 1.0f / (x / s);
} else if (x <= 9.999999998199587e-24f) {
tmp = 0.5f;
} else {
tmp = (s / x) + 1.0f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-9.999999974752427e-7)) then
tmp = 1.0e0 / (x / s)
else if (x <= 9.999999998199587e-24) then
tmp = 0.5e0
else
tmp = (s / x) + 1.0e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-9.999999974752427e-7)) tmp = Float32(Float32(1.0) / Float32(x / s)); elseif (x <= Float32(9.999999998199587e-24)) tmp = Float32(0.5); else tmp = Float32(Float32(s / x) + Float32(1.0)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-9.999999974752427e-7)) tmp = single(1.0) / (x / s); elseif (x <= single(9.999999998199587e-24)) tmp = single(0.5); else tmp = (s / x) + single(1.0); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.999999974752427 \cdot 10^{-7}:\\
\;\;\;\;\frac{1}{\frac{x}{s}}\\
\mathbf{elif}\;x \leq 9.999999998199587 \cdot 10^{-24}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{s}{x} + 1\\
\end{array}
\end{array}
if x < -9.99999997e-7Initial program 100.0%
Taylor expanded in x around 0 48.7%
neg-mul-148.7%
unsub-neg48.7%
Simplified48.7%
Taylor expanded in x around inf 44.5%
associate-*r/44.5%
neg-mul-144.5%
Simplified44.5%
clear-num48.7%
inv-pow48.7%
add-sqr-sqrt-0.0%
sqrt-unprod63.9%
sqr-neg63.9%
sqrt-unprod48.7%
add-sqr-sqrt48.7%
Applied egg-rr48.7%
unpow-148.7%
Simplified48.7%
if -9.99999997e-7 < x < 1e-23Initial program 99.4%
Taylor expanded in x around 0 71.0%
if 1e-23 < x Initial program 99.9%
distribute-frac-neg99.9%
exp-neg99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 92.1%
+-commutative92.1%
Simplified92.1%
expm1-log1p-u92.1%
log1p-define92.1%
expm1-undefine92.1%
Applied egg-rr91.4%
associate--l+91.4%
sub-neg91.4%
+-commutative91.4%
metadata-eval91.4%
Simplified91.4%
Taylor expanded in x around inf 90.3%
Final simplification72.6%
(FPCore (x s) :precision binary32 (if (<= x -9.999999974752427e-7) (* s (/ 1.0 x)) (if (<= x 9.999999998199587e-24) 0.5 (+ (/ s x) 1.0))))
float code(float x, float s) {
float tmp;
if (x <= -9.999999974752427e-7f) {
tmp = s * (1.0f / x);
} else if (x <= 9.999999998199587e-24f) {
tmp = 0.5f;
} else {
tmp = (s / x) + 1.0f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-9.999999974752427e-7)) then
tmp = s * (1.0e0 / x)
else if (x <= 9.999999998199587e-24) then
tmp = 0.5e0
else
tmp = (s / x) + 1.0e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-9.999999974752427e-7)) tmp = Float32(s * Float32(Float32(1.0) / x)); elseif (x <= Float32(9.999999998199587e-24)) tmp = Float32(0.5); else tmp = Float32(Float32(s / x) + Float32(1.0)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-9.999999974752427e-7)) tmp = s * (single(1.0) / x); elseif (x <= single(9.999999998199587e-24)) tmp = single(0.5); else tmp = (s / x) + single(1.0); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.999999974752427 \cdot 10^{-7}:\\
\;\;\;\;s \cdot \frac{1}{x}\\
\mathbf{elif}\;x \leq 9.999999998199587 \cdot 10^{-24}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{s}{x} + 1\\
\end{array}
\end{array}
if x < -9.99999997e-7Initial program 100.0%
Taylor expanded in x around 0 48.7%
neg-mul-148.7%
unsub-neg48.7%
Simplified48.7%
Taylor expanded in x around inf 44.5%
associate-*r/44.5%
neg-mul-144.5%
Simplified44.5%
clear-num48.7%
associate-/r/44.5%
add-sqr-sqrt-0.0%
sqrt-unprod61.5%
sqr-neg61.5%
sqrt-unprod44.5%
add-sqr-sqrt44.5%
Applied egg-rr44.5%
if -9.99999997e-7 < x < 1e-23Initial program 99.4%
Taylor expanded in x around 0 71.0%
if 1e-23 < x Initial program 99.9%
distribute-frac-neg99.9%
exp-neg99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 92.1%
+-commutative92.1%
Simplified92.1%
expm1-log1p-u92.1%
log1p-define92.1%
expm1-undefine92.1%
Applied egg-rr91.4%
associate--l+91.4%
sub-neg91.4%
+-commutative91.4%
metadata-eval91.4%
Simplified91.4%
Taylor expanded in x around inf 90.3%
Final simplification71.5%
(FPCore (x s) :precision binary32 (if (<= x 9.999999998199587e-24) (/ 1.0 (- 2.0 (/ x s))) 1.0))
float code(float x, float s) {
float tmp;
if (x <= 9.999999998199587e-24f) {
tmp = 1.0f / (2.0f - (x / s));
} else {
tmp = 1.0f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 9.999999998199587e-24) then
tmp = 1.0e0 / (2.0e0 - (x / s))
else
tmp = 1.0e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(9.999999998199587e-24)) tmp = Float32(Float32(1.0) / Float32(Float32(2.0) - Float32(x / s))); else tmp = Float32(1.0); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(9.999999998199587e-24)) tmp = single(1.0) / (single(2.0) - (x / s)); else tmp = single(1.0); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.999999998199587 \cdot 10^{-24}:\\
\;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
\mathbf{else}:\\
\;\;\;\;1\\
\end{array}
\end{array}
if x < 1e-23Initial program 99.7%
Taylor expanded in x around 0 63.2%
neg-mul-163.2%
unsub-neg63.2%
Simplified63.2%
if 1e-23 < x Initial program 99.9%
distribute-frac-neg99.9%
exp-neg99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 92.1%
+-commutative92.1%
Simplified92.1%
expm1-log1p-u92.1%
log1p-define92.1%
expm1-undefine92.1%
Applied egg-rr91.4%
associate--l+91.4%
sub-neg91.4%
+-commutative91.4%
metadata-eval91.4%
Simplified91.4%
Taylor expanded in x around inf 94.9%
Final simplification75.2%
(FPCore (x s) :precision binary32 (if (<= x -9.999999974752427e-7) (* s (/ 1.0 x)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -9.999999974752427e-7f) {
tmp = s * (1.0f / 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 <= (-9.999999974752427e-7)) then
tmp = s * (1.0e0 / x)
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-9.999999974752427e-7)) tmp = Float32(s * Float32(Float32(1.0) / x)); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-9.999999974752427e-7)) tmp = s * (single(1.0) / x); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.999999974752427 \cdot 10^{-7}:\\
\;\;\;\;s \cdot \frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -9.99999997e-7Initial program 100.0%
Taylor expanded in x around 0 48.7%
neg-mul-148.7%
unsub-neg48.7%
Simplified48.7%
Taylor expanded in x around inf 44.5%
associate-*r/44.5%
neg-mul-144.5%
Simplified44.5%
clear-num48.7%
associate-/r/44.5%
add-sqr-sqrt-0.0%
sqrt-unprod61.5%
sqr-neg61.5%
sqrt-unprod44.5%
add-sqr-sqrt44.5%
Applied egg-rr44.5%
if -9.99999997e-7 < x Initial program 99.6%
Taylor expanded in x around 0 49.8%
Final simplification48.4%
(FPCore (x s) :precision binary32 (if (<= x -9.999999974752427e-7) (/ s x) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -9.999999974752427e-7f) {
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 <= (-9.999999974752427e-7)) 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(-9.999999974752427e-7)) 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(-9.999999974752427e-7)) tmp = s / x; else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.999999974752427 \cdot 10^{-7}:\\
\;\;\;\;\frac{s}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -9.99999997e-7Initial program 100.0%
Taylor expanded in x around 0 48.7%
neg-mul-148.7%
unsub-neg48.7%
Simplified48.7%
Taylor expanded in x around inf 44.5%
associate-*r/44.5%
neg-mul-144.5%
Simplified44.5%
neg-sub044.5%
sub-neg44.5%
add-sqr-sqrt-0.0%
sqrt-unprod61.5%
sqr-neg61.5%
sqrt-unprod44.5%
add-sqr-sqrt44.5%
Applied egg-rr44.5%
+-lft-identity44.5%
Simplified44.5%
if -9.99999997e-7 < x Initial program 99.6%
Taylor expanded in x around 0 49.8%
(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 38.6%
herbie shell --seed 2024170
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))