
(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 12 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_1 (+ t_0 1.0))) (/ t_0 (* s (* t_1 t_1)))))
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));
}
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
function code(x, s) t_0 = exp(Float32(abs(x) / Float32(-s))) t_1 = Float32(t_0 + Float32(1.0)) return Float32(t_0 / Float32(s * Float32(t_1 * t_1))) end
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}
\\
\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.2%
fabs-neg99.2%
distribute-frac-neg99.2%
distribute-frac-neg299.2%
fabs-neg99.2%
*-commutative99.2%
fabs-neg99.2%
+-commutative99.2%
fabs-neg99.2%
Simplified99.3%
Final simplification99.3%
(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.2%
Simplified99.2%
Final simplification99.2%
(FPCore (x s) :precision binary32 (if (<= (fabs x) 0.10000000149011612) (/ (pow E (+ (/ x s) (* (log1p (exp (/ x s))) -2.0))) s) (/ (/ (exp (/ (- x) s)) s) 4.0)))
float code(float x, float s) {
float tmp;
if (fabsf(x) <= 0.10000000149011612f) {
tmp = powf(((float) M_E), ((x / s) + (log1pf(expf((x / s))) * -2.0f))) / s;
} else {
tmp = (expf((-x / s)) / s) / 4.0f;
}
return tmp;
}
function code(x, s) tmp = Float32(0.0) if (abs(x) <= Float32(0.10000000149011612)) tmp = Float32((Float32(exp(1)) ^ Float32(Float32(x / s) + Float32(log1p(exp(Float32(x / s))) * Float32(-2.0)))) / s); else tmp = Float32(Float32(exp(Float32(Float32(-x) / s)) / s) / Float32(4.0)); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.10000000149011612:\\
\;\;\;\;\frac{{e}^{\left(\frac{x}{s} + \mathsf{log1p}\left(e^{\frac{x}{s}}\right) \cdot -2\right)}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{e^{\frac{-x}{s}}}{s}}{4}\\
\end{array}
\end{array}
if (fabs.f32 x) < 0.100000001Initial program 98.2%
fabs-neg98.2%
distribute-frac-neg98.2%
distribute-frac-neg298.2%
fabs-neg98.2%
*-commutative98.2%
fabs-neg98.2%
+-commutative98.2%
fabs-neg98.2%
Simplified98.3%
Applied egg-rr93.9%
associate--r+94.1%
exp-diff94.6%
add-exp-log98.2%
Applied egg-rr98.2%
*-un-lft-identity98.2%
exp-prod98.3%
cancel-sign-sub-inv98.3%
metadata-eval98.3%
Applied egg-rr98.3%
exp-1-e98.3%
*-commutative98.3%
Simplified98.3%
if 0.100000001 < (fabs.f32 x) Initial program 100.0%
fabs-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
fabs-neg100.0%
*-commutative100.0%
fabs-neg100.0%
+-commutative100.0%
fabs-neg100.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%
rec-exp100.0%
pow1100.0%
pow1100.0%
add-sqr-sqrt53.8%
fabs-sqr53.8%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
rec-exp100.0%
distribute-neg-frac2100.0%
Simplified100.0%
distribute-frac-neg2100.0%
rec-exp100.0%
pow1100.0%
pow1100.0%
add-sqr-sqrt53.8%
fabs-sqr53.8%
add-sqr-sqrt100.0%
Applied egg-rr53.5%
rec-exp100.0%
distribute-neg-frac2100.0%
Simplified53.8%
Taylor expanded in x around 0 55.0%
Final simplification73.8%
(FPCore (x s) :precision binary32 (if (<= (fabs x) 0.10000000149011612) (/ (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.10000000149011612f) {
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.10000000149011612)) 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}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.10000000149011612:\\
\;\;\;\;\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.100000001Initial program 98.2%
fabs-neg98.2%
distribute-frac-neg98.2%
distribute-frac-neg298.2%
fabs-neg98.2%
*-commutative98.2%
fabs-neg98.2%
+-commutative98.2%
fabs-neg98.2%
Simplified98.3%
Applied egg-rr93.9%
associate--r+94.1%
exp-diff94.6%
add-exp-log98.2%
Applied egg-rr98.2%
if 0.100000001 < (fabs.f32 x) Initial program 100.0%
fabs-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
fabs-neg100.0%
*-commutative100.0%
fabs-neg100.0%
+-commutative100.0%
fabs-neg100.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%
rec-exp100.0%
pow1100.0%
pow1100.0%
add-sqr-sqrt53.8%
fabs-sqr53.8%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
rec-exp100.0%
distribute-neg-frac2100.0%
Simplified100.0%
distribute-frac-neg2100.0%
rec-exp100.0%
pow1100.0%
pow1100.0%
add-sqr-sqrt53.8%
fabs-sqr53.8%
add-sqr-sqrt100.0%
Applied egg-rr53.5%
rec-exp100.0%
distribute-neg-frac2100.0%
Simplified53.8%
Taylor expanded in x around 0 55.0%
Final simplification73.7%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (- x) s)))) (/ (/ t_0 s) (pow (+ t_0 1.0) 2.0))))
float code(float x, float s) {
float t_0 = expf((-x / s));
return (t_0 / s) / powf((t_0 + 1.0f), 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) / ((t_0 + 1.0e0) ** 2.0e0)
end function
function code(x, s) t_0 = exp(Float32(Float32(-x) / s)) return Float32(Float32(t_0 / s) / (Float32(t_0 + Float32(1.0)) ^ Float32(2.0))) end
function tmp = code(x, s) t_0 = exp((-x / s)); tmp = (t_0 / s) / ((t_0 + single(1.0)) ^ single(2.0)); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{-x}{s}}\\
\frac{\frac{t\_0}{s}}{{\left(t\_0 + 1\right)}^{2}}
\end{array}
\end{array}
Initial program 99.2%
fabs-neg99.2%
distribute-frac-neg99.2%
distribute-frac-neg299.2%
fabs-neg99.2%
*-commutative99.2%
fabs-neg99.2%
+-commutative99.2%
fabs-neg99.2%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-/r*99.2%
mul-1-neg99.2%
distribute-neg-frac299.2%
+-commutative99.2%
mul-1-neg99.2%
distribute-neg-frac299.2%
Simplified99.2%
distribute-frac-neg299.2%
rec-exp99.2%
pow199.2%
pow199.2%
add-sqr-sqrt53.3%
fabs-sqr53.3%
add-sqr-sqrt96.6%
Applied egg-rr96.6%
rec-exp96.6%
distribute-neg-frac296.6%
Simplified96.6%
distribute-frac-neg299.2%
rec-exp99.2%
pow199.2%
pow199.2%
add-sqr-sqrt53.3%
fabs-sqr53.3%
add-sqr-sqrt96.6%
Applied egg-rr62.9%
rec-exp96.6%
distribute-neg-frac296.6%
Simplified63.0%
Final simplification63.0%
(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.2%
fabs-neg99.2%
distribute-frac-neg99.2%
distribute-frac-neg299.2%
fabs-neg99.2%
*-commutative99.2%
fabs-neg99.2%
+-commutative99.2%
fabs-neg99.2%
Simplified99.3%
associate-*r*99.2%
associate-/r*99.2%
distribute-rgt-in99.2%
*-un-lft-identity99.2%
*-commutative99.2%
distribute-frac-neg299.2%
rec-exp99.2%
div-inv99.2%
associate-/r*99.2%
Applied egg-rr59.4%
Taylor expanded in x around 0 60.8%
Final simplification60.8%
(FPCore (x s) :precision binary32 (if (<= x 4.999999873689376e-5) (/ (- (+ 0.25 (/ (* x -0.125) s)) (* 0.5 (/ (* x -0.25) s))) s) (exp (/ (- x) s))))
float code(float x, float s) {
float tmp;
if (x <= 4.999999873689376e-5f) {
tmp = ((0.25f + ((x * -0.125f) / s)) - (0.5f * ((x * -0.25f) / s))) / s;
} else {
tmp = 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 <= 4.999999873689376e-5) then
tmp = ((0.25e0 + ((x * (-0.125e0)) / s)) - (0.5e0 * ((x * (-0.25e0)) / s))) / s
else
tmp = exp((-x / s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(4.999999873689376e-5)) tmp = Float32(Float32(Float32(Float32(0.25) + Float32(Float32(x * Float32(-0.125)) / s)) - Float32(Float32(0.5) * Float32(Float32(x * Float32(-0.25)) / s))) / s); else tmp = exp(Float32(Float32(-x) / s)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(4.999999873689376e-5)) tmp = ((single(0.25) + ((x * single(-0.125)) / s)) - (single(0.5) * ((x * single(-0.25)) / s))) / s; else tmp = exp((-x / s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.999999873689376 \cdot 10^{-5}:\\
\;\;\;\;\frac{\left(0.25 + \frac{x \cdot -0.125}{s}\right) - 0.5 \cdot \frac{x \cdot -0.25}{s}}{s}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{-x}{s}}\\
\end{array}
\end{array}
if x < 4.99999987e-5Initial program 98.9%
fabs-neg98.9%
distribute-frac-neg98.9%
distribute-frac-neg298.9%
fabs-neg98.9%
*-commutative98.9%
fabs-neg98.9%
+-commutative98.9%
fabs-neg98.9%
Simplified99.0%
associate-*r*98.9%
associate-/r*98.9%
distribute-rgt-in98.9%
*-un-lft-identity98.9%
*-commutative98.9%
distribute-frac-neg298.9%
rec-exp98.9%
div-inv98.9%
associate-/r*99.0%
Applied egg-rr85.4%
Taylor expanded in s around inf 38.2%
Taylor expanded in s around -inf 72.5%
mul-1-neg72.5%
distribute-rgt-out--72.5%
metadata-eval72.5%
associate-*r/73.1%
*-commutative73.1%
Simplified73.1%
if 4.99999987e-5 < x Initial program 99.9%
fabs-neg99.9%
distribute-frac-neg99.9%
distribute-frac-neg299.9%
fabs-neg99.9%
*-commutative99.9%
fabs-neg99.9%
+-commutative99.9%
fabs-neg99.9%
Simplified99.9%
Applied egg-rr60.3%
Taylor expanded in x around inf 3.4%
div-inv3.4%
exp-prod3.4%
add-sqr-sqrt3.4%
fabs-sqr3.4%
add-sqr-sqrt3.4%
add-sqr-sqrt3.4%
sqrt-unprod3.4%
sqr-neg3.4%
sqrt-unprod-0.0%
add-sqr-sqrt98.5%
exp-prod98.5%
div-inv98.5%
distribute-frac-neg298.5%
exp-neg98.5%
add-sqr-sqrt98.5%
sqrt-unprod98.5%
sqr-neg98.5%
sqrt-unprod-0.0%
add-sqr-sqrt3.4%
div-inv3.4%
exp-prod3.4%
Applied egg-rr98.5%
rec-exp98.5%
mul-1-neg98.5%
associate-*r/98.5%
neg-mul-198.5%
Simplified98.5%
Final simplification80.9%
(FPCore (x s) :precision binary32 (/ (/ 1.0 (* s (exp (/ x s)))) 4.0))
float code(float x, float s) {
return (1.0f / (s * expf((x / s)))) / 4.0f;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / (s * exp((x / s)))) / 4.0e0
end function
function code(x, s) return Float32(Float32(Float32(1.0) / Float32(s * exp(Float32(x / s)))) / Float32(4.0)) end
function tmp = code(x, s) tmp = (single(1.0) / (s * exp((x / s)))) / single(4.0); end
\begin{array}{l}
\\
\frac{\frac{1}{s \cdot e^{\frac{x}{s}}}}{4}
\end{array}
Initial program 99.2%
fabs-neg99.2%
distribute-frac-neg99.2%
distribute-frac-neg299.2%
fabs-neg99.2%
*-commutative99.2%
fabs-neg99.2%
+-commutative99.2%
fabs-neg99.2%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-/r*99.2%
mul-1-neg99.2%
distribute-neg-frac299.2%
+-commutative99.2%
mul-1-neg99.2%
distribute-neg-frac299.2%
Simplified99.2%
Taylor expanded in s around inf 94.6%
Applied egg-rr60.0%
unpow-160.0%
Simplified60.0%
Final simplification60.0%
(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(Float32(-x) / 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.2%
fabs-neg99.2%
distribute-frac-neg99.2%
distribute-frac-neg299.2%
fabs-neg99.2%
*-commutative99.2%
fabs-neg99.2%
+-commutative99.2%
fabs-neg99.2%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-/r*99.2%
mul-1-neg99.2%
distribute-neg-frac299.2%
+-commutative99.2%
mul-1-neg99.2%
distribute-neg-frac299.2%
Simplified99.2%
distribute-frac-neg299.2%
rec-exp99.2%
pow199.2%
pow199.2%
add-sqr-sqrt53.3%
fabs-sqr53.3%
add-sqr-sqrt96.6%
Applied egg-rr96.6%
rec-exp96.6%
distribute-neg-frac296.6%
Simplified96.6%
distribute-frac-neg299.2%
rec-exp99.2%
pow199.2%
pow199.2%
add-sqr-sqrt53.3%
fabs-sqr53.3%
add-sqr-sqrt96.6%
Applied egg-rr62.9%
rec-exp96.6%
distribute-neg-frac296.6%
Simplified63.0%
Taylor expanded in x around 0 60.0%
Final simplification60.0%
(FPCore (x s) :precision binary32 (/ (- (+ 0.25 (/ (* x -0.125) s)) (* 0.5 (/ (* x -0.25) s))) s))
float code(float x, float s) {
return ((0.25f + ((x * -0.125f) / s)) - (0.5f * ((x * -0.25f) / s))) / s;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = ((0.25e0 + ((x * (-0.125e0)) / s)) - (0.5e0 * ((x * (-0.25e0)) / s))) / s
end function
function code(x, s) return Float32(Float32(Float32(Float32(0.25) + Float32(Float32(x * Float32(-0.125)) / s)) - Float32(Float32(0.5) * Float32(Float32(x * Float32(-0.25)) / s))) / s) end
function tmp = code(x, s) tmp = ((single(0.25) + ((x * single(-0.125)) / s)) - (single(0.5) * ((x * single(-0.25)) / s))) / s; end
\begin{array}{l}
\\
\frac{\left(0.25 + \frac{x \cdot -0.125}{s}\right) - 0.5 \cdot \frac{x \cdot -0.25}{s}}{s}
\end{array}
Initial program 99.2%
fabs-neg99.2%
distribute-frac-neg99.2%
distribute-frac-neg299.2%
fabs-neg99.2%
*-commutative99.2%
fabs-neg99.2%
+-commutative99.2%
fabs-neg99.2%
Simplified99.3%
associate-*r*99.2%
associate-/r*99.2%
distribute-rgt-in99.2%
*-un-lft-identity99.2%
*-commutative99.2%
distribute-frac-neg299.2%
rec-exp99.2%
div-inv99.2%
associate-/r*99.2%
Applied egg-rr59.4%
Taylor expanded in s around inf 35.5%
Taylor expanded in s around -inf 66.8%
mul-1-neg66.8%
distribute-rgt-out--66.8%
metadata-eval66.8%
associate-*r/67.6%
*-commutative67.6%
Simplified67.6%
Final simplification67.6%
(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.2%
fabs-neg99.2%
distribute-frac-neg99.2%
distribute-frac-neg299.2%
fabs-neg99.2%
*-commutative99.2%
fabs-neg99.2%
+-commutative99.2%
fabs-neg99.2%
Simplified99.3%
Taylor expanded in s around inf 24.2%
Final simplification24.2%
(FPCore (x s) :precision binary32 1.0)
float code(float x, float s) {
return 1.0f;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0
end function
function code(x, s) return Float32(1.0) end
function tmp = code(x, s) tmp = single(1.0); end
\begin{array}{l}
\\
1
\end{array}
Initial program 99.2%
fabs-neg99.2%
distribute-frac-neg99.2%
distribute-frac-neg299.2%
fabs-neg99.2%
*-commutative99.2%
fabs-neg99.2%
+-commutative99.2%
fabs-neg99.2%
Simplified99.3%
Applied egg-rr85.1%
Taylor expanded in x around inf 40.2%
Taylor expanded in x around 0 8.2%
Final simplification8.2%
herbie shell --seed 2024059
(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))))))