
(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 9 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 (/ (fabs x) (- s)))) (/ (exp (fma (log1p (exp t_0)) -2.0 t_0)) s)))
float code(float x, float s) {
float t_0 = fabsf(x) / -s;
return expf(fmaf(log1pf(expf(t_0)), -2.0f, t_0)) / s;
}
function code(x, s) t_0 = Float32(abs(x) / Float32(-s)) return Float32(exp(fma(log1p(exp(t_0)), Float32(-2.0), t_0)) / s) end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left|x\right|}{-s}\\
\frac{e^{\mathsf{fma}\left(\mathsf{log1p}\left(e^{t\_0}\right), -2, t\_0\right)}}{s}
\end{array}
\end{array}
Initial program 99.5%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f32N/A
pow2N/A
pow-lowering-pow.f32N/A
+-commutativeN/A
+-lowering-+.f32N/A
exp-lowering-exp.f32N/A
distribute-frac-negN/A
neg-lowering-neg.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.5
Applied egg-rr99.5%
associate-/r*N/A
/-lowering-/.f32N/A
Applied egg-rr99.6%
exp-lowering-exp.f32N/A
sub-negN/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-neg-inN/A
accelerator-lowering-fma.f32N/A
Applied egg-rr99.6%
(FPCore (x s)
:precision binary32
(let* ((t_0 (exp (/ (fabs x) (- s)))) (t_1 (/ (fabs x) s)) (t_2 (+ t_0 1.0)))
(if (<= (/ t_0 (* t_2 (* s t_2))) 1.999999987845058e-8)
(/ t_0 s)
(/
1.0
(*
s
(fma
(/ x s)
(* (/ x s) 5.0)
(fma 4.0 t_1 (fma t_1 (* (+ t_1 1.0) -4.0) 4.0))))))))
float code(float x, float s) {
float t_0 = expf((fabsf(x) / -s));
float t_1 = fabsf(x) / s;
float t_2 = t_0 + 1.0f;
float tmp;
if ((t_0 / (t_2 * (s * t_2))) <= 1.999999987845058e-8f) {
tmp = t_0 / s;
} else {
tmp = 1.0f / (s * fmaf((x / s), ((x / s) * 5.0f), fmaf(4.0f, t_1, fmaf(t_1, ((t_1 + 1.0f) * -4.0f), 4.0f))));
}
return tmp;
}
function code(x, s) t_0 = exp(Float32(abs(x) / Float32(-s))) t_1 = Float32(abs(x) / s) t_2 = Float32(t_0 + Float32(1.0)) tmp = Float32(0.0) if (Float32(t_0 / Float32(t_2 * Float32(s * t_2))) <= Float32(1.999999987845058e-8)) tmp = Float32(t_0 / s); else tmp = Float32(Float32(1.0) / Float32(s * fma(Float32(x / s), Float32(Float32(x / s) * Float32(5.0)), fma(Float32(4.0), t_1, fma(t_1, Float32(Float32(t_1 + Float32(1.0)) * Float32(-4.0)), Float32(4.0)))))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left|x\right|}{-s}}\\
t_1 := \frac{\left|x\right|}{s}\\
t_2 := t\_0 + 1\\
\mathbf{if}\;\frac{t\_0}{t\_2 \cdot \left(s \cdot t\_2\right)} \leq 1.999999987845058 \cdot 10^{-8}:\\
\;\;\;\;\frac{t\_0}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\frac{x}{s}, \frac{x}{s} \cdot 5, \mathsf{fma}\left(4, t\_1, \mathsf{fma}\left(t\_1, \left(t\_1 + 1\right) \cdot -4, 4\right)\right)\right)}\\
\end{array}
\end{array}
if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 1.99999999e-8Initial program 99.7%
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f32N/A
pow2N/A
pow-lowering-pow.f32N/A
+-commutativeN/A
+-lowering-+.f32N/A
exp-lowering-exp.f32N/A
distribute-frac-negN/A
neg-lowering-neg.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.7
Applied egg-rr99.7%
associate-/r*N/A
/-lowering-/.f32N/A
Applied egg-rr99.7%
Taylor expanded in s around 0
neg-mul-1N/A
neg-lowering-neg.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.7
Simplified99.7%
if 1.99999999e-8 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) Initial program 99.0%
clear-numN/A
/-lowering-/.f32N/A
div-invN/A
distribute-frac-negN/A
exp-negN/A
remove-double-divN/A
associate-*l*N/A
*-commutativeN/A
Applied egg-rr99.0%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-commutativeN/A
associate-+r+N/A
associate-+l+N/A
Simplified74.7%
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
*-commutativeN/A
times-fracN/A
associate-*l*N/A
accelerator-lowering-fma.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
+-lowering-+.f32N/A
Applied egg-rr92.5%
associate-+l+N/A
*-commutativeN/A
div-invN/A
associate-*l*N/A
associate-/r/N/A
clear-numN/A
accelerator-lowering-fma.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
accelerator-lowering-fma.f32N/A
Applied egg-rr92.7%
Final simplification97.8%
(FPCore (x s)
:precision binary32
(let* ((t_0 (exp (/ (fabs x) (- s)))) (t_1 (/ (fabs x) s)) (t_2 (+ t_0 1.0)))
(if (<= (/ t_0 (* t_2 (* s t_2))) 1.999999987845058e-8)
0.0
(/
1.0
(*
s
(fma
(/ x s)
(* (/ x s) 5.0)
(fma 4.0 t_1 (fma t_1 (* (+ t_1 1.0) -4.0) 4.0))))))))
float code(float x, float s) {
float t_0 = expf((fabsf(x) / -s));
float t_1 = fabsf(x) / s;
float t_2 = t_0 + 1.0f;
float tmp;
if ((t_0 / (t_2 * (s * t_2))) <= 1.999999987845058e-8f) {
tmp = 0.0f;
} else {
tmp = 1.0f / (s * fmaf((x / s), ((x / s) * 5.0f), fmaf(4.0f, t_1, fmaf(t_1, ((t_1 + 1.0f) * -4.0f), 4.0f))));
}
return tmp;
}
function code(x, s) t_0 = exp(Float32(abs(x) / Float32(-s))) t_1 = Float32(abs(x) / s) t_2 = Float32(t_0 + Float32(1.0)) tmp = Float32(0.0) if (Float32(t_0 / Float32(t_2 * Float32(s * t_2))) <= Float32(1.999999987845058e-8)) tmp = Float32(0.0); else tmp = Float32(Float32(1.0) / Float32(s * fma(Float32(x / s), Float32(Float32(x / s) * Float32(5.0)), fma(Float32(4.0), t_1, fma(t_1, Float32(Float32(t_1 + Float32(1.0)) * Float32(-4.0)), Float32(4.0)))))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left|x\right|}{-s}}\\
t_1 := \frac{\left|x\right|}{s}\\
t_2 := t\_0 + 1\\
\mathbf{if}\;\frac{t\_0}{t\_2 \cdot \left(s \cdot t\_2\right)} \leq 1.999999987845058 \cdot 10^{-8}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\frac{x}{s}, \frac{x}{s} \cdot 5, \mathsf{fma}\left(4, t\_1, \mathsf{fma}\left(t\_1, \left(t\_1 + 1\right) \cdot -4, 4\right)\right)\right)}\\
\end{array}
\end{array}
if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 1.99999999e-8Initial program 99.7%
Taylor expanded in s around -inf
Simplified0.3%
Taylor expanded in s around 0
div-subN/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-outN/A
+-inverses99.0
Simplified99.0%
div0N/A
metadata-eval99.0
Applied egg-rr99.0%
if 1.99999999e-8 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) Initial program 99.0%
clear-numN/A
/-lowering-/.f32N/A
div-invN/A
distribute-frac-negN/A
exp-negN/A
remove-double-divN/A
associate-*l*N/A
*-commutativeN/A
Applied egg-rr99.0%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-commutativeN/A
associate-+r+N/A
associate-+l+N/A
Simplified74.7%
+-commutativeN/A
associate-+l+N/A
associate-+l+N/A
*-commutativeN/A
times-fracN/A
associate-*l*N/A
accelerator-lowering-fma.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
+-lowering-+.f32N/A
Applied egg-rr92.5%
associate-+l+N/A
*-commutativeN/A
div-invN/A
associate-*l*N/A
associate-/r/N/A
clear-numN/A
accelerator-lowering-fma.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
+-commutativeN/A
*-commutativeN/A
associate-*l*N/A
accelerator-lowering-fma.f32N/A
Applied egg-rr92.7%
Final simplification97.4%
(FPCore (x s)
:precision binary32
(let* ((t_0 (exp (/ (fabs x) (- s)))) (t_1 (/ (* x x) s)) (t_2 (+ t_0 1.0)))
(if (<= (/ t_0 (* t_2 (* s t_2))) 1.999999987845058e-8)
0.0
(/ 1.0 (* s (- (/ (fma t_1 -4.0 (fma 5.0 t_1 0.0)) s) -4.0))))))
float code(float x, float s) {
float t_0 = expf((fabsf(x) / -s));
float t_1 = (x * x) / s;
float t_2 = t_0 + 1.0f;
float tmp;
if ((t_0 / (t_2 * (s * t_2))) <= 1.999999987845058e-8f) {
tmp = 0.0f;
} else {
tmp = 1.0f / (s * ((fmaf(t_1, -4.0f, fmaf(5.0f, t_1, 0.0f)) / s) - -4.0f));
}
return tmp;
}
function code(x, s) t_0 = exp(Float32(abs(x) / Float32(-s))) t_1 = Float32(Float32(x * x) / s) t_2 = Float32(t_0 + Float32(1.0)) tmp = Float32(0.0) if (Float32(t_0 / Float32(t_2 * Float32(s * t_2))) <= Float32(1.999999987845058e-8)) tmp = Float32(0.0); else tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(fma(t_1, Float32(-4.0), fma(Float32(5.0), t_1, Float32(0.0))) / s) - Float32(-4.0)))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left|x\right|}{-s}}\\
t_1 := \frac{x \cdot x}{s}\\
t_2 := t\_0 + 1\\
\mathbf{if}\;\frac{t\_0}{t\_2 \cdot \left(s \cdot t\_2\right)} \leq 1.999999987845058 \cdot 10^{-8}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(\frac{\mathsf{fma}\left(t\_1, -4, \mathsf{fma}\left(5, t\_1, 0\right)\right)}{s} - -4\right)}\\
\end{array}
\end{array}
if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 1.99999999e-8Initial program 99.7%
Taylor expanded in s around -inf
Simplified0.3%
Taylor expanded in s around 0
div-subN/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-outN/A
+-inverses99.0
Simplified99.0%
div0N/A
metadata-eval99.0
Applied egg-rr99.0%
if 1.99999999e-8 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) Initial program 99.0%
clear-numN/A
/-lowering-/.f32N/A
div-invN/A
distribute-frac-negN/A
exp-negN/A
remove-double-divN/A
associate-*l*N/A
*-commutativeN/A
Applied egg-rr99.0%
Taylor expanded in s around -inf
mul-1-negN/A
neg-lowering-neg.f32N/A
*-lowering-*.f32N/A
sub-negN/A
metadata-evalN/A
Simplified90.1%
Final simplification96.7%
(FPCore (x s)
:precision binary32
(let* ((t_0 (exp (/ (fabs x) (- s)))) (t_1 (+ t_0 1.0)))
(if (<= (/ t_0 (* t_1 (* s t_1))) 1.999999987845058e-8)
0.0
(/ 1.0 (fma s 4.0 (/ (* x x) s))))))
float code(float x, float s) {
float t_0 = expf((fabsf(x) / -s));
float t_1 = t_0 + 1.0f;
float tmp;
if ((t_0 / (t_1 * (s * t_1))) <= 1.999999987845058e-8f) {
tmp = 0.0f;
} else {
tmp = 1.0f / fmaf(s, 4.0f, ((x * x) / s));
}
return tmp;
}
function code(x, s) t_0 = exp(Float32(abs(x) / Float32(-s))) t_1 = Float32(t_0 + Float32(1.0)) tmp = Float32(0.0) if (Float32(t_0 / Float32(t_1 * Float32(s * t_1))) <= Float32(1.999999987845058e-8)) tmp = Float32(0.0); else tmp = Float32(Float32(1.0) / fma(s, Float32(4.0), Float32(Float32(x * x) / s))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left|x\right|}{-s}}\\
t_1 := t\_0 + 1\\
\mathbf{if}\;\frac{t\_0}{t\_1 \cdot \left(s \cdot t\_1\right)} \leq 1.999999987845058 \cdot 10^{-8}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(s, 4, \frac{x \cdot x}{s}\right)}\\
\end{array}
\end{array}
if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 1.99999999e-8Initial program 99.7%
Taylor expanded in s around -inf
Simplified0.3%
Taylor expanded in s around 0
div-subN/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-outN/A
+-inverses99.0
Simplified99.0%
div0N/A
metadata-eval99.0
Applied egg-rr99.0%
if 1.99999999e-8 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) Initial program 99.0%
clear-numN/A
/-lowering-/.f32N/A
div-invN/A
distribute-frac-negN/A
exp-negN/A
remove-double-divN/A
associate-*l*N/A
*-commutativeN/A
Applied egg-rr99.0%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-commutativeN/A
associate-+r+N/A
associate-+l+N/A
Simplified74.7%
Taylor expanded in x around 0
+-commutativeN/A
distribute-rgt-outN/A
metadata-evalN/A
mul0-rgtN/A
metadata-evalN/A
accelerator-lowering-fma.f32N/A
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3290.1
Simplified90.1%
Final simplification96.7%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (fabs x) (- s)))) (t_1 (+ t_0 1.0))) (if (<= (/ t_0 (* t_1 (* s t_1))) 1.999999987845058e-8) 0.0 (/ 0.25 s))))
float code(float x, float s) {
float t_0 = expf((fabsf(x) / -s));
float t_1 = t_0 + 1.0f;
float tmp;
if ((t_0 / (t_1 * (s * t_1))) <= 1.999999987845058e-8f) {
tmp = 0.0f;
} else {
tmp = 0.25f / s;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: t_1
real(4) :: tmp
t_0 = exp((abs(x) / -s))
t_1 = t_0 + 1.0e0
if ((t_0 / (t_1 * (s * t_1))) <= 1.999999987845058e-8) then
tmp = 0.0e0
else
tmp = 0.25e0 / s
end if
code = tmp
end function
function code(x, s) t_0 = exp(Float32(abs(x) / Float32(-s))) t_1 = Float32(t_0 + Float32(1.0)) tmp = Float32(0.0) if (Float32(t_0 / Float32(t_1 * Float32(s * t_1))) <= Float32(1.999999987845058e-8)) tmp = Float32(0.0); else tmp = Float32(Float32(0.25) / s); end return tmp end
function tmp_2 = code(x, s) t_0 = exp((abs(x) / -s)); t_1 = t_0 + single(1.0); tmp = single(0.0); if ((t_0 / (t_1 * (s * t_1))) <= single(1.999999987845058e-8)) tmp = single(0.0); else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left|x\right|}{-s}}\\
t_1 := t\_0 + 1\\
\mathbf{if}\;\frac{t\_0}{t\_1 \cdot \left(s \cdot t\_1\right)} \leq 1.999999987845058 \cdot 10^{-8}:\\
\;\;\;\;0\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
\end{array}
if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 1.99999999e-8Initial program 99.7%
Taylor expanded in s around -inf
Simplified0.3%
Taylor expanded in s around 0
div-subN/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-outN/A
+-inverses99.0
Simplified99.0%
div0N/A
metadata-eval99.0
Applied egg-rr99.0%
if 1.99999999e-8 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) Initial program 99.0%
Taylor expanded in s around inf
/-lowering-/.f3288.4
Simplified88.4%
Final simplification96.2%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (fabs x) (- s))))) (/ t_0 (* (* s (- 2.0 (/ (fabs x) s))) (+ t_0 1.0)))))
float code(float x, float s) {
float t_0 = expf((fabsf(x) / -s));
return t_0 / ((s * (2.0f - (fabsf(x) / s))) * (t_0 + 1.0f));
}
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 * (2.0e0 - (abs(x) / s))) * (t_0 + 1.0e0))
end function
function code(x, s) t_0 = exp(Float32(abs(x) / Float32(-s))) return Float32(t_0 / Float32(Float32(s * Float32(Float32(2.0) - Float32(abs(x) / s))) * Float32(t_0 + Float32(1.0)))) end
function tmp = code(x, s) t_0 = exp((abs(x) / -s)); tmp = t_0 / ((s * (single(2.0) - (abs(x) / s))) * (t_0 + single(1.0))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left|x\right|}{-s}}\\
\frac{t\_0}{\left(s \cdot \left(2 - \frac{\left|x\right|}{s}\right)\right) \cdot \left(t\_0 + 1\right)}
\end{array}
\end{array}
Initial program 99.5%
Taylor expanded in s around inf
*-lowering-*.f32N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3295.9
Simplified95.9%
Final simplification95.9%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (fabs x) (- s))))) (/ t_0 (* (+ t_0 1.0) (* s 2.0)))))
float code(float x, float s) {
float t_0 = expf((fabsf(x) / -s));
return t_0 / ((t_0 + 1.0f) * (s * 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((abs(x) / -s))
code = t_0 / ((t_0 + 1.0e0) * (s * 2.0e0))
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(2.0)))) end
function tmp = code(x, s) t_0 = exp((abs(x) / -s)); tmp = t_0 / ((t_0 + single(1.0)) * (s * single(2.0))); 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 \cdot 2\right)}
\end{array}
\end{array}
Initial program 99.5%
Taylor expanded in s around inf
*-commutativeN/A
*-lowering-*.f3294.8
Simplified94.8%
Final simplification94.8%
(FPCore (x s) :precision binary32 0.0)
float code(float x, float s) {
return 0.0f;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.0e0
end function
function code(x, s) return Float32(0.0) end
function tmp = code(x, s) tmp = single(0.0); end
\begin{array}{l}
\\
0
\end{array}
Initial program 99.5%
Taylor expanded in s around -inf
Simplified16.3%
Taylor expanded in s around 0
div-subN/A
*-commutativeN/A
metadata-evalN/A
distribute-rgt-outN/A
+-inverses74.5
Simplified74.5%
div0N/A
metadata-eval74.5
Applied egg-rr74.5%
herbie shell --seed 2024198
(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))))))