
(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 17 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) 4.0)))
(/
(*
(/
1.0
(*
(pow (* E (exp 0.6666666666666666)) t_0)
(exp (* t_0 0.3333333333333333))))
(/ (/ 1.0 s) (pow E (/ (fabs x) (* s 2.0)))))
(pow (+ 1.0 (exp (/ (fabs x) (- s)))) 2.0))))
float code(float x, float s) {
float t_0 = (fabsf(x) / s) / 4.0f;
return ((1.0f / (powf((((float) M_E) * expf(0.6666666666666666f)), t_0) * expf((t_0 * 0.3333333333333333f)))) * ((1.0f / s) / powf(((float) M_E), (fabsf(x) / (s * 2.0f))))) / powf((1.0f + expf((fabsf(x) / -s))), 2.0f);
}
function code(x, s) t_0 = Float32(Float32(abs(x) / s) / Float32(4.0)) return Float32(Float32(Float32(Float32(1.0) / Float32((Float32(Float32(exp(1)) * exp(Float32(0.6666666666666666))) ^ t_0) * exp(Float32(t_0 * Float32(0.3333333333333333))))) * Float32(Float32(Float32(1.0) / s) / (Float32(exp(1)) ^ Float32(abs(x) / Float32(s * Float32(2.0)))))) / (Float32(Float32(1.0) + exp(Float32(abs(x) / Float32(-s)))) ^ Float32(2.0))) end
function tmp = code(x, s) t_0 = (abs(x) / s) / single(4.0); tmp = ((single(1.0) / (((single(2.71828182845904523536) * exp(single(0.6666666666666666))) ^ t_0) * exp((t_0 * single(0.3333333333333333))))) * ((single(1.0) / s) / (single(2.71828182845904523536) ^ (abs(x) / (s * single(2.0)))))) / ((single(1.0) + exp((abs(x) / -s))) ^ single(2.0)); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\frac{\left|x\right|}{s}}{4}\\
\frac{\frac{1}{{\left(e \cdot e^{0.6666666666666666}\right)}^{t\_0} \cdot e^{t\_0 \cdot 0.3333333333333333}} \cdot \frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}}}{{\left(1 + e^{\frac{\left|x\right|}{-s}}\right)}^{2}}
\end{array}
\end{array}
Initial program 99.1%
associate-*l*N/A
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
exp-lowering-exp.f32N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
neg-lowering-neg.f32N/A
pow2N/A
pow-lowering-pow.f32N/A
Applied egg-rr99.1%
div-invN/A
distribute-frac-neg2N/A
exp-negN/A
associate-*l/N/A
*-lft-identityN/A
pow-expN/A
sqr-powN/A
times-fracN/A
*-lowering-*.f32N/A
Applied egg-rr99.4%
sqr-powN/A
pow-prod-downN/A
add-cube-cbrtN/A
associate-*r*N/A
unpow-prod-downN/A
*-lowering-*.f32N/A
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x s)
:precision binary32
(/
(*
(/ (/ 1.0 s) (pow E (/ (fabs x) (* s 2.0))))
(/
1.0
(*
(pow (* E (exp 0.6666666666666666)) (/ (/ (fabs x) s) 4.0))
(exp (/ (* (fabs x) 0.08333333333333333) s)))))
(pow (+ 1.0 (exp (/ (fabs x) (- s)))) 2.0)))
float code(float x, float s) {
return (((1.0f / s) / powf(((float) M_E), (fabsf(x) / (s * 2.0f)))) * (1.0f / (powf((((float) M_E) * expf(0.6666666666666666f)), ((fabsf(x) / s) / 4.0f)) * expf(((fabsf(x) * 0.08333333333333333f) / s))))) / powf((1.0f + expf((fabsf(x) / -s))), 2.0f);
}
function code(x, s) return Float32(Float32(Float32(Float32(Float32(1.0) / s) / (Float32(exp(1)) ^ Float32(abs(x) / Float32(s * Float32(2.0))))) * Float32(Float32(1.0) / Float32((Float32(Float32(exp(1)) * exp(Float32(0.6666666666666666))) ^ Float32(Float32(abs(x) / s) / Float32(4.0))) * exp(Float32(Float32(abs(x) * Float32(0.08333333333333333)) / s))))) / (Float32(Float32(1.0) + exp(Float32(abs(x) / Float32(-s)))) ^ Float32(2.0))) end
function tmp = code(x, s) tmp = (((single(1.0) / s) / (single(2.71828182845904523536) ^ (abs(x) / (s * single(2.0))))) * (single(1.0) / (((single(2.71828182845904523536) * exp(single(0.6666666666666666))) ^ ((abs(x) / s) / single(4.0))) * exp(((abs(x) * single(0.08333333333333333)) / s))))) / ((single(1.0) + exp((abs(x) / -s))) ^ single(2.0)); end
\begin{array}{l}
\\
\frac{\frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}} \cdot \frac{1}{{\left(e \cdot e^{0.6666666666666666}\right)}^{\left(\frac{\frac{\left|x\right|}{s}}{4}\right)} \cdot e^{\frac{\left|x\right| \cdot 0.08333333333333333}{s}}}}{{\left(1 + e^{\frac{\left|x\right|}{-s}}\right)}^{2}}
\end{array}
Initial program 99.1%
associate-*l*N/A
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
exp-lowering-exp.f32N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
neg-lowering-neg.f32N/A
pow2N/A
pow-lowering-pow.f32N/A
Applied egg-rr99.1%
div-invN/A
distribute-frac-neg2N/A
exp-negN/A
associate-*l/N/A
*-lft-identityN/A
pow-expN/A
sqr-powN/A
times-fracN/A
*-lowering-*.f32N/A
Applied egg-rr99.4%
sqr-powN/A
pow-prod-downN/A
add-cube-cbrtN/A
associate-*r*N/A
unpow-prod-downN/A
*-lowering-*.f32N/A
Applied egg-rr99.4%
Taylor expanded in x around 0
associate-*r/N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
fabs-lowering-fabs.f3299.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x s) :precision binary32 (/ (* (/ (/ 1.0 s) (pow E (/ (fabs x) (* s 2.0)))) (pow E (/ (/ (fabs x) s) -2.0))) (pow (+ 1.0 (exp (/ (fabs x) (- s)))) 2.0)))
float code(float x, float s) {
return (((1.0f / s) / powf(((float) M_E), (fabsf(x) / (s * 2.0f)))) * powf(((float) M_E), ((fabsf(x) / s) / -2.0f))) / powf((1.0f + expf((fabsf(x) / -s))), 2.0f);
}
function code(x, s) return Float32(Float32(Float32(Float32(Float32(1.0) / s) / (Float32(exp(1)) ^ Float32(abs(x) / Float32(s * Float32(2.0))))) * (Float32(exp(1)) ^ Float32(Float32(abs(x) / s) / Float32(-2.0)))) / (Float32(Float32(1.0) + exp(Float32(abs(x) / Float32(-s)))) ^ Float32(2.0))) end
function tmp = code(x, s) tmp = (((single(1.0) / s) / (single(2.71828182845904523536) ^ (abs(x) / (s * single(2.0))))) * (single(2.71828182845904523536) ^ ((abs(x) / s) / single(-2.0)))) / ((single(1.0) + exp((abs(x) / -s))) ^ single(2.0)); end
\begin{array}{l}
\\
\frac{\frac{\frac{1}{s}}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}} \cdot {e}^{\left(\frac{\frac{\left|x\right|}{s}}{-2}\right)}}{{\left(1 + e^{\frac{\left|x\right|}{-s}}\right)}^{2}}
\end{array}
Initial program 99.1%
associate-*l*N/A
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
exp-lowering-exp.f32N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
neg-lowering-neg.f32N/A
pow2N/A
pow-lowering-pow.f32N/A
Applied egg-rr99.1%
div-invN/A
distribute-frac-neg2N/A
exp-negN/A
associate-*l/N/A
*-lft-identityN/A
pow-expN/A
sqr-powN/A
times-fracN/A
*-lowering-*.f32N/A
Applied egg-rr99.4%
pow-flipN/A
associate-/r*N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
pow-lowering-pow.f32N/A
E-lowering-E.f32N/A
distribute-frac-neg2N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
metadata-eval99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x s) :precision binary32 (/ (* (/ 1.0 (pow E (/ (fabs x) (* s 2.0)))) (/ (exp (/ (/ (fabs x) s) -2.0)) s)) (pow (+ 1.0 (exp (/ (fabs x) (- s)))) 2.0)))
float code(float x, float s) {
return ((1.0f / powf(((float) M_E), (fabsf(x) / (s * 2.0f)))) * (expf(((fabsf(x) / s) / -2.0f)) / s)) / powf((1.0f + expf((fabsf(x) / -s))), 2.0f);
}
function code(x, s) return Float32(Float32(Float32(Float32(1.0) / (Float32(exp(1)) ^ Float32(abs(x) / Float32(s * Float32(2.0))))) * Float32(exp(Float32(Float32(abs(x) / s) / Float32(-2.0))) / s)) / (Float32(Float32(1.0) + exp(Float32(abs(x) / Float32(-s)))) ^ Float32(2.0))) end
function tmp = code(x, s) tmp = ((single(1.0) / (single(2.71828182845904523536) ^ (abs(x) / (s * single(2.0))))) * (exp(((abs(x) / s) / single(-2.0))) / s)) / ((single(1.0) + exp((abs(x) / -s))) ^ single(2.0)); end
\begin{array}{l}
\\
\frac{\frac{1}{{e}^{\left(\frac{\left|x\right|}{s \cdot 2}\right)}} \cdot \frac{e^{\frac{\frac{\left|x\right|}{s}}{-2}}}{s}}{{\left(1 + e^{\frac{\left|x\right|}{-s}}\right)}^{2}}
\end{array}
Initial program 99.1%
associate-*l*N/A
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
exp-lowering-exp.f32N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
neg-lowering-neg.f32N/A
pow2N/A
pow-lowering-pow.f32N/A
Applied egg-rr99.1%
div-invN/A
distribute-frac-neg2N/A
exp-negN/A
associate-*l/N/A
*-lft-identityN/A
pow-expN/A
sqr-powN/A
times-fracN/A
*-lowering-*.f32N/A
Applied egg-rr99.4%
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f32N/A
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x s) :precision binary32 (/ (/ (pow (* E E) (/ (fabs x) (- 0.0 (* s 2.0)))) s) (pow (+ 1.0 (exp (/ (fabs x) (- s)))) 2.0)))
float code(float x, float s) {
return (powf((((float) M_E) * ((float) M_E)), (fabsf(x) / (0.0f - (s * 2.0f)))) / s) / powf((1.0f + expf((fabsf(x) / -s))), 2.0f);
}
function code(x, s) return Float32(Float32((Float32(Float32(exp(1)) * Float32(exp(1))) ^ Float32(abs(x) / Float32(Float32(0.0) - Float32(s * Float32(2.0))))) / s) / (Float32(Float32(1.0) + exp(Float32(abs(x) / Float32(-s)))) ^ Float32(2.0))) end
function tmp = code(x, s) tmp = (((single(2.71828182845904523536) * single(2.71828182845904523536)) ^ (abs(x) / (single(0.0) - (s * single(2.0))))) / s) / ((single(1.0) + exp((abs(x) / -s))) ^ single(2.0)); end
\begin{array}{l}
\\
\frac{\frac{{\left(e \cdot e\right)}^{\left(\frac{\left|x\right|}{0 - s \cdot 2}\right)}}{s}}{{\left(1 + e^{\frac{\left|x\right|}{-s}}\right)}^{2}}
\end{array}
Initial program 99.1%
associate-*l*N/A
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
exp-lowering-exp.f32N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
neg-lowering-neg.f32N/A
pow2N/A
pow-lowering-pow.f32N/A
Applied egg-rr99.1%
distribute-frac-neg2N/A
exp-negN/A
*-lft-identityN/A
pow-expN/A
sqr-powN/A
pow-prod-downN/A
pow-flipN/A
pow-lowering-pow.f32N/A
*-lowering-*.f32N/A
exp-1-eN/A
E-lowering-E.f32N/A
exp-1-eN/A
E-lowering-E.f32N/A
neg-lowering-neg.f32N/A
associate-/l/N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
*-commutativeN/A
*-lowering-*.f3299.2%
Applied egg-rr99.2%
Final simplification99.2%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (fabs x) (- s))))) (/ (/ t_0 s) (pow (+ 1.0 t_0) 2.0))))
float code(float x, float s) {
float t_0 = expf((fabsf(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((abs(x) / -s))
code = (t_0 / s) / ((1.0e0 + t_0) ** 2.0e0)
end function
function code(x, s) t_0 = exp(Float32(abs(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((abs(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{\left|x\right|}{-s}}\\
\frac{\frac{t\_0}{s}}{{\left(1 + t\_0\right)}^{2}}
\end{array}
\end{array}
Initial program 99.1%
associate-*l*N/A
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
exp-lowering-exp.f32N/A
distribute-frac-negN/A
distribute-neg-frac2N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
neg-lowering-neg.f32N/A
pow2N/A
pow-lowering-pow.f32N/A
Applied egg-rr99.1%
Final simplification99.1%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ 2.0 (* 2.0 (cosh (/ (fabs x) s)))))))
float code(float x, float s) {
return 1.0f / (s * (2.0f + (2.0f * coshf((fabsf(x) / s)))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (s * (2.0e0 + (2.0e0 * cosh((abs(x) / s)))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * cosh(Float32(abs(x) / s)))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * cosh((abs(x) / s))))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(2 + 2 \cdot \cosh \left(\frac{\left|x\right|}{s}\right)\right)}
\end{array}
Initial program 99.1%
Simplified98.9%
associate-/l/N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
associate-+r+N/A
+-commutativeN/A
+-lowering-+.f32N/A
distribute-frac-negN/A
+-commutativeN/A
distribute-frac-negN/A
cosh-undefN/A
*-lowering-*.f32N/A
cosh-lowering-cosh.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.0%
Applied egg-rr99.0%
(FPCore (x s) :precision binary32 (/ (/ 1.0 s) (+ (exp (/ (fabs x) s)) 3.0)))
float code(float x, float s) {
return (1.0f / s) / (expf((fabsf(x) / s)) + 3.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / s) / (exp((abs(x) / s)) + 3.0e0)
end function
function code(x, s) return Float32(Float32(Float32(1.0) / s) / Float32(exp(Float32(abs(x) / s)) + Float32(3.0))) end
function tmp = code(x, s) tmp = (single(1.0) / s) / (exp((abs(x) / s)) + single(3.0)); end
\begin{array}{l}
\\
\frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + 3}
\end{array}
Initial program 99.1%
Simplified98.9%
*-lft-identityN/A
exp-prodN/A
pow-lowering-pow.f32N/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3298.9%
Applied egg-rr98.9%
Taylor expanded in s around inf
Simplified94.1%
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
+-commutativeN/A
associate-+l+N/A
metadata-evalN/A
+-lowering-+.f32N/A
pow-expN/A
*-lft-identityN/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3294.1%
Applied egg-rr94.1%
(FPCore (x s) :precision binary32 (/ (/ (exp (/ (fabs x) (- s))) 4.0) s))
float code(float x, float s) {
return (expf((fabsf(x) / -s)) / 4.0f) / s;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (exp((abs(x) / -s)) / 4.0e0) / s
end function
function code(x, s) return Float32(Float32(exp(Float32(abs(x) / Float32(-s))) / Float32(4.0)) / s) end
function tmp = code(x, s) tmp = (exp((abs(x) / -s)) / single(4.0)) / s; end
\begin{array}{l}
\\
\frac{\frac{e^{\frac{\left|x\right|}{-s}}}{4}}{s}
\end{array}
Initial program 99.1%
Taylor expanded in s around inf
*-commutativeN/A
*-lowering-*.f3291.9%
Simplified91.9%
distribute-frac-negN/A
distribute-frac-neg2N/A
*-commutativeN/A
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
distribute-frac-neg2N/A
distribute-frac-negN/A
exp-lowering-exp.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
neg-lowering-neg.f3291.9%
Applied egg-rr91.9%
(FPCore (x s) :precision binary32 (/ (exp (/ (fabs x) (- s))) (* s 4.0)))
float code(float x, float s) {
return expf((fabsf(x) / -s)) / (s * 4.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = exp((abs(x) / -s)) / (s * 4.0e0)
end function
function code(x, s) return Float32(exp(Float32(abs(x) / Float32(-s))) / Float32(s * Float32(4.0))) end
function tmp = code(x, s) tmp = exp((abs(x) / -s)) / (s * single(4.0)); end
\begin{array}{l}
\\
\frac{e^{\frac{\left|x\right|}{-s}}}{s \cdot 4}
\end{array}
Initial program 99.1%
Taylor expanded in s around inf
*-commutativeN/A
*-lowering-*.f3291.9%
Simplified91.9%
Final simplification91.9%
(FPCore (x s) :precision binary32 (/ (/ 0.25 (exp (/ (fabs x) s))) s))
float code(float x, float s) {
return (0.25f / expf((fabsf(x) / s))) / s;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (0.25e0 / exp((abs(x) / s))) / s
end function
function code(x, s) return Float32(Float32(Float32(0.25) / exp(Float32(abs(x) / s))) / s) end
function tmp = code(x, s) tmp = (single(0.25) / exp((abs(x) / s))) / s; end
\begin{array}{l}
\\
\frac{\frac{0.25}{e^{\frac{\left|x\right|}{s}}}}{s}
\end{array}
Initial program 99.1%
Taylor expanded in s around inf
*-commutativeN/A
*-lowering-*.f3291.9%
Simplified91.9%
Taylor expanded in x around 0
associate-*r/N/A
/-lowering-/.f32N/A
neg-mul-1N/A
rec-expN/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f32N/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3291.8%
Simplified91.8%
(FPCore (x s) :precision binary32 (/ 0.25 (* s (exp (/ (fabs x) s)))))
float code(float x, float s) {
return 0.25f / (s * expf((fabsf(x) / s)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.25e0 / (s * exp((abs(x) / s)))
end function
function code(x, s) return Float32(Float32(0.25) / Float32(s * exp(Float32(abs(x) / s)))) end
function tmp = code(x, s) tmp = single(0.25) / (s * exp((abs(x) / s))); end
\begin{array}{l}
\\
\frac{0.25}{s \cdot e^{\frac{\left|x\right|}{s}}}
\end{array}
Initial program 99.1%
Taylor expanded in s around inf
*-commutativeN/A
*-lowering-*.f3291.9%
Simplified91.9%
Taylor expanded in x around 0
associate-*r/N/A
/-lowering-/.f32N/A
neg-mul-1N/A
rec-expN/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f32N/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3291.8%
Simplified91.8%
associate-/l/N/A
/-lowering-/.f32N/A
*-lft-identityN/A
pow-expN/A
*-lowering-*.f32N/A
pow-expN/A
*-lft-identityN/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3291.8%
Applied egg-rr91.8%
(FPCore (x s) :precision binary32 (if (<= (fabs x) 1.5000000786160286e-23) (/ (- 0.25 (* (/ x s) (/ (* x 0.0625) s))) s) (/ (/ 1.0 (+ 4.0 (/ (* x x) (* s s)))) s)))
float code(float x, float s) {
float tmp;
if (fabsf(x) <= 1.5000000786160286e-23f) {
tmp = (0.25f - ((x / s) * ((x * 0.0625f) / s))) / s;
} else {
tmp = (1.0f / (4.0f + ((x * x) / (s * s)))) / s;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (abs(x) <= 1.5000000786160286e-23) then
tmp = (0.25e0 - ((x / s) * ((x * 0.0625e0) / s))) / s
else
tmp = (1.0e0 / (4.0e0 + ((x * x) / (s * s)))) / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (abs(x) <= Float32(1.5000000786160286e-23)) tmp = Float32(Float32(Float32(0.25) - Float32(Float32(x / s) * Float32(Float32(x * Float32(0.0625)) / s))) / s); else tmp = Float32(Float32(Float32(1.0) / Float32(Float32(4.0) + Float32(Float32(x * x) / Float32(s * s)))) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (abs(x) <= single(1.5000000786160286e-23)) tmp = (single(0.25) - ((x / s) * ((x * single(0.0625)) / s))) / s; else tmp = (single(1.0) / (single(4.0) + ((x * x) / (s * s)))) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 1.5000000786160286 \cdot 10^{-23}:\\
\;\;\;\;\frac{0.25 - \frac{x}{s} \cdot \frac{x \cdot 0.0625}{s}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{4 + \frac{x \cdot x}{s \cdot s}}}{s}\\
\end{array}
\end{array}
if (fabs.f32 x) < 1.50000008e-23Initial program 97.4%
Simplified96.7%
Taylor expanded in s around inf
Simplified47.6%
associate-*l*N/A
times-fracN/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f3266.3%
Applied egg-rr66.3%
if 1.50000008e-23 < (fabs.f32 x) Initial program 99.6%
Simplified99.7%
Taylor expanded in s around inf
associate-+r+N/A
distribute-lft1-inN/A
metadata-evalN/A
mul0-lftN/A
associate-+r+N/A
metadata-evalN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3283.6%
Simplified83.6%
(FPCore (x s) :precision binary32 (if (<= s 4.0000001089808046e-27) (/ (/ (/ (* (* x x) -0.0625) s) s) s) (/ (- 0.25 (* (/ x s) (/ (* x 0.0625) s))) s)))
float code(float x, float s) {
float tmp;
if (s <= 4.0000001089808046e-27f) {
tmp = ((((x * x) * -0.0625f) / s) / s) / s;
} else {
tmp = (0.25f - ((x / s) * ((x * 0.0625f) / s))) / s;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (s <= 4.0000001089808046e-27) then
tmp = ((((x * x) * (-0.0625e0)) / s) / s) / s
else
tmp = (0.25e0 - ((x / s) * ((x * 0.0625e0) / s))) / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (s <= Float32(4.0000001089808046e-27)) tmp = Float32(Float32(Float32(Float32(Float32(x * x) * Float32(-0.0625)) / s) / s) / s); else tmp = Float32(Float32(Float32(0.25) - Float32(Float32(x / s) * Float32(Float32(x * Float32(0.0625)) / s))) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (s <= single(4.0000001089808046e-27)) tmp = ((((x * x) * single(-0.0625)) / s) / s) / s; else tmp = (single(0.25) - ((x / s) * ((x * single(0.0625)) / s))) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;s \leq 4.0000001089808046 \cdot 10^{-27}:\\
\;\;\;\;\frac{\frac{\frac{\left(x \cdot x\right) \cdot -0.0625}{s}}{s}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25 - \frac{x}{s} \cdot \frac{x \cdot 0.0625}{s}}{s}\\
\end{array}
\end{array}
if s < 4.00000011e-27Initial program 98.2%
Simplified97.7%
Taylor expanded in s around inf
Simplified2.1%
Taylor expanded in x around inf
associate-*r/N/A
unpow3N/A
unpow2N/A
associate-/r*N/A
*-commutativeN/A
unpow2N/A
sqr-absN/A
unpow2N/A
associate-*l/N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
/-lowering-/.f32N/A
Simplified21.4%
associate-*r/N/A
/-lowering-/.f32N/A
associate-*r/N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
*-lowering-*.f3222.6%
Applied egg-rr22.6%
if 4.00000011e-27 < s Initial program 99.5%
Simplified99.6%
Taylor expanded in s around inf
Simplified35.7%
associate-*l*N/A
times-fracN/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f3237.8%
Applied egg-rr37.8%
Final simplification32.7%
(FPCore (x s) :precision binary32 (if (<= s 2.0000000063421537e-28) (/ (/ (/ (* (* x x) -0.0625) s) s) s) (/ 0.25 s)))
float code(float x, float s) {
float tmp;
if (s <= 2.0000000063421537e-28f) {
tmp = ((((x * x) * -0.0625f) / s) / s) / s;
} 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) :: tmp
if (s <= 2.0000000063421537e-28) then
tmp = ((((x * x) * (-0.0625e0)) / s) / s) / s
else
tmp = 0.25e0 / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (s <= Float32(2.0000000063421537e-28)) tmp = Float32(Float32(Float32(Float32(Float32(x * x) * Float32(-0.0625)) / s) / s) / s); else tmp = Float32(Float32(0.25) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (s <= single(2.0000000063421537e-28)) tmp = ((((x * x) * single(-0.0625)) / s) / s) / s; else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;s \leq 2.0000000063421537 \cdot 10^{-28}:\\
\;\;\;\;\frac{\frac{\frac{\left(x \cdot x\right) \cdot -0.0625}{s}}{s}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
\end{array}
if s < 2.00000001e-28Initial program 98.2%
Simplified97.5%
Taylor expanded in s around inf
Simplified2.1%
Taylor expanded in x around inf
associate-*r/N/A
unpow3N/A
unpow2N/A
associate-/r*N/A
*-commutativeN/A
unpow2N/A
sqr-absN/A
unpow2N/A
associate-*l/N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
/-lowering-/.f32N/A
Simplified21.8%
associate-*r/N/A
/-lowering-/.f32N/A
associate-*r/N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
*-lowering-*.f3223.0%
Applied egg-rr23.0%
if 2.00000001e-28 < s Initial program 99.5%
Taylor expanded in s around inf
/-lowering-/.f3236.9%
Simplified36.9%
Final simplification32.6%
(FPCore (x s) :precision binary32 (if (<= s 2.0000000063421537e-28) (/ (* -0.0625 (/ (/ (* x x) s) s)) s) (/ 0.25 s)))
float code(float x, float s) {
float tmp;
if (s <= 2.0000000063421537e-28f) {
tmp = (-0.0625f * (((x * x) / s) / s)) / s;
} 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) :: tmp
if (s <= 2.0000000063421537e-28) then
tmp = ((-0.0625e0) * (((x * x) / s) / s)) / s
else
tmp = 0.25e0 / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (s <= Float32(2.0000000063421537e-28)) tmp = Float32(Float32(Float32(-0.0625) * Float32(Float32(Float32(x * x) / s) / s)) / s); else tmp = Float32(Float32(0.25) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (s <= single(2.0000000063421537e-28)) tmp = (single(-0.0625) * (((x * x) / s) / s)) / s; else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;s \leq 2.0000000063421537 \cdot 10^{-28}:\\
\;\;\;\;\frac{-0.0625 \cdot \frac{\frac{x \cdot x}{s}}{s}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
\end{array}
if s < 2.00000001e-28Initial program 98.2%
Simplified97.5%
Taylor expanded in s around inf
Simplified2.1%
Taylor expanded in x around inf
associate-*r/N/A
unpow3N/A
unpow2N/A
associate-/r*N/A
*-commutativeN/A
unpow2N/A
sqr-absN/A
unpow2N/A
associate-*l/N/A
*-commutativeN/A
metadata-evalN/A
distribute-lft-neg-inN/A
/-lowering-/.f32N/A
Simplified21.8%
if 2.00000001e-28 < s Initial program 99.5%
Taylor expanded in s around inf
/-lowering-/.f3236.9%
Simplified36.9%
(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.1%
Taylor expanded in s around inf
/-lowering-/.f3228.7%
Simplified28.7%
herbie shell --seed 2024161
(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))))))