
(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}
NOTE: x should be positive before calling this function (FPCore (x s) :precision binary32 (if (<= (fabs x) 0.004000000189989805) (/ (exp (+ (/ x s) (* -2.0 (log1p (exp (/ x s)))))) s) (/ (/ (exp (/ (- x) s)) s) 4.0)))
x = abs(x);
float code(float x, float s) {
float tmp;
if (fabsf(x) <= 0.004000000189989805f) {
tmp = expf(((x / s) + (-2.0f * log1pf(expf((x / s)))))) / s;
} else {
tmp = (expf((-x / s)) / s) / 4.0f;
}
return tmp;
}
x = abs(x) function code(x, s) tmp = Float32(0.0) if (abs(x) <= Float32(0.004000000189989805)) tmp = Float32(exp(Float32(Float32(x / s) + Float32(Float32(-2.0) * log1p(exp(Float32(x / s)))))) / s); else tmp = Float32(Float32(exp(Float32(Float32(-x) / s)) / s) / Float32(4.0)); end return tmp end
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.004000000189989805:\\
\;\;\;\;\frac{e^{\frac{x}{s} + -2 \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right)}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{e^{\frac{-x}{s}}}{s}}{4}\\
\end{array}
\end{array}
if (fabs.f32 x) < 0.00400000019Initial program 98.4%
associate-*l*98.7%
Simplified98.7%
*-un-lft-identity98.7%
*-commutative98.7%
times-frac98.5%
Applied egg-rr82.2%
associate-*r/82.4%
add-exp-log82.4%
prod-exp97.8%
pow-flip97.8%
log-pow98.7%
metadata-eval98.7%
+-commutative98.7%
log1p-udef98.7%
Applied egg-rr98.7%
if 0.00400000019 < (fabs.f32 x) Initial program 100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
associate-/r*100.0%
associate-*r/100.0%
mul-1-neg100.0%
+-commutative100.0%
associate-*r/100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in s around inf 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
add-sqr-sqrt53.1%
fabs-sqr53.1%
add-sqr-sqrt54.6%
Applied egg-rr54.6%
rec-exp54.6%
distribute-neg-frac54.6%
Simplified54.6%
Final simplification73.7%
NOTE: x should be positive before calling this function (FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (- (fabs x)) s))) (t_1 (+ t_0 1.0))) (/ t_0 (* s (* t_1 t_1)))))
x = abs(x);
float code(float x, float s) {
float t_0 = expf((-fabsf(x) / s));
float t_1 = t_0 + 1.0f;
return t_0 / (s * (t_1 * t_1));
}
NOTE: x should be positive before calling this function
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 = t_0 + 1.0e0
code = t_0 / (s * (t_1 * t_1))
end function
x = abs(x) function code(x, s) t_0 = exp(Float32(Float32(-abs(x)) / s)) t_1 = Float32(t_0 + Float32(1.0)) return Float32(t_0 / Float32(s * Float32(t_1 * t_1))) end
x = abs(x) function tmp = code(x, s) t_0 = exp((-abs(x) / s)); t_1 = t_0 + single(1.0); tmp = t_0 / (s * (t_1 * t_1)); end
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
t_1 := t_0 + 1\\
\frac{t_0}{s \cdot \left(t_1 \cdot t_1\right)}
\end{array}
\end{array}
Initial program 99.3%
associate-*l*99.4%
Simplified99.4%
Final simplification99.4%
NOTE: x should be positive before calling this function (FPCore (x s) :precision binary32 (/ 1.0 (* (fma s (exp (/ (fabs x) (- s))) s) (+ 1.0 (exp (/ (fabs x) s))))))
x = abs(x);
float code(float x, float s) {
return 1.0f / (fmaf(s, expf((fabsf(x) / -s)), s) * (1.0f + expf((fabsf(x) / s))));
}
x = abs(x) function code(x, s) return Float32(Float32(1.0) / Float32(fma(s, exp(Float32(abs(x) / Float32(-s))), s) * Float32(Float32(1.0) + exp(Float32(abs(x) / s))))) end
\begin{array}{l}
x = |x|\\
\\
\frac{1}{\mathsf{fma}\left(s, e^{\frac{\left|x\right|}{-s}}, s\right) \cdot \left(1 + e^{\frac{\left|x\right|}{s}}\right)}
\end{array}
Initial program 99.3%
Simplified99.4%
Final simplification99.4%
NOTE: x should be positive before calling this function (FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (- (fabs x)) s)))) (/ (/ t_0 s) (pow (+ t_0 1.0) 2.0))))
x = abs(x);
float code(float x, float s) {
float t_0 = expf((-fabsf(x) / s));
return (t_0 / s) / powf((t_0 + 1.0f), 2.0f);
}
NOTE: x should be positive before calling this function
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 / s) / ((t_0 + 1.0e0) ** 2.0e0)
end function
x = abs(x) function code(x, s) t_0 = exp(Float32(Float32(-abs(x)) / s)) return Float32(Float32(t_0 / s) / (Float32(t_0 + Float32(1.0)) ^ Float32(2.0))) end
x = abs(x) function tmp = code(x, s) t_0 = exp((-abs(x) / s)); tmp = (t_0 / s) / ((t_0 + single(1.0)) ^ single(2.0)); end
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
\frac{\frac{t_0}{s}}{{\left(t_0 + 1\right)}^{2}}
\end{array}
\end{array}
Initial program 99.3%
associate-*l*99.4%
Simplified99.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.4%
associate-*r/99.4%
mul-1-neg99.4%
+-commutative99.4%
associate-*r/99.4%
mul-1-neg99.4%
Simplified99.4%
Final simplification99.4%
NOTE: x should be positive before calling this function
(FPCore (x s)
:precision binary32
(if (<= x 1.000000031374395e-22)
(/ 0.25 s)
(if (<= x 20000000000.0)
(* 4.0 (/ (/ 1.0 (* (/ 1.0 s) (/ 1.0 s))) s))
(/ s (pow x 2.0)))))x = abs(x);
float code(float x, float s) {
float tmp;
if (x <= 1.000000031374395e-22f) {
tmp = 0.25f / s;
} else if (x <= 20000000000.0f) {
tmp = 4.0f * ((1.0f / ((1.0f / s) * (1.0f / s))) / s);
} else {
tmp = s / powf(x, 2.0f);
}
return tmp;
}
NOTE: x should be positive before calling this function
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 1.000000031374395e-22) then
tmp = 0.25e0 / s
else if (x <= 20000000000.0e0) then
tmp = 4.0e0 * ((1.0e0 / ((1.0e0 / s) * (1.0e0 / s))) / s)
else
tmp = s / (x ** 2.0e0)
end if
code = tmp
end function
x = abs(x) function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.000000031374395e-22)) tmp = Float32(Float32(0.25) / s); elseif (x <= Float32(20000000000.0)) tmp = Float32(Float32(4.0) * Float32(Float32(Float32(1.0) / Float32(Float32(Float32(1.0) / s) * Float32(Float32(1.0) / s))) / s)); else tmp = Float32(s / (x ^ Float32(2.0))); end return tmp end
x = abs(x) function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.000000031374395e-22)) tmp = single(0.25) / s; elseif (x <= single(20000000000.0)) tmp = single(4.0) * ((single(1.0) / ((single(1.0) / s) * (single(1.0) / s))) / s); else tmp = s / (x ^ single(2.0)); end tmp_2 = tmp; end
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.000000031374395 \cdot 10^{-22}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{elif}\;x \leq 20000000000:\\
\;\;\;\;4 \cdot \frac{\frac{1}{\frac{1}{s} \cdot \frac{1}{s}}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{s}{{x}^{2}}\\
\end{array}
\end{array}
if x < 1.00000003e-22Initial program 99.0%
associate-*l*99.2%
Simplified99.2%
Taylor expanded in s around inf 34.6%
if 1.00000003e-22 < x < 2e10Initial program 99.6%
associate-*l*99.7%
Simplified99.7%
Applied egg-rr90.4%
Taylor expanded in x around 0 22.1%
add-sqr-sqrt19.3%
sqrt-unprod20.6%
sqr-neg20.6%
sqrt-unprod0.7%
add-sqr-sqrt12.9%
exp-sum12.9%
add-exp-log12.9%
*-commutative12.9%
exp-to-pow12.9%
metadata-eval12.9%
+-lft-identity12.9%
mul0-rgt12.9%
flip-+51.9%
Applied egg-rr51.9%
div051.9%
neg-sub051.9%
neg-mul-151.9%
metadata-eval51.9%
times-frac51.9%
neg-mul-151.9%
remove-double-neg51.9%
*-lft-identity51.9%
*-commutative51.9%
*-commutative51.9%
times-frac51.9%
metadata-eval51.9%
Simplified51.9%
pow151.9%
metadata-eval51.9%
pow-div51.9%
pow151.9%
metadata-eval51.9%
pow-prod-up51.9%
pow151.9%
clear-num51.9%
pow151.9%
pow-div51.9%
metadata-eval51.9%
inv-pow51.9%
pow151.9%
clear-num51.9%
pow151.9%
pow-div51.9%
metadata-eval51.9%
inv-pow51.9%
frac-times61.4%
metadata-eval61.4%
Applied egg-rr61.4%
if 2e10 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in s around -inf 30.3%
+-commutative30.3%
mul-1-neg30.3%
distribute-lft1-in95.7%
metadata-eval95.7%
associate-*r/95.7%
mul-1-neg95.7%
remove-double-neg95.7%
associate-+r+95.7%
Simplified95.7%
Taylor expanded in x around inf 94.1%
Final simplification52.4%
NOTE: x should be positive before calling this function (FPCore (x s) :precision binary32 (/ (/ (exp (/ (- x) s)) s) 4.0))
x = abs(x);
float code(float x, float s) {
return (expf((-x / s)) / s) / 4.0f;
}
NOTE: x should be positive before calling this function
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (exp((-x / s)) / s) / 4.0e0
end function
x = abs(x) function code(x, s) return Float32(Float32(exp(Float32(Float32(-x) / s)) / s) / Float32(4.0)) end
x = abs(x) function tmp = code(x, s) tmp = (exp((-x / s)) / s) / single(4.0); end
\begin{array}{l}
x = |x|\\
\\
\frac{\frac{e^{\frac{-x}{s}}}{s}}{4}
\end{array}
Initial program 99.3%
associate-*l*99.4%
Simplified99.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.4%
associate-*r/99.4%
mul-1-neg99.4%
+-commutative99.4%
associate-*r/99.4%
mul-1-neg99.4%
Simplified99.4%
Taylor expanded in s around inf 95.1%
distribute-frac-neg95.1%
exp-neg95.1%
add-sqr-sqrt46.9%
fabs-sqr46.9%
add-sqr-sqrt58.3%
Applied egg-rr58.3%
rec-exp58.4%
distribute-neg-frac58.4%
Simplified58.4%
Final simplification58.4%
NOTE: x should be positive before calling this function (FPCore (x s) :precision binary32 (if (<= s 3.99999987306209e-20) (* 4.0 (/ (/ 1.0 (* (/ 1.0 s) (/ 1.0 s))) s)) (/ 0.25 s)))
x = abs(x);
float code(float x, float s) {
float tmp;
if (s <= 3.99999987306209e-20f) {
tmp = 4.0f * ((1.0f / ((1.0f / s) * (1.0f / s))) / s);
} else {
tmp = 0.25f / s;
}
return tmp;
}
NOTE: x should be positive before calling this function
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (s <= 3.99999987306209e-20) then
tmp = 4.0e0 * ((1.0e0 / ((1.0e0 / s) * (1.0e0 / s))) / s)
else
tmp = 0.25e0 / s
end if
code = tmp
end function
x = abs(x) function code(x, s) tmp = Float32(0.0) if (s <= Float32(3.99999987306209e-20)) tmp = Float32(Float32(4.0) * Float32(Float32(Float32(1.0) / Float32(Float32(Float32(1.0) / s) * Float32(Float32(1.0) / s))) / s)); else tmp = Float32(Float32(0.25) / s); end return tmp end
x = abs(x) function tmp_2 = code(x, s) tmp = single(0.0); if (s <= single(3.99999987306209e-20)) tmp = single(4.0) * ((single(1.0) / ((single(1.0) / s) * (single(1.0) / s))) / s); else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;s \leq 3.99999987306209 \cdot 10^{-20}:\\
\;\;\;\;4 \cdot \frac{\frac{1}{\frac{1}{s} \cdot \frac{1}{s}}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
\end{array}
if s < 3.99999987e-20Initial program 99.1%
associate-*l*99.2%
Simplified99.2%
Applied egg-rr70.1%
Taylor expanded in x around 0 9.6%
add-sqr-sqrt9.4%
sqrt-unprod9.6%
sqr-neg9.6%
sqrt-unprod-0.0%
add-sqr-sqrt12.9%
exp-sum12.9%
add-exp-log12.9%
*-commutative12.9%
exp-to-pow12.9%
metadata-eval12.9%
+-lft-identity12.9%
mul0-rgt12.9%
flip-+73.4%
Applied egg-rr76.3%
div076.3%
neg-sub076.3%
neg-mul-176.3%
metadata-eval76.3%
times-frac76.3%
neg-mul-176.3%
remove-double-neg76.3%
*-lft-identity76.3%
*-commutative76.3%
*-commutative76.3%
times-frac76.3%
metadata-eval76.3%
Simplified76.3%
pow176.3%
metadata-eval76.3%
pow-div76.3%
pow176.3%
metadata-eval76.3%
pow-prod-up76.3%
pow176.3%
clear-num76.3%
pow176.3%
pow-div76.3%
metadata-eval76.3%
inv-pow76.3%
pow176.3%
clear-num76.3%
pow176.3%
pow-div76.3%
metadata-eval76.3%
inv-pow76.3%
frac-times91.6%
metadata-eval91.6%
Applied egg-rr91.6%
if 3.99999987e-20 < s Initial program 99.5%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in s around inf 40.5%
Final simplification65.3%
NOTE: x should be positive before calling this function (FPCore (x s) :precision binary32 (if (<= s 2.5000000784359874e-23) (* 4.0 (/ (* s s) s)) (/ 0.25 s)))
x = abs(x);
float code(float x, float s) {
float tmp;
if (s <= 2.5000000784359874e-23f) {
tmp = 4.0f * ((s * s) / s);
} else {
tmp = 0.25f / s;
}
return tmp;
}
NOTE: x should be positive before calling this function
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (s <= 2.5000000784359874e-23) then
tmp = 4.0e0 * ((s * s) / s)
else
tmp = 0.25e0 / s
end if
code = tmp
end function
x = abs(x) function code(x, s) tmp = Float32(0.0) if (s <= Float32(2.5000000784359874e-23)) tmp = Float32(Float32(4.0) * Float32(Float32(s * s) / s)); else tmp = Float32(Float32(0.25) / s); end return tmp end
x = abs(x) function tmp_2 = code(x, s) tmp = single(0.0); if (s <= single(2.5000000784359874e-23)) tmp = single(4.0) * ((s * s) / s); else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;s \leq 2.5000000784359874 \cdot 10^{-23}:\\
\;\;\;\;4 \cdot \frac{s \cdot s}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
\end{array}
if s < 2.50000008e-23Initial program 98.9%
associate-*l*99.0%
Simplified99.0%
Applied egg-rr68.2%
Taylor expanded in x around 0 8.3%
add-sqr-sqrt8.0%
sqrt-unprod8.3%
sqr-neg8.3%
sqrt-unprod-0.0%
add-sqr-sqrt13.8%
exp-sum13.8%
add-exp-log13.8%
*-commutative13.8%
exp-to-pow13.8%
metadata-eval13.8%
+-lft-identity13.8%
mul0-rgt13.8%
flip-+88.8%
Applied egg-rr92.4%
div092.4%
neg-sub092.4%
neg-mul-192.4%
metadata-eval92.4%
times-frac92.4%
neg-mul-192.4%
remove-double-neg92.4%
*-lft-identity92.4%
*-commutative92.4%
*-commutative92.4%
times-frac92.4%
metadata-eval92.4%
Simplified92.4%
unpow292.4%
Applied egg-rr92.4%
if 2.50000008e-23 < s Initial program 99.5%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in s around inf 36.8%
Final simplification58.5%
NOTE: x should be positive before calling this function (FPCore (x s) :precision binary32 (if (<= x 5.000000058430487e-8) (/ 0.25 s) (* s 4.0)))
x = abs(x);
float code(float x, float s) {
float tmp;
if (x <= 5.000000058430487e-8f) {
tmp = 0.25f / s;
} else {
tmp = s * 4.0f;
}
return tmp;
}
NOTE: x should be positive before calling this function
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 5.000000058430487e-8) then
tmp = 0.25e0 / s
else
tmp = s * 4.0e0
end if
code = tmp
end function
x = abs(x) function code(x, s) tmp = Float32(0.0) if (x <= Float32(5.000000058430487e-8)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(s * Float32(4.0)); end return tmp end
x = abs(x) function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(5.000000058430487e-8)) tmp = single(0.25) / s; else tmp = s * single(4.0); end tmp_2 = tmp; end
\begin{array}{l}
x = |x|\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.000000058430487 \cdot 10^{-8}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;s \cdot 4\\
\end{array}
\end{array}
if x < 5.00000006e-8Initial program 99.0%
associate-*l*99.2%
Simplified99.2%
Taylor expanded in s around inf 35.5%
if 5.00000006e-8 < x Initial program 100.0%
associate-*l*100.0%
Simplified100.0%
Applied egg-rr48.1%
Taylor expanded in x around 0 4.9%
add-sqr-sqrt4.7%
sqrt-unprod4.9%
sqr-neg4.9%
sqrt-unprod0.2%
add-sqr-sqrt11.6%
exp-sum11.6%
add-exp-log11.6%
*-commutative11.6%
exp-to-pow11.6%
metadata-eval11.6%
+-lft-identity11.6%
mul0-rgt11.6%
flip-+54.8%
Applied egg-rr55.9%
div055.9%
neg-sub055.9%
neg-mul-155.9%
metadata-eval55.9%
times-frac55.9%
neg-mul-155.9%
remove-double-neg55.9%
*-lft-identity55.9%
*-commutative55.9%
*-commutative55.9%
times-frac55.9%
metadata-eval55.9%
Simplified55.9%
Taylor expanded in s around 0 11.6%
Final simplification28.0%
NOTE: x should be positive before calling this function (FPCore (x s) :precision binary32 (* s 4.0))
x = abs(x);
float code(float x, float s) {
return s * 4.0f;
}
NOTE: x should be positive before calling this function
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = s * 4.0e0
end function
x = abs(x) function code(x, s) return Float32(s * Float32(4.0)) end
x = abs(x) function tmp = code(x, s) tmp = s * single(4.0); end
\begin{array}{l}
x = |x|\\
\\
s \cdot 4
\end{array}
Initial program 99.3%
associate-*l*99.4%
Simplified99.4%
Applied egg-rr81.2%
Taylor expanded in x around 0 24.4%
add-sqr-sqrt22.8%
sqrt-unprod23.6%
sqr-neg23.6%
sqrt-unprod0.4%
add-sqr-sqrt11.1%
exp-sum11.1%
add-exp-log11.1%
*-commutative11.1%
exp-to-pow11.1%
metadata-eval11.1%
+-lft-identity11.1%
mul0-rgt11.1%
flip-+40.5%
Applied egg-rr41.9%
div041.9%
neg-sub041.9%
neg-mul-141.9%
metadata-eval41.9%
times-frac41.9%
neg-mul-141.9%
remove-double-neg41.9%
*-lft-identity41.9%
*-commutative41.9%
*-commutative41.9%
times-frac41.9%
metadata-eval41.9%
Simplified41.9%
Taylor expanded in s around 0 11.1%
Final simplification11.1%
herbie shell --seed 2023310
(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))))))