
(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 11 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) (+ 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(abs(x) / Float32(-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.0%
*-commutative99.0%
fabs-neg99.0%
distribute-lft-in99.0%
*-rgt-identity99.0%
fabs-neg99.0%
distribute-rgt-in99.1%
cancel-sign-sub99.1%
Simplified99.0%
Final simplification99.0%
(FPCore (x s) :precision binary32 (if (<= (fabs x) 0.25999999046325684) (/ (exp (- (/ x s) (* 2.0 (log1p (exp (/ x s)))))) s) (/ (/ (exp (/ x (- s))) s) 4.0)))
float code(float x, float s) {
float tmp;
if (fabsf(x) <= 0.25999999046325684f) {
tmp = expf(((x / s) - (2.0f * log1pf(expf((x / s)))))) / s;
} else {
tmp = (expf((x / -s)) / s) / 4.0f;
}
return tmp;
}
function code(x, s) tmp = Float32(0.0) if (abs(x) <= Float32(0.25999999046325684)) tmp = Float32(exp(Float32(Float32(x / s) - Float32(Float32(2.0) * log1p(exp(Float32(x / s)))))) / s); else tmp = Float32(Float32(exp(Float32(x / Float32(-s))) / s) / Float32(4.0)); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.25999999046325684:\\
\;\;\;\;\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.25999999Initial program 97.9%
*-commutative97.9%
Simplified97.9%
Applied egg-rr91.8%
exp-diff77.1%
add-exp-log81.2%
*-commutative81.2%
associate-/r*81.0%
+-commutative81.0%
Applied egg-rr81.0%
add-exp-log81.0%
log-div80.9%
add-log-exp95.9%
+-commutative95.9%
log-pow97.2%
+-commutative97.2%
log1p-define97.4%
Applied egg-rr97.4%
if 0.25999999 < (fabs.f32 x) Initial program 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
associate-/r*100.0%
mul-1-neg100.0%
distribute-neg-frac2100.0%
+-commutative100.0%
mul-1-neg100.0%
distribute-neg-frac2100.0%
Simplified100.0%
distribute-frac-neg2100.0%
exp-neg100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod-0.0%
add-sqr-sqrt3.1%
div-inv3.1%
exp-prod3.1%
add-sqr-sqrt1.6%
fabs-sqr1.6%
add-sqr-sqrt50.1%
add-sqr-sqrt-0.0%
sqrt-unprod53.0%
sqr-neg53.0%
sqrt-unprod53.0%
add-sqr-sqrt53.0%
exp-prod53.0%
div-inv53.0%
Applied egg-rr53.0%
rec-exp53.0%
distribute-frac-neg53.0%
Simplified53.0%
Taylor expanded in s around inf 53.0%
Final simplification73.8%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ x (- s))))) (/ (/ t_0 s) (pow (+ 1.0 t_0) 2.0))))
float code(float x, float s) {
float t_0 = expf((x / -s));
return (t_0 / s) / powf((1.0f + t_0), 2.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
t_0 = exp((x / -s))
code = (t_0 / s) / ((1.0e0 + t_0) ** 2.0e0)
end function
function code(x, s) t_0 = exp(Float32(x / Float32(-s))) return Float32(Float32(t_0 / s) / (Float32(Float32(1.0) + t_0) ^ Float32(2.0))) end
function tmp = code(x, s) t_0 = exp((x / -s)); tmp = (t_0 / s) / ((single(1.0) + t_0) ^ single(2.0)); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{x}{-s}}\\
\frac{\frac{t\_0}{s}}{{\left(1 + t\_0\right)}^{2}}
\end{array}
\end{array}
Initial program 99.0%
*-commutative99.0%
Simplified99.0%
Taylor expanded in x around 0 99.0%
associate-/r*98.9%
mul-1-neg98.9%
distribute-neg-frac298.9%
+-commutative98.9%
mul-1-neg98.9%
distribute-neg-frac298.9%
Simplified98.9%
distribute-frac-neg298.9%
exp-neg98.8%
add-sqr-sqrt98.7%
sqrt-unprod92.5%
sqr-neg92.5%
sqrt-unprod-0.0%
add-sqr-sqrt21.8%
div-inv21.8%
exp-prod22.2%
add-sqr-sqrt12.7%
fabs-sqr12.7%
add-sqr-sqrt52.8%
add-sqr-sqrt19.8%
sqrt-unprod52.5%
sqr-neg52.5%
sqrt-unprod52.5%
add-sqr-sqrt52.5%
exp-prod60.7%
div-inv60.7%
Applied egg-rr60.7%
rec-exp60.8%
distribute-frac-neg60.8%
Simplified60.8%
distribute-frac-neg298.9%
exp-neg98.8%
add-sqr-sqrt98.7%
sqrt-unprod92.5%
sqr-neg92.5%
sqrt-unprod-0.0%
add-sqr-sqrt21.8%
div-inv21.8%
exp-prod22.2%
add-sqr-sqrt12.7%
fabs-sqr12.7%
add-sqr-sqrt52.8%
add-sqr-sqrt19.8%
sqrt-unprod52.5%
sqr-neg52.5%
sqrt-unprod52.5%
add-sqr-sqrt52.5%
exp-prod60.7%
div-inv60.7%
Applied egg-rr61.7%
rec-exp60.8%
distribute-frac-neg60.8%
Simplified61.8%
Final simplification61.8%
(FPCore (x s) :precision binary32 (/ (/ (exp (/ x (- s))) s) (pow (- 2.0 (/ x s)) 2.0)))
float code(float x, float s) {
return (expf((x / -s)) / s) / powf((2.0f - (x / s)), 2.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (exp((x / -s)) / s) / ((2.0e0 - (x / s)) ** 2.0e0)
end function
function code(x, s) return Float32(Float32(exp(Float32(x / Float32(-s))) / s) / (Float32(Float32(2.0) - Float32(x / s)) ^ Float32(2.0))) end
function tmp = code(x, s) tmp = (exp((x / -s)) / s) / ((single(2.0) - (x / s)) ^ single(2.0)); end
\begin{array}{l}
\\
\frac{\frac{e^{\frac{x}{-s}}}{s}}{{\left(2 - \frac{x}{s}\right)}^{2}}
\end{array}
Initial program 99.0%
*-commutative99.0%
Simplified99.0%
Taylor expanded in x around 0 99.0%
associate-/r*98.9%
mul-1-neg98.9%
distribute-neg-frac298.9%
+-commutative98.9%
mul-1-neg98.9%
distribute-neg-frac298.9%
Simplified98.9%
distribute-frac-neg298.9%
exp-neg98.8%
add-sqr-sqrt98.7%
sqrt-unprod92.5%
sqr-neg92.5%
sqrt-unprod-0.0%
add-sqr-sqrt21.8%
div-inv21.8%
exp-prod22.2%
add-sqr-sqrt12.7%
fabs-sqr12.7%
add-sqr-sqrt52.8%
add-sqr-sqrt19.8%
sqrt-unprod52.5%
sqr-neg52.5%
sqrt-unprod52.5%
add-sqr-sqrt52.5%
exp-prod60.7%
div-inv60.7%
Applied egg-rr60.7%
rec-exp60.8%
distribute-frac-neg60.8%
Simplified60.8%
distribute-frac-neg298.9%
exp-neg98.8%
add-sqr-sqrt98.7%
sqrt-unprod92.5%
sqr-neg92.5%
sqrt-unprod-0.0%
add-sqr-sqrt21.8%
div-inv21.8%
exp-prod22.2%
add-sqr-sqrt12.7%
fabs-sqr12.7%
add-sqr-sqrt52.8%
add-sqr-sqrt19.8%
sqrt-unprod52.5%
sqr-neg52.5%
sqrt-unprod52.5%
add-sqr-sqrt52.5%
exp-prod60.7%
div-inv60.7%
Applied egg-rr61.7%
rec-exp60.8%
distribute-frac-neg60.8%
Simplified61.8%
Taylor expanded in x around 0 56.7%
mul-1-neg56.7%
unsub-neg56.7%
Simplified56.7%
Final simplification56.7%
(FPCore (x s) :precision binary32 (* (/ 1.0 (+ 1.0 (exp (/ x s)))) (/ 0.5 s)))
float code(float x, float s) {
return (1.0f / (1.0f + expf((x / s)))) * (0.5f / 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)))) * (0.5e0 / s)
end function
function code(x, s) return Float32(Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(x / s)))) * Float32(Float32(0.5) / s)) end
function tmp = code(x, s) tmp = (single(1.0) / (single(1.0) + exp((x / s)))) * (single(0.5) / s); end
\begin{array}{l}
\\
\frac{1}{1 + e^{\frac{x}{s}}} \cdot \frac{0.5}{s}
\end{array}
Initial program 99.0%
*-commutative99.0%
Simplified99.0%
*-un-lft-identity99.0%
times-frac98.9%
Applied egg-rr64.5%
Taylor expanded in x around 0 56.8%
Final simplification56.8%
(FPCore (x s) :precision binary32 (/ (/ (exp (/ x (- s))) s) 4.0))
float code(float x, float s) {
return (expf((x / -s)) / s) / 4.0f;
}
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
function code(x, s) return Float32(Float32(exp(Float32(x / Float32(-s))) / s) / Float32(4.0)) end
function tmp = code(x, s) tmp = (exp((x / -s)) / s) / single(4.0); end
\begin{array}{l}
\\
\frac{\frac{e^{\frac{x}{-s}}}{s}}{4}
\end{array}
Initial program 99.0%
*-commutative99.0%
Simplified99.0%
Taylor expanded in x around 0 99.0%
associate-/r*98.9%
mul-1-neg98.9%
distribute-neg-frac298.9%
+-commutative98.9%
mul-1-neg98.9%
distribute-neg-frac298.9%
Simplified98.9%
distribute-frac-neg298.9%
exp-neg98.8%
add-sqr-sqrt98.7%
sqrt-unprod92.5%
sqr-neg92.5%
sqrt-unprod-0.0%
add-sqr-sqrt21.8%
div-inv21.8%
exp-prod22.2%
add-sqr-sqrt12.7%
fabs-sqr12.7%
add-sqr-sqrt52.8%
add-sqr-sqrt19.8%
sqrt-unprod52.5%
sqr-neg52.5%
sqrt-unprod52.5%
add-sqr-sqrt52.5%
exp-prod60.7%
div-inv60.7%
Applied egg-rr60.7%
rec-exp60.8%
distribute-frac-neg60.8%
Simplified60.8%
Taylor expanded in s around inf 55.9%
Final simplification55.9%
(FPCore (x s)
:precision binary32
(if (<= x 3.9999998989515007e-5)
(/ 0.25 s)
(/
(-
(+ 0.3333333333333333 (* 0.3333333333333333 (/ s x)))
(* (/ s x) 0.4444444444444444))
x)))
float code(float x, float s) {
float tmp;
if (x <= 3.9999998989515007e-5f) {
tmp = 0.25f / s;
} else {
tmp = ((0.3333333333333333f + (0.3333333333333333f * (s / x))) - ((s / x) * 0.4444444444444444f)) / x;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 3.9999998989515007e-5) then
tmp = 0.25e0 / s
else
tmp = ((0.3333333333333333e0 + (0.3333333333333333e0 * (s / x))) - ((s / x) * 0.4444444444444444e0)) / x
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(3.9999998989515007e-5)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(Float32(Float32(0.3333333333333333) + Float32(Float32(0.3333333333333333) * Float32(s / x))) - Float32(Float32(s / x) * Float32(0.4444444444444444))) / x); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(3.9999998989515007e-5)) tmp = single(0.25) / s; else tmp = ((single(0.3333333333333333) + (single(0.3333333333333333) * (s / x))) - ((s / x) * single(0.4444444444444444))) / x; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.9999998989515007 \cdot 10^{-5}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(0.3333333333333333 + 0.3333333333333333 \cdot \frac{s}{x}\right) - \frac{s}{x} \cdot 0.4444444444444444}{x}\\
\end{array}
\end{array}
if x < 3.9999999e-5Initial program 98.6%
*-commutative98.6%
Simplified98.6%
Taylor expanded in s around inf 33.5%
if 3.9999999e-5 < x Initial program 100.0%
*-commutative100.0%
Simplified100.0%
div-inv100.0%
div-inv100.0%
div-inv100.0%
add-sqr-sqrt-0.0%
sqrt-unprod3.1%
sqr-neg3.1%
sqrt-unprod3.1%
add-sqr-sqrt3.1%
add-sqr-sqrt3.1%
fabs-sqr3.1%
add-sqr-sqrt3.1%
*-commutative3.1%
associate-*l*3.1%
Applied egg-rr-0.0%
associate-*r/-0.0%
*-rgt-identity-0.0%
+-commutative-0.0%
Simplified-0.0%
Taylor expanded in x around 0 0.9%
Taylor expanded in x around 0 22.3%
Taylor expanded in x around inf 11.0%
Final simplification27.0%
(FPCore (x s) :precision binary32 (/ (+ 1.0 (/ x s)) (+ (* s 4.0) (* x (+ 4.0 (* (/ x s) 3.0))))))
float code(float x, float s) {
return (1.0f + (x / s)) / ((s * 4.0f) + (x * (4.0f + ((x / s) * 3.0f))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 + (x / s)) / ((s * 4.0e0) + (x * (4.0e0 + ((x / s) * 3.0e0))))
end function
function code(x, s) return Float32(Float32(Float32(1.0) + Float32(x / s)) / Float32(Float32(s * Float32(4.0)) + Float32(x * Float32(Float32(4.0) + Float32(Float32(x / s) * Float32(3.0)))))) end
function tmp = code(x, s) tmp = (single(1.0) + (x / s)) / ((s * single(4.0)) + (x * (single(4.0) + ((x / s) * single(3.0))))); end
\begin{array}{l}
\\
\frac{1 + \frac{x}{s}}{s \cdot 4 + x \cdot \left(4 + \frac{x}{s} \cdot 3\right)}
\end{array}
Initial program 99.0%
*-commutative99.0%
Simplified99.0%
div-inv99.0%
div-inv99.0%
div-inv99.0%
add-sqr-sqrt-0.0%
sqrt-unprod22.0%
sqr-neg22.0%
sqrt-unprod21.8%
add-sqr-sqrt21.8%
add-sqr-sqrt12.5%
fabs-sqr12.5%
add-sqr-sqrt60.0%
*-commutative60.0%
associate-*l*60.0%
Applied egg-rr63.8%
associate-*r/63.8%
*-rgt-identity63.8%
+-commutative63.8%
Simplified63.8%
Taylor expanded in x around 0 59.7%
Taylor expanded in x around 0 36.1%
Final simplification36.1%
(FPCore (x s) :precision binary32 (if (<= x 3.9999998989515007e-5) (/ 0.25 s) (/ (+ 0.3333333333333333 (/ (* s -0.1111111111111111) x)) x)))
float code(float x, float s) {
float tmp;
if (x <= 3.9999998989515007e-5f) {
tmp = 0.25f / s;
} else {
tmp = (0.3333333333333333f + ((s * -0.1111111111111111f) / x)) / x;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 3.9999998989515007e-5) then
tmp = 0.25e0 / s
else
tmp = (0.3333333333333333e0 + ((s * (-0.1111111111111111e0)) / x)) / x
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(3.9999998989515007e-5)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(Float32(0.3333333333333333) + Float32(Float32(s * Float32(-0.1111111111111111)) / x)) / x); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(3.9999998989515007e-5)) tmp = single(0.25) / s; else tmp = (single(0.3333333333333333) + ((s * single(-0.1111111111111111)) / x)) / x; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.9999998989515007 \cdot 10^{-5}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333 + \frac{s \cdot -0.1111111111111111}{x}}{x}\\
\end{array}
\end{array}
if x < 3.9999999e-5Initial program 98.6%
*-commutative98.6%
Simplified98.6%
Taylor expanded in s around inf 33.5%
if 3.9999999e-5 < x Initial program 100.0%
*-commutative100.0%
Simplified100.0%
div-inv100.0%
div-inv100.0%
div-inv100.0%
add-sqr-sqrt-0.0%
sqrt-unprod3.1%
sqr-neg3.1%
sqrt-unprod3.1%
add-sqr-sqrt3.1%
add-sqr-sqrt3.1%
fabs-sqr3.1%
add-sqr-sqrt3.1%
*-commutative3.1%
associate-*l*3.1%
Applied egg-rr-0.0%
associate-*r/-0.0%
*-rgt-identity-0.0%
+-commutative-0.0%
Simplified-0.0%
Taylor expanded in x around 0 0.9%
Taylor expanded in x around 0 22.3%
Taylor expanded in x around inf 11.0%
associate--l+11.0%
associate-*r/11.0%
associate-*r/11.0%
div-sub11.0%
distribute-rgt-out--11.0%
metadata-eval11.0%
Simplified11.0%
Final simplification27.0%
(FPCore (x s) :precision binary32 (if (<= x 3.9999998989515007e-5) (/ 0.25 s) (/ 0.3333333333333333 x)))
float code(float x, float s) {
float tmp;
if (x <= 3.9999998989515007e-5f) {
tmp = 0.25f / s;
} else {
tmp = 0.3333333333333333f / x;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 3.9999998989515007e-5) then
tmp = 0.25e0 / s
else
tmp = 0.3333333333333333e0 / x
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(3.9999998989515007e-5)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(0.3333333333333333) / x); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(3.9999998989515007e-5)) tmp = single(0.25) / s; else tmp = single(0.3333333333333333) / x; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.9999998989515007 \cdot 10^{-5}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{x}\\
\end{array}
\end{array}
if x < 3.9999999e-5Initial program 98.6%
*-commutative98.6%
Simplified98.6%
Taylor expanded in s around inf 33.5%
if 3.9999999e-5 < x Initial program 100.0%
*-commutative100.0%
Simplified100.0%
div-inv100.0%
div-inv100.0%
div-inv100.0%
add-sqr-sqrt-0.0%
sqrt-unprod3.1%
sqr-neg3.1%
sqrt-unprod3.1%
add-sqr-sqrt3.1%
add-sqr-sqrt3.1%
fabs-sqr3.1%
add-sqr-sqrt3.1%
*-commutative3.1%
associate-*l*3.1%
Applied egg-rr-0.0%
associate-*r/-0.0%
*-rgt-identity-0.0%
+-commutative-0.0%
Simplified-0.0%
Taylor expanded in x around 0 0.9%
Taylor expanded in x around 0 22.3%
Taylor expanded in x around inf 11.0%
Final simplification27.0%
(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.0%
*-commutative99.0%
Simplified99.0%
Taylor expanded in s around inf 25.1%
Final simplification25.1%
herbie shell --seed 2024075
(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))))))