
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (- (fabs x)) s))) (t_1 (+ 1.0 t_0))) (/ t_0 (* (* s t_1) t_1))))
float code(float x, float s) {
float t_0 = expf((-fabsf(x) / s));
float t_1 = 1.0f + t_0;
return t_0 / ((s * t_1) * t_1);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: t_1
t_0 = exp((-abs(x) / s))
t_1 = 1.0e0 + t_0
code = t_0 / ((s * t_1) * t_1)
end function
function code(x, s) t_0 = exp(Float32(Float32(-abs(x)) / s)) t_1 = Float32(Float32(1.0) + t_0) return Float32(t_0 / Float32(Float32(s * t_1) * t_1)) end
function tmp = code(x, s) t_0 = exp((-abs(x) / s)); t_1 = single(1.0) + t_0; tmp = t_0 / ((s * t_1) * t_1); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
t_1 := 1 + t\_0\\
\frac{t\_0}{\left(s \cdot t\_1\right) \cdot t\_1}
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (- (fabs x)) s))) (t_1 (+ 1.0 t_0))) (/ t_0 (* (* s t_1) t_1))))
float code(float x, float s) {
float t_0 = expf((-fabsf(x) / s));
float t_1 = 1.0f + t_0;
return t_0 / ((s * t_1) * t_1);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: t_1
t_0 = exp((-abs(x) / s))
t_1 = 1.0e0 + t_0
code = t_0 / ((s * t_1) * t_1)
end function
function code(x, s) t_0 = exp(Float32(Float32(-abs(x)) / s)) t_1 = Float32(Float32(1.0) + t_0) return Float32(t_0 / Float32(Float32(s * t_1) * t_1)) end
function tmp = code(x, s) t_0 = exp((-abs(x) / s)); t_1 = single(1.0) + t_0; tmp = t_0 / ((s * t_1) * t_1); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
t_1 := 1 + t\_0\\
\frac{t\_0}{\left(s \cdot t\_1\right) \cdot t\_1}
\end{array}
\end{array}
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (- (fabs x)) s)))) (/ t_0 (* (+ t_0 1.0) (fma s t_0 s)))))
float code(float x, float s) {
float t_0 = expf((-fabsf(x) / s));
return t_0 / ((t_0 + 1.0f) * fmaf(s, t_0, s));
}
function code(x, s) t_0 = exp(Float32(Float32(-abs(x)) / s)) return Float32(t_0 / Float32(Float32(t_0 + Float32(1.0)) * fma(s, t_0, s))) end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
\frac{t\_0}{\left(t\_0 + 1\right) \cdot \mathsf{fma}\left(s, t\_0, s\right)}
\end{array}
\end{array}
Initial program 99.7%
*-commutative99.7%
distribute-lft-in99.8%
*-rgt-identity99.8%
fabs-neg99.8%
+-commutative99.8%
fma-define99.8%
fabs-neg99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (- (fabs x)) s)))) (/ t_0 (* (+ t_0 1.0) (+ s (/ s (exp (/ (fabs x) s))))))))
float code(float x, float s) {
float t_0 = expf((-fabsf(x) / s));
return t_0 / ((t_0 + 1.0f) * (s + (s / expf((fabsf(x) / s)))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
t_0 = exp((-abs(x) / s))
code = t_0 / ((t_0 + 1.0e0) * (s + (s / exp((abs(x) / s)))))
end function
function code(x, s) t_0 = exp(Float32(Float32(-abs(x)) / s)) return Float32(t_0 / Float32(Float32(t_0 + Float32(1.0)) * Float32(s + Float32(s / exp(Float32(abs(x) / s)))))) end
function tmp = code(x, s) t_0 = exp((-abs(x) / s)); tmp = t_0 / ((t_0 + single(1.0)) * (s + (s / exp((abs(x) / s))))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
\frac{t\_0}{\left(t\_0 + 1\right) \cdot \left(s + \frac{s}{e^{\frac{\left|x\right|}{s}}}\right)}
\end{array}
\end{array}
Initial program 99.7%
*-commutative99.7%
fabs-neg99.7%
distribute-lft-in99.8%
*-rgt-identity99.8%
fabs-neg99.8%
distribute-rgt-in99.8%
cancel-sign-sub99.8%
Simplified99.7%
Final simplification99.7%
(FPCore (x s)
:precision binary32
(let* ((t_0 (exp (/ x s))))
(if (<= (fabs x) 0.0020000000949949026)
(/ (exp (- (/ x s) (* 2.0 (log1p t_0)))) s)
(/ (exp (/ x (- s))) (* s (pow (+ 1.0 t_0) 2.0))))))
float code(float x, float s) {
float t_0 = expf((x / s));
float tmp;
if (fabsf(x) <= 0.0020000000949949026f) {
tmp = expf(((x / s) - (2.0f * log1pf(t_0)))) / s;
} else {
tmp = expf((x / -s)) / (s * powf((1.0f + t_0), 2.0f));
}
return tmp;
}
function code(x, s) t_0 = exp(Float32(x / s)) tmp = Float32(0.0) if (abs(x) <= Float32(0.0020000000949949026)) tmp = Float32(exp(Float32(Float32(x / s) - Float32(Float32(2.0) * log1p(t_0)))) / s); else tmp = Float32(exp(Float32(x / Float32(-s))) / Float32(s * (Float32(Float32(1.0) + t_0) ^ Float32(2.0)))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{x}{s}}\\
\mathbf{if}\;\left|x\right| \leq 0.0020000000949949026:\\
\;\;\;\;\frac{e^{\frac{x}{s} - 2 \cdot \mathsf{log1p}\left(t\_0\right)}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\frac{x}{-s}}}{s \cdot {\left(1 + t\_0\right)}^{2}}\\
\end{array}
\end{array}
if (fabs.f32 x) < 0.00200000009Initial program 99.5%
*-commutative99.5%
Simplified99.5%
associate-/r*99.5%
+-commutative99.5%
distribute-lft-in99.5%
*-rgt-identity99.5%
fma-undefine99.5%
associate-/r*99.5%
div-inv99.5%
Applied egg-rr77.8%
associate-*r/77.8%
*-rgt-identity77.8%
associate-/r*77.8%
+-commutative77.8%
Simplified77.8%
+-commutative77.8%
associate-/r*77.8%
add-exp-log74.5%
log-div74.2%
add-log-exp95.0%
+-commutative95.0%
log-prod94.2%
+-commutative94.2%
log-pow94.9%
+-commutative94.9%
log1p-define94.8%
Applied egg-rr94.8%
Taylor expanded in x around inf 94.9%
+-commutative94.9%
associate--r+95.1%
exp-diff95.1%
log1p-define95.1%
rem-exp-log99.5%
Simplified99.5%
if 0.00200000009 < (fabs.f32 x) Initial program 100.0%
*-commutative100.0%
Simplified100.0%
Applied egg-rr59.3%
unpow-159.3%
*-commutative59.3%
associate-/r*59.3%
rec-exp59.3%
distribute-neg-frac259.3%
+-commutative59.3%
Simplified59.3%
(FPCore (x s) :precision binary32 (if (<= x 10.0) (/ (exp (- (/ x s) (* 2.0 (log1p (exp (/ x s)))))) s) (/ s (pow (exp x) s))))
float code(float x, float s) {
float tmp;
if (x <= 10.0f) {
tmp = expf(((x / s) - (2.0f * log1pf(expf((x / s)))))) / s;
} else {
tmp = s / powf(expf(x), s);
}
return tmp;
}
function code(x, s) tmp = Float32(0.0) if (x <= Float32(10.0)) tmp = Float32(exp(Float32(Float32(x / s) - Float32(Float32(2.0) * log1p(exp(Float32(x / s)))))) / s); else tmp = Float32(s / (exp(x) ^ s)); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 10:\\
\;\;\;\;\frac{e^{\frac{x}{s} - 2 \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right)}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{s}{{\left(e^{x}\right)}^{s}}\\
\end{array}
\end{array}
if x < 10Initial program 99.6%
*-commutative99.6%
Simplified99.6%
associate-/r*99.6%
+-commutative99.6%
distribute-lft-in99.6%
*-rgt-identity99.6%
fma-undefine99.7%
associate-/r*99.7%
div-inv99.7%
Applied egg-rr81.0%
associate-*r/81.0%
*-rgt-identity81.0%
associate-/r*81.0%
+-commutative81.0%
Simplified81.0%
+-commutative81.0%
associate-/r*81.0%
add-exp-log78.8%
log-div78.6%
add-log-exp96.7%
+-commutative96.7%
log-prod96.2%
+-commutative96.2%
log-pow96.6%
+-commutative96.6%
log1p-define96.5%
Applied egg-rr96.5%
Taylor expanded in x around inf 96.6%
+-commutative96.6%
associate--r+96.8%
exp-diff96.8%
log1p-define96.8%
rem-exp-log99.7%
Simplified99.7%
if 10 < x Initial program 100.0%
*-commutative100.0%
Simplified100.0%
associate-/r*100.0%
+-commutative100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
fma-undefine100.0%
associate-/r*100.0%
div-inv98.5%
Applied egg-rr-0.0%
associate-*r/-0.0%
*-rgt-identity-0.0%
associate-/r*-0.0%
+-commutative-0.0%
Simplified-0.0%
+-commutative-0.0%
associate-/r*-0.0%
add-exp-log-0.0%
log-div-0.0%
add-log-exp48.5%
+-commutative48.5%
log-prod48.5%
+-commutative48.5%
log-pow48.5%
+-commutative48.5%
log1p-define48.5%
Applied egg-rr48.5%
Applied egg-rr98.9%
(FPCore (x s) :precision binary32 (if (<= x 100.0) (* (+ 0.5 (* x (/ 0.25 s))) (/ (/ 1.0 s) (+ 1.0 (exp (/ x s))))) (/ s (pow (exp x) s))))
float code(float x, float s) {
float tmp;
if (x <= 100.0f) {
tmp = (0.5f + (x * (0.25f / s))) * ((1.0f / s) / (1.0f + expf((x / s))));
} else {
tmp = s / powf(expf(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 <= 100.0e0) then
tmp = (0.5e0 + (x * (0.25e0 / s))) * ((1.0e0 / s) / (1.0e0 + exp((x / s))))
else
tmp = s / (exp(x) ** s)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(100.0)) tmp = Float32(Float32(Float32(0.5) + Float32(x * Float32(Float32(0.25) / s))) * Float32(Float32(Float32(1.0) / s) / Float32(Float32(1.0) + exp(Float32(x / s))))); else tmp = Float32(s / (exp(x) ^ s)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(100.0)) tmp = (single(0.5) + (x * (single(0.25) / s))) * ((single(1.0) / s) / (single(1.0) + exp((x / s)))); else tmp = s / (exp(x) ^ s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 100:\\
\;\;\;\;\left(0.5 + x \cdot \frac{0.25}{s}\right) \cdot \frac{\frac{1}{s}}{1 + e^{\frac{x}{s}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{s}{{\left(e^{x}\right)}^{s}}\\
\end{array}
\end{array}
if x < 100Initial program 99.6%
*-commutative99.6%
Simplified99.6%
associate-/r*99.6%
+-commutative99.6%
distribute-lft-in99.6%
*-rgt-identity99.6%
fma-undefine99.7%
associate-/r*99.7%
div-inv99.7%
Applied egg-rr80.6%
associate-*r/80.6%
*-rgt-identity80.6%
associate-/r*80.6%
+-commutative80.6%
Simplified80.6%
Applied egg-rr99.1%
add-cube-cbrt99.0%
fma-neg99.0%
pow299.0%
Applied egg-rr99.0%
Taylor expanded in x around 0 57.4%
exp-neg57.4%
rem-exp-log57.4%
metadata-eval57.4%
associate-/l*57.4%
associate-*r*57.9%
*-commutative57.9%
associate-*r*57.9%
associate-*r/57.9%
exp-neg57.9%
rem-exp-log57.9%
metadata-eval57.9%
metadata-eval57.9%
Simplified57.9%
if 100 < x Initial program 100.0%
*-commutative100.0%
Simplified100.0%
associate-/r*100.0%
+-commutative100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
fma-undefine100.0%
associate-/r*100.0%
div-inv98.5%
Applied egg-rr-0.0%
associate-*r/-0.0%
*-rgt-identity-0.0%
associate-/r*-0.0%
+-commutative-0.0%
Simplified-0.0%
+-commutative-0.0%
associate-/r*-0.0%
add-exp-log-0.0%
log-div-0.0%
add-log-exp49.3%
+-commutative49.3%
log-prod49.3%
+-commutative49.3%
log-pow49.3%
+-commutative49.3%
log1p-define49.3%
Applied egg-rr49.3%
Applied egg-rr100.0%
Final simplification68.9%
(FPCore (x s)
:precision binary32
(let* ((t_0 (/ (/ 1.0 s) (+ 1.0 (exp (/ x s))))))
(if (<= x 0.0020000000949949026)
(* (+ 0.5 (* x (/ 0.25 s))) t_0)
(* t_0 1.5))))
float code(float x, float s) {
float t_0 = (1.0f / s) / (1.0f + expf((x / s)));
float tmp;
if (x <= 0.0020000000949949026f) {
tmp = (0.5f + (x * (0.25f / s))) * t_0;
} else {
tmp = t_0 * 1.5f;
}
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) / (1.0e0 + exp((x / s)))
if (x <= 0.0020000000949949026e0) then
tmp = (0.5e0 + (x * (0.25e0 / s))) * t_0
else
tmp = t_0 * 1.5e0
end if
code = tmp
end function
function code(x, s) t_0 = Float32(Float32(Float32(1.0) / s) / Float32(Float32(1.0) + exp(Float32(x / s)))) tmp = Float32(0.0) if (x <= Float32(0.0020000000949949026)) tmp = Float32(Float32(Float32(0.5) + Float32(x * Float32(Float32(0.25) / s))) * t_0); else tmp = Float32(t_0 * Float32(1.5)); end return tmp end
function tmp_2 = code(x, s) t_0 = (single(1.0) / s) / (single(1.0) + exp((x / s))); tmp = single(0.0); if (x <= single(0.0020000000949949026)) tmp = (single(0.5) + (x * (single(0.25) / s))) * t_0; else tmp = t_0 * single(1.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{1}{s}}{1 + e^{\frac{x}{s}}}\\
\mathbf{if}\;x \leq 0.0020000000949949026:\\
\;\;\;\;\left(0.5 + x \cdot \frac{0.25}{s}\right) \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot 1.5\\
\end{array}
\end{array}
if x < 0.00200000009Initial program 99.6%
*-commutative99.6%
Simplified99.6%
associate-/r*99.6%
+-commutative99.6%
distribute-lft-in99.6%
*-rgt-identity99.6%
fma-undefine99.7%
associate-/r*99.7%
div-inv99.6%
Applied egg-rr84.6%
associate-*r/84.6%
*-rgt-identity84.6%
associate-/r*84.6%
+-commutative84.6%
Simplified84.6%
Applied egg-rr99.6%
add-cube-cbrt99.5%
fma-neg99.5%
pow299.5%
Applied egg-rr99.5%
Taylor expanded in x around 0 55.8%
exp-neg55.8%
rem-exp-log55.8%
metadata-eval55.8%
associate-/l*55.8%
associate-*r*55.8%
*-commutative55.8%
associate-*r*55.8%
associate-*r/55.8%
exp-neg55.8%
rem-exp-log55.8%
metadata-eval55.8%
metadata-eval55.8%
Simplified55.8%
if 0.00200000009 < x Initial program 100.0%
*-commutative100.0%
Simplified100.0%
associate-/r*100.0%
+-commutative100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
fma-undefine100.0%
associate-/r*100.0%
div-inv98.7%
Applied egg-rr-0.0%
associate-*r/-0.0%
*-rgt-identity-0.0%
associate-/r*-0.0%
+-commutative-0.0%
Simplified-0.0%
Applied egg-rr53.9%
Taylor expanded in x around 0 98.7%
neg-mul-198.7%
Simplified98.7%
Applied egg-rr98.7%
Final simplification68.6%
(FPCore (x s) :precision binary32 (if (<= x 8.499999924127398e-19) (/ 0.25 s) (* (/ (/ 1.0 s) (+ 1.0 (exp (/ x s)))) 1.5)))
float code(float x, float s) {
float tmp;
if (x <= 8.499999924127398e-19f) {
tmp = 0.25f / s;
} else {
tmp = ((1.0f / s) / (1.0f + expf((x / s)))) * 1.5f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 8.499999924127398e-19) then
tmp = 0.25e0 / s
else
tmp = ((1.0e0 / s) / (1.0e0 + exp((x / s)))) * 1.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(8.499999924127398e-19)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(Float32(Float32(1.0) / s) / Float32(Float32(1.0) + exp(Float32(x / s)))) * Float32(1.5)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(8.499999924127398e-19)) tmp = single(0.25) / s; else tmp = ((single(1.0) / s) / (single(1.0) + exp((x / s)))) * single(1.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 8.499999924127398 \cdot 10^{-19}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{s}}{1 + e^{\frac{x}{s}}} \cdot 1.5\\
\end{array}
\end{array}
if x < 8.49999992e-19Initial program 99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in s around inf 43.3%
if 8.49999992e-19 < x Initial program 99.9%
*-commutative99.9%
Simplified99.9%
associate-/r*99.9%
+-commutative99.9%
distribute-lft-in99.9%
*-rgt-identity99.9%
fma-undefine99.9%
associate-/r*99.9%
div-inv98.9%
Applied egg-rr8.5%
associate-*r/8.5%
*-rgt-identity8.5%
associate-/r*8.5%
+-commutative8.5%
Simplified8.5%
Applied egg-rr65.8%
Taylor expanded in x around 0 95.5%
neg-mul-195.5%
Simplified95.5%
Applied egg-rr92.6%
Final simplification63.1%
(FPCore (x s) :precision binary32 (if (<= x 0.0020000000949949026) (/ 0.25 s) (exp (* s (- x)))))
float code(float x, float s) {
float tmp;
if (x <= 0.0020000000949949026f) {
tmp = 0.25f / s;
} else {
tmp = expf((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.0020000000949949026e0) then
tmp = 0.25e0 / s
else
tmp = exp((s * -x))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(0.0020000000949949026)) tmp = Float32(Float32(0.25) / s); else tmp = exp(Float32(s * Float32(-x))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(0.0020000000949949026)) tmp = single(0.25) / s; else tmp = exp((s * -x)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0020000000949949026:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;e^{s \cdot \left(-x\right)}\\
\end{array}
\end{array}
if x < 0.00200000009Initial program 99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in s around inf 41.2%
if 0.00200000009 < x Initial program 100.0%
*-commutative100.0%
Simplified100.0%
associate-/r*100.0%
+-commutative100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
fma-undefine100.0%
associate-/r*100.0%
div-inv98.7%
Applied egg-rr-0.0%
associate-*r/-0.0%
*-rgt-identity-0.0%
associate-/r*-0.0%
+-commutative-0.0%
Simplified-0.0%
+-commutative-0.0%
associate-/r*-0.0%
add-exp-log-0.0%
log-div-0.0%
add-log-exp53.9%
+-commutative53.9%
log-prod53.9%
+-commutative53.9%
log-pow53.9%
+-commutative53.9%
log1p-define53.9%
Applied egg-rr53.9%
Applied egg-rr88.9%
associate-/r*88.9%
*-inverses88.9%
exp-prod45.9%
rec-exp45.9%
distribute-rgt-neg-in45.9%
Simplified45.9%
Final simplification42.6%
(FPCore (x s) :precision binary32 (if (<= x 0.0020000000949949026) (/ 0.25 s) (/ s -2.0)))
float code(float x, float s) {
float tmp;
if (x <= 0.0020000000949949026f) {
tmp = 0.25f / s;
} else {
tmp = 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 <= 0.0020000000949949026e0) then
tmp = 0.25e0 / s
else
tmp = s / (-2.0e0)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(0.0020000000949949026)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(s / Float32(-2.0)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(0.0020000000949949026)) tmp = single(0.25) / s; else tmp = s / single(-2.0); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0020000000949949026:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{s}{-2}\\
\end{array}
\end{array}
if x < 0.00200000009Initial program 99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in s around inf 41.2%
if 0.00200000009 < x Initial program 100.0%
*-commutative100.0%
Simplified100.0%
associate-/r*100.0%
+-commutative100.0%
distribute-lft-in100.0%
*-rgt-identity100.0%
fma-undefine100.0%
associate-/r*100.0%
div-inv98.7%
Applied egg-rr-0.0%
associate-*r/-0.0%
*-rgt-identity-0.0%
associate-/r*-0.0%
+-commutative-0.0%
Simplified-0.0%
+-commutative-0.0%
associate-/r*-0.0%
add-exp-log-0.0%
log-div-0.0%
add-log-exp53.9%
+-commutative53.9%
log-prod53.9%
+-commutative53.9%
log-pow53.9%
+-commutative53.9%
log1p-define53.9%
Applied egg-rr53.9%
Applied egg-rr1.4%
associate-/l/1.4%
associate-/r*1.4%
associate-/l*1.4%
*-inverses11.1%
*-rgt-identity11.1%
Simplified11.1%
(FPCore (x s) :precision binary32 (/ 0.25 s))
float code(float x, float s) {
return 0.25f / s;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.25e0 / s
end function
function code(x, s) return Float32(Float32(0.25) / s) end
function tmp = code(x, s) tmp = single(0.25) / s; end
\begin{array}{l}
\\
\frac{0.25}{s}
\end{array}
Initial program 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in s around inf 30.3%
herbie shell --seed 2024111
(FPCore (x s)
:name "Logistic distribution"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ (exp (/ (- (fabs x)) s)) (* (* s (+ 1.0 (exp (/ (- (fabs x)) s)))) (+ 1.0 (exp (/ (- (fabs x)) s))))))