
(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.8%
div-inv99.8%
exp-prod83.7%
neg-mul-183.7%
exp-prod83.7%
pow-pow99.8%
div-inv99.8%
Applied egg-rr99.8%
add-exp-log99.8%
log-rec99.8%
log1p-expm1-u99.8%
log1p-define99.8%
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.8%
exp-prod83.7%
neg-mul-183.7%
exp-prod83.7%
pow-pow99.8%
div-inv99.8%
Applied egg-rr99.8%
Final simplification99.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.8%
div-inv99.8%
exp-prod83.7%
neg-mul-183.7%
exp-prod83.7%
pow-pow99.8%
div-inv99.8%
Applied egg-rr99.8%
add-cube-cbrt99.6%
unpow-prod-down99.7%
cbrt-unprod99.8%
prod-exp99.8%
metadata-eval99.8%
Applied egg-rr99.8%
expm1-log1p-u99.7%
log1p-define99.7%
expm1-undefine99.7%
add-exp-log99.8%
pow-prod-down99.8%
metadata-eval99.8%
prod-exp99.8%
cbrt-unprod99.6%
add-cube-cbrt99.8%
Applied egg-rr99.8%
associate--l+99.8%
exp-prod99.8%
*-commutative99.8%
expm1-define99.8%
*-commutative99.8%
mul-1-neg99.8%
distribute-frac-neg299.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.8%
Final simplification99.8%
(FPCore (x s)
:precision binary32
(if (<= (- x) -6.000000019026461e-30)
0.5
(if (<= (- x) 1999999968613499000.0)
(/ 1.0 (/ (- 4.0 (/ (/ x s) (/ s x))) (+ (/ x s) 2.0)))
(/ 1.0 (/ -1.0 (/ s (- x (* s 2.0))))))))
float code(float x, float s) {
float tmp;
if (-x <= -6.000000019026461e-30f) {
tmp = 0.5f;
} else if (-x <= 1999999968613499000.0f) {
tmp = 1.0f / ((4.0f - ((x / s) / (s / x))) / ((x / s) + 2.0f));
} else {
tmp = 1.0f / (-1.0f / (s / (x - (s * 2.0f))));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (-x <= (-6.000000019026461e-30)) then
tmp = 0.5e0
else if (-x <= 1999999968613499000.0e0) then
tmp = 1.0e0 / ((4.0e0 - ((x / s) / (s / x))) / ((x / s) + 2.0e0))
else
tmp = 1.0e0 / ((-1.0e0) / (s / (x - (s * 2.0e0))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(-6.000000019026461e-30)) tmp = Float32(0.5); elseif (Float32(-x) <= Float32(1999999968613499000.0)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(4.0) - Float32(Float32(x / s) / Float32(s / x))) / Float32(Float32(x / s) + Float32(2.0)))); else tmp = Float32(Float32(1.0) / Float32(Float32(-1.0) / Float32(s / Float32(x - Float32(s * Float32(2.0)))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-x <= single(-6.000000019026461e-30)) tmp = single(0.5); elseif (-x <= single(1999999968613499000.0)) tmp = single(1.0) / ((single(4.0) - ((x / s) / (s / x))) / ((x / s) + single(2.0))); else tmp = single(1.0) / (single(-1.0) / (s / (x - (s * single(2.0))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq -6.000000019026461 \cdot 10^{-30}:\\
\;\;\;\;0.5\\
\mathbf{elif}\;-x \leq 1999999968613499000:\\
\;\;\;\;\frac{1}{\frac{4 - \frac{\frac{x}{s}}{\frac{s}{x}}}{\frac{x}{s} + 2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{-1}{\frac{s}{x - s \cdot 2}}}\\
\end{array}
\end{array}
if (neg.f32 x) < -6e-30Initial program 99.9%
Taylor expanded in x around 0 38.1%
if -6e-30 < (neg.f32 x) < 1.99999997e18Initial program 99.5%
Taylor expanded in x around 0 43.3%
mul-1-neg43.3%
unsub-neg43.3%
Simplified43.3%
sub-neg43.3%
neg-mul-143.3%
rem-log-exp94.3%
pow-exp94.3%
flip-+31.9%
metadata-eval31.9%
pow-exp31.9%
rem-log-exp31.9%
neg-mul-131.9%
pow-exp31.9%
rem-log-exp33.1%
neg-mul-133.1%
distribute-neg-frac233.1%
distribute-neg-frac233.1%
pow-exp33.1%
rem-log-exp52.8%
neg-mul-152.8%
distribute-neg-frac252.8%
Applied egg-rr52.8%
associate-*l/52.8%
add-sqr-sqrt-0.0%
sqrt-unprod57.8%
sqr-neg57.8%
sqrt-unprod52.3%
add-sqr-sqrt52.3%
remove-double-neg52.3%
distribute-neg-frac252.3%
associate-*l/52.3%
distribute-lft-neg-in52.3%
clear-num52.3%
un-div-inv52.3%
distribute-frac-neg252.3%
remove-double-neg52.3%
add-sqr-sqrt-0.0%
sqrt-unprod58.1%
sqr-neg58.1%
sqrt-unprod52.8%
add-sqr-sqrt52.8%
Applied egg-rr52.8%
Taylor expanded in x around 0 52.8%
if 1.99999997e18 < (neg.f32 x) Initial program 100.0%
Taylor expanded in x around 0 82.6%
mul-1-neg82.6%
unsub-neg82.6%
Simplified82.6%
Taylor expanded in s around 0 82.6%
*-commutative82.6%
Simplified82.6%
clear-num82.6%
inv-pow82.6%
Applied egg-rr82.6%
unpow-182.6%
Simplified82.6%
Final simplification48.8%
(FPCore (x s)
:precision binary32
(if (<= (- x) -6.000000019026461e-30)
0.5
(if (<= (- x) 1999999968613499000.0)
(/ 1.0 (/ (- 4.0 (* x (/ (/ x s) s))) (+ (/ x s) 2.0)))
(/ 1.0 (/ -1.0 (/ s (- x (* s 2.0))))))))
float code(float x, float s) {
float tmp;
if (-x <= -6.000000019026461e-30f) {
tmp = 0.5f;
} else if (-x <= 1999999968613499000.0f) {
tmp = 1.0f / ((4.0f - (x * ((x / s) / s))) / ((x / s) + 2.0f));
} else {
tmp = 1.0f / (-1.0f / (s / (x - (s * 2.0f))));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (-x <= (-6.000000019026461e-30)) then
tmp = 0.5e0
else if (-x <= 1999999968613499000.0e0) then
tmp = 1.0e0 / ((4.0e0 - (x * ((x / s) / s))) / ((x / s) + 2.0e0))
else
tmp = 1.0e0 / ((-1.0e0) / (s / (x - (s * 2.0e0))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(-6.000000019026461e-30)) tmp = Float32(0.5); elseif (Float32(-x) <= Float32(1999999968613499000.0)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(4.0) - Float32(x * Float32(Float32(x / s) / s))) / Float32(Float32(x / s) + Float32(2.0)))); else tmp = Float32(Float32(1.0) / Float32(Float32(-1.0) / Float32(s / Float32(x - Float32(s * Float32(2.0)))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-x <= single(-6.000000019026461e-30)) tmp = single(0.5); elseif (-x <= single(1999999968613499000.0)) tmp = single(1.0) / ((single(4.0) - (x * ((x / s) / s))) / ((x / s) + single(2.0))); else tmp = single(1.0) / (single(-1.0) / (s / (x - (s * single(2.0))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq -6.000000019026461 \cdot 10^{-30}:\\
\;\;\;\;0.5\\
\mathbf{elif}\;-x \leq 1999999968613499000:\\
\;\;\;\;\frac{1}{\frac{4 - x \cdot \frac{\frac{x}{s}}{s}}{\frac{x}{s} + 2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{-1}{\frac{s}{x - s \cdot 2}}}\\
\end{array}
\end{array}
if (neg.f32 x) < -6e-30Initial program 99.9%
Taylor expanded in x around 0 38.1%
if -6e-30 < (neg.f32 x) < 1.99999997e18Initial program 99.5%
Taylor expanded in x around 0 43.3%
mul-1-neg43.3%
unsub-neg43.3%
Simplified43.3%
sub-neg43.3%
neg-mul-143.3%
rem-log-exp94.3%
pow-exp94.3%
flip-+31.9%
metadata-eval31.9%
pow-exp31.9%
rem-log-exp31.9%
neg-mul-131.9%
pow-exp31.9%
rem-log-exp33.1%
neg-mul-133.1%
distribute-neg-frac233.1%
distribute-neg-frac233.1%
pow-exp33.1%
rem-log-exp52.8%
neg-mul-152.8%
distribute-neg-frac252.8%
Applied egg-rr52.8%
associate-*l/52.8%
add-sqr-sqrt-0.0%
sqrt-unprod57.8%
sqr-neg57.8%
sqrt-unprod52.3%
add-sqr-sqrt52.3%
remove-double-neg52.3%
distribute-neg-frac252.3%
associate-*l/52.3%
distribute-lft-neg-in52.3%
clear-num52.3%
un-div-inv52.3%
distribute-frac-neg252.3%
remove-double-neg52.3%
add-sqr-sqrt-0.0%
sqrt-unprod58.1%
sqr-neg58.1%
sqrt-unprod52.8%
add-sqr-sqrt52.8%
Applied egg-rr52.8%
associate-/r/60.0%
Applied egg-rr60.0%
if 1.99999997e18 < (neg.f32 x) Initial program 100.0%
Taylor expanded in x around 0 82.6%
mul-1-neg82.6%
unsub-neg82.6%
Simplified82.6%
Taylor expanded in s around 0 82.6%
*-commutative82.6%
Simplified82.6%
clear-num82.6%
inv-pow82.6%
Applied egg-rr82.6%
unpow-182.6%
Simplified82.6%
Final simplification51.6%
(FPCore (x s) :precision binary32 (if (<= (- x) -6.000000019026461e-30) 0.5 (/ 1.0 (- 2.0 (/ x s)))))
float code(float x, float s) {
float tmp;
if (-x <= -6.000000019026461e-30f) {
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 <= (-6.000000019026461e-30)) 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(-6.000000019026461e-30)) 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 <= single(-6.000000019026461e-30)) 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}\;-x \leq -6.000000019026461 \cdot 10^{-30}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
\end{array}
\end{array}
if (neg.f32 x) < -6e-30Initial program 99.9%
Taylor expanded in x around 0 38.1%
if -6e-30 < (neg.f32 x) Initial program 99.6%
Taylor expanded in x around 0 51.8%
mul-1-neg51.8%
unsub-neg51.8%
Simplified51.8%
Final simplification45.0%
(FPCore (x s) :precision binary32 (if (<= (- x) 4.999999858590343e-10) 0.5 (/ 1.0 (/ x s))))
float code(float x, float s) {
float tmp;
if (-x <= 4.999999858590343e-10f) {
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 <= 4.999999858590343e-10) 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(4.999999858590343e-10)) 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 <= single(4.999999858590343e-10)) tmp = single(0.5); else tmp = single(1.0) / (x / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq 4.999999858590343 \cdot 10^{-10}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x}{s}}\\
\end{array}
\end{array}
if (neg.f32 x) < 4.99999986e-10Initial program 99.7%
Taylor expanded in x around 0 45.0%
if 4.99999986e-10 < (neg.f32 x) Initial program 99.8%
Taylor expanded in x around 0 42.8%
mul-1-neg42.8%
unsub-neg42.8%
Simplified42.8%
sub-neg42.8%
neg-mul-142.8%
rem-log-exp97.9%
pow-exp97.9%
flip-+0.4%
metadata-eval0.4%
pow-exp0.4%
rem-log-exp0.4%
neg-mul-10.4%
pow-exp0.4%
rem-log-exp1.4%
neg-mul-11.4%
distribute-neg-frac21.4%
distribute-neg-frac21.4%
pow-exp1.4%
rem-log-exp32.1%
neg-mul-132.1%
distribute-neg-frac232.1%
Applied egg-rr32.1%
sub-neg32.1%
distribute-frac-neg232.1%
remove-double-neg32.1%
add-sqr-sqrt32.1%
sqrt-unprod21.9%
sqr-neg21.9%
sqrt-unprod-0.0%
add-sqr-sqrt31.8%
flip-+2.7%
metadata-eval2.7%
clear-num2.7%
clear-num2.7%
metadata-eval2.7%
flip-+31.8%
Applied egg-rr31.8%
Taylor expanded in x around inf 42.5%
Final simplification44.2%
(FPCore (x s) :precision binary32 (if (<= (- x) 4.999999858590343e-10) 0.5 (/ -1.0 (/ x s))))
float code(float x, float s) {
float tmp;
if (-x <= 4.999999858590343e-10f) {
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 <= 4.999999858590343e-10) 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(4.999999858590343e-10)) 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 <= single(4.999999858590343e-10)) tmp = single(0.5); else tmp = single(-1.0) / (x / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq 4.999999858590343 \cdot 10^{-10}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{x}{s}}\\
\end{array}
\end{array}
if (neg.f32 x) < 4.99999986e-10Initial program 99.7%
Taylor expanded in x around 0 45.0%
if 4.99999986e-10 < (neg.f32 x) Initial program 99.8%
Taylor expanded in x around 0 42.8%
mul-1-neg42.8%
unsub-neg42.8%
Simplified42.8%
Taylor expanded in x around inf 42.8%
mul-1-neg42.8%
distribute-frac-neg242.8%
Simplified42.8%
Final simplification44.3%
(FPCore (x s) :precision binary32 (if (<= x -9.999999717180685e-10) (/ s (- x)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -9.999999717180685e-10f) {
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.999999717180685e-10)) 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.999999717180685e-10)) 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(-9.999999717180685e-10)) tmp = s / -x; else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.999999717180685 \cdot 10^{-10}:\\
\;\;\;\;\frac{s}{-x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -9.99999972e-10Initial program 99.8%
Taylor expanded in x around 0 42.8%
mul-1-neg42.8%
unsub-neg42.8%
Simplified42.8%
Taylor expanded in x around inf 39.1%
associate-*r/39.1%
neg-mul-139.1%
Simplified39.1%
if -9.99999972e-10 < x Initial program 99.7%
Taylor expanded in x around 0 45.0%
Final simplification43.2%
(FPCore (x s) :precision binary32 (if (<= x -9.999999717180685e-10) (/ s x) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -9.999999717180685e-10f) {
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.999999717180685e-10)) 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.999999717180685e-10)) 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.999999717180685e-10)) tmp = s / x; else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.999999717180685 \cdot 10^{-10}:\\
\;\;\;\;\frac{s}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -9.99999972e-10Initial program 99.8%
Taylor expanded in x around 0 42.8%
mul-1-neg42.8%
unsub-neg42.8%
Simplified42.8%
Taylor expanded in x around inf 42.8%
mul-1-neg42.8%
distribute-frac-neg242.8%
Simplified42.8%
clear-num39.1%
div-inv39.1%
add-sqr-sqrt-0.0%
sqrt-unprod51.3%
sqr-neg51.3%
sqrt-unprod38.8%
add-sqr-sqrt38.8%
Applied egg-rr38.8%
associate-*r/38.8%
*-rgt-identity38.8%
Simplified38.8%
if -9.99999972e-10 < x Initial program 99.7%
Taylor expanded in x around 0 45.0%
Final simplification43.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 33.1%
Final simplification33.1%
herbie shell --seed 2024059
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))