
(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 14 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 (/ 1.0 (+ (* (exp (* (/ x s) -0.6666666666666666)) (pow (cbrt (exp -1.0)) (/ x s))) 1.0)))
float code(float x, float s) {
return 1.0f / ((expf(((x / s) * -0.6666666666666666f)) * powf(cbrtf(expf(-1.0f)), (x / s))) + 1.0f);
}
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(exp(Float32(Float32(x / s) * Float32(-0.6666666666666666))) * (cbrt(exp(Float32(-1.0))) ^ Float32(x / s))) + Float32(1.0))) end
\begin{array}{l}
\\
\frac{1}{e^{\frac{x}{s} \cdot -0.6666666666666666} \cdot {\left(\sqrt[3]{e^{-1}}\right)}^{\left(\frac{x}{s}\right)} + 1}
\end{array}
Initial program 99.8%
*-un-lft-identity99.8%
exp-prod99.9%
distribute-frac-neg99.9%
neg-mul-199.9%
add-sqr-sqrt49.6%
sqrt-unprod60.3%
sqr-neg60.3%
sqrt-unprod12.5%
add-sqr-sqrt27.4%
pow-unpow27.4%
add-sqr-sqrt12.5%
sqrt-unprod60.3%
sqr-neg60.3%
sqrt-unprod49.6%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
add-cube-cbrt99.7%
unpow-prod-down99.8%
cbrt-unprod99.8%
pow-exp99.8%
metadata-eval99.8%
pow-exp99.8%
metadata-eval99.8%
prod-exp99.8%
metadata-eval99.8%
pow-exp99.8%
metadata-eval99.8%
Applied egg-rr99.8%
add-exp-log99.9%
log-pow99.8%
pow1/399.8%
log-pow99.9%
rem-log-exp99.9%
metadata-eval99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x s) :precision binary32 (/ 1.0 (+ (pow (exp -0.5) (/ (* x 2.0) s)) 1.0)))
float code(float x, float s) {
return 1.0f / (powf(expf(-0.5f), ((x * 2.0f) / s)) + 1.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / ((exp((-0.5e0)) ** ((x * 2.0e0) / s)) + 1.0e0)
end function
function code(x, s) return Float32(Float32(1.0) / Float32((exp(Float32(-0.5)) ^ Float32(Float32(x * Float32(2.0)) / s)) + Float32(1.0))) end
function tmp = code(x, s) tmp = single(1.0) / ((exp(single(-0.5)) ^ ((x * single(2.0)) / s)) + single(1.0)); end
\begin{array}{l}
\\
\frac{1}{{\left(e^{-0.5}\right)}^{\left(\frac{x \cdot 2}{s}\right)} + 1}
\end{array}
Initial program 99.8%
*-un-lft-identity99.8%
exp-prod99.9%
distribute-frac-neg99.9%
neg-mul-199.9%
add-sqr-sqrt49.6%
sqrt-unprod60.3%
sqr-neg60.3%
sqrt-unprod12.5%
add-sqr-sqrt27.4%
pow-unpow27.4%
add-sqr-sqrt12.5%
sqrt-unprod60.3%
sqr-neg60.3%
sqrt-unprod49.6%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
add-sqr-sqrt99.9%
unpow-prod-down99.8%
sqrt-pow199.8%
pow-to-exp99.8%
rem-log-exp99.8%
metadata-eval99.8%
metadata-eval99.8%
sqrt-pow199.8%
pow-to-exp99.8%
rem-log-exp99.8%
metadata-eval99.8%
metadata-eval99.8%
Applied egg-rr99.8%
pow-sqr99.9%
*-commutative99.9%
associate-*l/99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x s) :precision binary32 (/ 1.0 (+ (pow (pow E -1.0) (/ x s)) 1.0)))
float code(float x, float s) {
return 1.0f / (powf(powf(((float) M_E), -1.0f), (x / s)) + 1.0f);
}
function code(x, s) return Float32(Float32(1.0) / Float32(((Float32(exp(1)) ^ Float32(-1.0)) ^ Float32(x / s)) + Float32(1.0))) end
function tmp = code(x, s) tmp = single(1.0) / (((single(2.71828182845904523536) ^ 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%
*-un-lft-identity99.8%
exp-prod99.9%
distribute-frac-neg99.9%
neg-mul-199.9%
add-sqr-sqrt49.6%
sqrt-unprod60.3%
sqr-neg60.3%
sqrt-unprod12.5%
add-sqr-sqrt27.4%
pow-unpow27.4%
add-sqr-sqrt12.5%
sqrt-unprod60.3%
sqr-neg60.3%
sqrt-unprod49.6%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
Final simplification99.9%
(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.8%
Final simplification99.8%
(FPCore (x s)
:precision binary32
(let* ((t_0 (/ x (- s))))
(if (<= t_0 -1.0)
0.5
(if (<= t_0 INFINITY)
(/ 1.0 (/ (- 4.0 (/ x (* s (/ s x)))) (+ (/ x s) 2.0)))
(/ 1.0 (/ x s))))))
float code(float x, float s) {
float t_0 = x / -s;
float tmp;
if (t_0 <= -1.0f) {
tmp = 0.5f;
} else if (t_0 <= ((float) INFINITY)) {
tmp = 1.0f / ((4.0f - (x / (s * (s / x)))) / ((x / s) + 2.0f));
} else {
tmp = 1.0f / (x / s);
}
return tmp;
}
function code(x, s) t_0 = Float32(x / Float32(-s)) tmp = Float32(0.0) if (t_0 <= Float32(-1.0)) tmp = Float32(0.5); elseif (t_0 <= Float32(Inf)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(4.0) - Float32(x / Float32(s * Float32(s / x)))) / Float32(Float32(x / s) + Float32(2.0)))); else tmp = Float32(Float32(1.0) / Float32(x / s)); end return tmp end
function tmp_2 = code(x, s) t_0 = x / -s; tmp = single(0.0); if (t_0 <= single(-1.0)) tmp = single(0.5); elseif (t_0 <= single(Inf)) tmp = single(1.0) / ((single(4.0) - (x / (s * (s / x)))) / ((x / s) + single(2.0))); else tmp = single(1.0) / (x / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{-s}\\
\mathbf{if}\;t\_0 \leq -1:\\
\;\;\;\;0.5\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{1}{\frac{4 - \frac{x}{s \cdot \frac{s}{x}}}{\frac{x}{s} + 2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -1Initial program 100.0%
Taylor expanded in x around 0 28.2%
if -1 < (/.f32 (neg.f32 x) s) < +inf.0Initial program 99.8%
Taylor expanded in x around 0 59.5%
mul-1-neg59.5%
unsub-neg59.5%
Simplified59.5%
sub-neg59.5%
neg-mul-159.5%
add-log-exp96.9%
pow-exp96.9%
metadata-eval96.9%
pow-exp96.9%
flip-+37.6%
Applied egg-rr56.4%
distribute-frac-neg256.4%
distribute-frac-neg256.4%
sqr-neg56.4%
clear-num56.4%
frac-times58.6%
*-un-lft-identity58.6%
Applied egg-rr58.6%
if +inf.0 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0 40.6%
mul-1-neg40.6%
unsub-neg40.6%
Simplified40.6%
Taylor expanded in x around inf 17.7%
associate-*r/17.7%
neg-mul-117.7%
Simplified17.7%
inv-pow17.7%
distribute-frac-neg17.7%
distribute-frac-neg217.7%
add-sqr-sqrt-0.0%
sqrt-unprod27.5%
sqr-neg27.5%
sqrt-unprod20.0%
add-sqr-sqrt20.0%
Applied egg-rr20.0%
unpow-120.0%
Simplified20.0%
Final simplification48.0%
(FPCore (x s)
:precision binary32
(let* ((t_0 (/ x (- s))))
(if (<= t_0 0.5)
0.5
(if (<= t_0 INFINITY)
(/ -1.0 (/ (- (* (/ x s) (/ x s)) 4.0) (/ x s)))
(/ 1.0 (/ x s))))))
float code(float x, float s) {
float t_0 = x / -s;
float tmp;
if (t_0 <= 0.5f) {
tmp = 0.5f;
} else if (t_0 <= ((float) INFINITY)) {
tmp = -1.0f / ((((x / s) * (x / s)) - 4.0f) / (x / s));
} else {
tmp = 1.0f / (x / s);
}
return tmp;
}
function code(x, s) t_0 = Float32(x / Float32(-s)) tmp = Float32(0.0) if (t_0 <= Float32(0.5)) tmp = Float32(0.5); elseif (t_0 <= Float32(Inf)) tmp = Float32(Float32(-1.0) / Float32(Float32(Float32(Float32(x / s) * Float32(x / s)) - Float32(4.0)) / Float32(x / s))); else tmp = Float32(Float32(1.0) / Float32(x / s)); end return tmp end
function tmp_2 = code(x, s) t_0 = x / -s; tmp = single(0.0); if (t_0 <= single(0.5)) tmp = single(0.5); elseif (t_0 <= single(Inf)) tmp = single(-1.0) / ((((x / s) * (x / s)) - single(4.0)) / (x / s)); else tmp = single(1.0) / (x / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{-s}\\
\mathbf{if}\;t\_0 \leq 0.5:\\
\;\;\;\;0.5\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{-1}{\frac{\frac{x}{s} \cdot \frac{x}{s} - 4}{\frac{x}{s}}}\\
\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 54.2%
if 0.5 < (/.f32 (neg.f32 x) s) < +inf.0Initial program 99.8%
Taylor expanded in x around 0 36.2%
mul-1-neg36.2%
unsub-neg36.2%
Simplified36.2%
sub-neg36.2%
neg-mul-136.2%
add-log-exp97.5%
pow-exp97.5%
metadata-eval97.5%
pow-exp97.5%
flip-+0.5%
Applied egg-rr31.1%
Taylor expanded in x around inf 31.1%
if +inf.0 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0 40.6%
mul-1-neg40.6%
unsub-neg40.6%
Simplified40.6%
Taylor expanded in x around inf 17.7%
associate-*r/17.7%
neg-mul-117.7%
Simplified17.7%
inv-pow17.7%
distribute-frac-neg17.7%
distribute-frac-neg217.7%
add-sqr-sqrt-0.0%
sqrt-unprod27.5%
sqr-neg27.5%
sqrt-unprod20.0%
add-sqr-sqrt20.0%
Applied egg-rr20.0%
unpow-120.0%
Simplified20.0%
Final simplification45.0%
(FPCore (x s) :precision binary32 (if (<= (/ x (- s)) -1.0) 0.5 (/ 1.0 (+ -1.0 (- 3.0 (/ x s))))))
float code(float x, float s) {
float tmp;
if ((x / -s) <= -1.0f) {
tmp = 0.5f;
} else {
tmp = 1.0f / (-1.0f + (3.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) <= (-1.0e0)) then
tmp = 0.5e0
else
tmp = 1.0e0 / ((-1.0e0) + (3.0e0 - (x / s)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(x / Float32(-s)) <= Float32(-1.0)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(Float32(-1.0) + Float32(Float32(3.0) - Float32(x / s)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((x / -s) <= single(-1.0)) tmp = single(0.5); else tmp = single(1.0) / (single(-1.0) + (single(3.0) - (x / s))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{x}{-s} \leq -1:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{-1 + \left(3 - \frac{x}{s}\right)}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -1Initial program 100.0%
Taylor expanded in x around 0 28.2%
if -1 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0 59.5%
mul-1-neg59.5%
unsub-neg59.5%
Simplified59.5%
expm1-log1p-u59.4%
Applied egg-rr59.4%
expm1-undefine59.4%
sub-neg59.4%
log1p-undefine59.4%
rem-exp-log59.5%
associate-+r-59.5%
metadata-eval59.5%
metadata-eval59.5%
Simplified59.5%
Final simplification48.6%
(FPCore (x s) :precision binary32 (if (<= (/ x (- s)) -1.0) 0.5 (/ 1.0 (- 2.0 (/ x s)))))
float code(float x, float s) {
float tmp;
if ((x / -s) <= -1.0f) {
tmp = 0.5f;
} 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) <= (-1.0e0)) then
tmp = 0.5e0
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(-1.0)) tmp = Float32(0.5); 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(-1.0)) tmp = single(0.5); 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 -1:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -1Initial program 100.0%
Taylor expanded in x around 0 28.2%
if -1 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0 59.5%
mul-1-neg59.5%
unsub-neg59.5%
Simplified59.5%
Final simplification48.6%
(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(x / Float32(-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 54.2%
if 0.5 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0 36.2%
mul-1-neg36.2%
unsub-neg36.2%
Simplified36.2%
Taylor expanded in x around inf 36.2%
associate-*r/36.2%
neg-mul-136.2%
Simplified36.2%
Final simplification47.0%
(FPCore (x s) :precision binary32 (if (<= x -1.0000000116860974e-7) (* s (/ -1.0 x)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.0000000116860974e-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 <= (-1.0000000116860974e-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(-1.0000000116860974e-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(-1.0000000116860974e-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 -1.0000000116860974 \cdot 10^{-7}:\\
\;\;\;\;s \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.00000001e-7Initial program 99.8%
Taylor expanded in x around 0 44.7%
mul-1-neg44.7%
unsub-neg44.7%
Simplified44.7%
Taylor expanded in x around inf 44.7%
associate-*r/44.7%
neg-mul-144.7%
Simplified44.7%
associate-/r/40.8%
frac-2neg40.8%
metadata-eval40.8%
remove-double-neg40.8%
Applied egg-rr40.8%
if -1.00000001e-7 < x Initial program 99.8%
Taylor expanded in x around 0 47.9%
Final simplification45.7%
(FPCore (x s) :precision binary32 (if (<= x -1.500000053056283e-7) (/ 1.0 (/ x s)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.500000053056283e-7f) {
tmp = 1.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 <= (-1.500000053056283e-7)) then
tmp = 1.0e0 / (x / s)
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-1.500000053056283e-7)) tmp = Float32(Float32(1.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(-1.500000053056283e-7)) tmp = single(1.0) / (x / s); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.500000053056283 \cdot 10^{-7}:\\
\;\;\;\;\frac{1}{\frac{x}{s}}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.5000001e-7Initial program 100.0%
Taylor expanded in x around 0 45.1%
mul-1-neg45.1%
unsub-neg45.1%
Simplified45.1%
Taylor expanded in x around inf 45.1%
associate-*r/45.1%
neg-mul-145.1%
Simplified45.1%
inv-pow45.1%
distribute-frac-neg45.1%
distribute-frac-neg245.1%
add-sqr-sqrt-0.0%
sqrt-unprod51.8%
sqr-neg51.8%
sqrt-unprod45.1%
add-sqr-sqrt45.1%
Applied egg-rr45.1%
unpow-145.1%
Simplified45.1%
if -1.5000001e-7 < x Initial program 99.8%
Taylor expanded in x around 0 47.7%
Final simplification46.9%
(FPCore (x s) :precision binary32 (if (<= x -1.0000000116860974e-7) (/ s (- x)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.0000000116860974e-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 <= (-1.0000000116860974e-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(-1.0000000116860974e-7)) 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(-1.0000000116860974e-7)) tmp = s / -x; else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.0000000116860974 \cdot 10^{-7}:\\
\;\;\;\;\frac{s}{-x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.00000001e-7Initial program 99.8%
Taylor expanded in x around 0 44.7%
mul-1-neg44.7%
unsub-neg44.7%
Simplified44.7%
Taylor expanded in x around inf 40.8%
associate-*r/40.8%
neg-mul-140.8%
Simplified40.8%
if -1.00000001e-7 < x Initial program 99.8%
Taylor expanded in x around 0 47.9%
Final simplification45.7%
(FPCore (x s) :precision binary32 (if (<= x -1.500000053056283e-7) (/ s x) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.500000053056283e-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 <= (-1.500000053056283e-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(-1.500000053056283e-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(-1.500000053056283e-7)) tmp = s / x; else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.500000053056283 \cdot 10^{-7}:\\
\;\;\;\;\frac{s}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.5000001e-7Initial program 100.0%
Taylor expanded in x around 0 45.1%
mul-1-neg45.1%
unsub-neg45.1%
Simplified45.1%
Taylor expanded in x around inf 45.1%
associate-*r/45.1%
neg-mul-145.1%
Simplified45.1%
clear-num41.2%
add-sqr-sqrt41.2%
sqrt-unprod55.9%
sqr-neg55.9%
sqrt-unprod-0.0%
add-sqr-sqrt41.2%
*-un-lft-identity41.2%
Applied egg-rr41.2%
*-lft-identity41.2%
Simplified41.2%
if -1.5000001e-7 < x Initial program 99.8%
Taylor expanded in x around 0 47.7%
Final simplification45.7%
(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 35.2%
Final simplification35.2%
herbie shell --seed 2024053
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))