
(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
(/
(/
1.0
(+
(exp (/ (- 0.0 (fabs x)) s))
(+ 2.0 (pow (pow E (/ (/ (fabs x) s) 2.0)) 2.0))))
s))
float code(float x, float s) {
return (1.0f / (expf(((0.0f - fabsf(x)) / s)) + (2.0f + powf(powf(((float) M_E), ((fabsf(x) / s) / 2.0f)), 2.0f)))) / s;
}
function code(x, s) return Float32(Float32(Float32(1.0) / Float32(exp(Float32(Float32(Float32(0.0) - abs(x)) / s)) + Float32(Float32(2.0) + ((Float32(exp(1)) ^ Float32(Float32(abs(x) / s) / Float32(2.0))) ^ Float32(2.0))))) / s) end
function tmp = code(x, s) tmp = (single(1.0) / (exp(((single(0.0) - abs(x)) / s)) + (single(2.0) + ((single(2.71828182845904523536) ^ ((abs(x) / s) / single(2.0))) ^ single(2.0))))) / s; end
\begin{array}{l}
\\
\frac{\frac{1}{e^{\frac{0 - \left|x\right|}{s}} + \left(2 + {\left({e}^{\left(\frac{\frac{\left|x\right|}{s}}{2}\right)}\right)}^{2}\right)}}{s}
\end{array}
Initial program 99.8%
Simplified99.8%
*-lft-identityN/A
exp-prodN/A
pow-lowering-pow.f32N/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.9%
Applied egg-rr99.9%
metadata-evalN/A
pow-expN/A
pow-unpowN/A
neg-mul-1N/A
distribute-frac-neg2N/A
sqr-powN/A
pow2N/A
pow-lowering-pow.f32N/A
distribute-frac-neg2N/A
neg-mul-1N/A
associate-/l*N/A
pow-unpowN/A
pow-expN/A
metadata-evalN/A
pow-lowering-pow.f32N/A
exp-1-eN/A
E-lowering-E.f32N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x s) :precision binary32 (let* ((t_0 (/ (- 0.0 (fabs x)) s))) (/ (/ 1.0 (+ (exp t_0) (+ 2.0 (pow (exp -1.0) t_0)))) s)))
float code(float x, float s) {
float t_0 = (0.0f - fabsf(x)) / s;
return (1.0f / (expf(t_0) + (2.0f + powf(expf(-1.0f), t_0)))) / s;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
t_0 = (0.0e0 - abs(x)) / s
code = (1.0e0 / (exp(t_0) + (2.0e0 + (exp((-1.0e0)) ** t_0)))) / s
end function
function code(x, s) t_0 = Float32(Float32(Float32(0.0) - abs(x)) / s) return Float32(Float32(Float32(1.0) / Float32(exp(t_0) + Float32(Float32(2.0) + (exp(Float32(-1.0)) ^ t_0)))) / s) end
function tmp = code(x, s) t_0 = (single(0.0) - abs(x)) / s; tmp = (single(1.0) / (exp(t_0) + (single(2.0) + (exp(single(-1.0)) ^ t_0)))) / s; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{0 - \left|x\right|}{s}\\
\frac{\frac{1}{e^{t\_0} + \left(2 + {\left(e^{-1}\right)}^{t\_0}\right)}}{s}
\end{array}
\end{array}
Initial program 99.8%
Simplified99.8%
remove-double-divN/A
exp-negN/A
neg-mul-1N/A
exp-prodN/A
pow-flipN/A
distribute-frac-negN/A
pow-lowering-pow.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.f3299.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x s) :precision binary32 (/ (/ 1.0 (+ (exp (/ (- 0.0 (fabs x)) s)) (+ 2.0 (pow E (/ (fabs x) s))))) s))
float code(float x, float s) {
return (1.0f / (expf(((0.0f - fabsf(x)) / s)) + (2.0f + powf(((float) M_E), (fabsf(x) / s))))) / s;
}
function code(x, s) return Float32(Float32(Float32(1.0) / Float32(exp(Float32(Float32(Float32(0.0) - abs(x)) / s)) + Float32(Float32(2.0) + (Float32(exp(1)) ^ Float32(abs(x) / s))))) / s) end
function tmp = code(x, s) tmp = (single(1.0) / (exp(((single(0.0) - abs(x)) / s)) + (single(2.0) + (single(2.71828182845904523536) ^ (abs(x) / s))))) / s; end
\begin{array}{l}
\\
\frac{\frac{1}{e^{\frac{0 - \left|x\right|}{s}} + \left(2 + {e}^{\left(\frac{\left|x\right|}{s}\right)}\right)}}{s}
\end{array}
Initial program 99.8%
Simplified99.8%
*-lft-identityN/A
exp-prodN/A
pow-lowering-pow.f32N/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x s) :precision binary32 (/ (exp (- (log (+ 2.0 (* 2.0 (cosh (/ (fabs x) s))))))) s))
float code(float x, float s) {
return expf(-logf((2.0f + (2.0f * coshf((fabsf(x) / s)))))) / s;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = exp(-log((2.0e0 + (2.0e0 * cosh((abs(x) / s)))))) / s
end function
function code(x, s) return Float32(exp(Float32(-log(Float32(Float32(2.0) + Float32(Float32(2.0) * cosh(Float32(abs(x) / s))))))) / s) end
function tmp = code(x, s) tmp = exp(-log((single(2.0) + (single(2.0) * cosh((abs(x) / s)))))) / s; end
\begin{array}{l}
\\
\frac{e^{-\log \left(2 + 2 \cdot \cosh \left(\frac{\left|x\right|}{s}\right)\right)}}{s}
\end{array}
Initial program 99.8%
Simplified99.8%
inv-powN/A
pow-to-expN/A
exp-lowering-exp.f32N/A
*-lowering-*.f32N/A
Applied egg-rr99.8%
exp-lowering-exp.f32N/A
*-commutativeN/A
mul-1-negN/A
neg-lowering-neg.f32N/A
rem-exp-logN/A
log-lowering-log.f32N/A
rem-exp-logN/A
+-lowering-+.f32N/A
*-lowering-*.f32N/A
cosh-lowering-cosh.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.8%
Applied egg-rr99.8%
(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.8%
Simplified99.8%
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.8%
Applied egg-rr99.8%
(FPCore (x s) :precision binary32 (/ (exp (/ (- 0.0 (fabs x)) s)) (* s 4.0)))
float code(float x, float s) {
return expf(((0.0f - fabsf(x)) / s)) / (s * 4.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = exp(((0.0e0 - abs(x)) / s)) / (s * 4.0e0)
end function
function code(x, s) return Float32(exp(Float32(Float32(Float32(0.0) - abs(x)) / s)) / Float32(s * Float32(4.0))) end
function tmp = code(x, s) tmp = exp(((single(0.0) - abs(x)) / s)) / (s * single(4.0)); end
\begin{array}{l}
\\
\frac{e^{\frac{0 - \left|x\right|}{s}}}{s \cdot 4}
\end{array}
Initial program 99.8%
Taylor expanded in s around inf
*-commutativeN/A
*-lowering-*.f3296.2%
Simplified96.2%
Final simplification96.2%
(FPCore (x s) :precision binary32 (if (<= x 4.0000000126843074e-28) (/ (/ 1.0 (+ 4.0 (* x (* (/ 1.0 s) (/ x s))))) s) (/ (/ 1.0 s) (+ 4.0 (* x (* x (/ 1.0 (* s s))))))))
float code(float x, float s) {
float tmp;
if (x <= 4.0000000126843074e-28f) {
tmp = (1.0f / (4.0f + (x * ((1.0f / s) * (x / s))))) / s;
} else {
tmp = (1.0f / s) / (4.0f + (x * (x * (1.0f / (s * 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.0000000126843074e-28) then
tmp = (1.0e0 / (4.0e0 + (x * ((1.0e0 / s) * (x / s))))) / s
else
tmp = (1.0e0 / s) / (4.0e0 + (x * (x * (1.0e0 / (s * s)))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(4.0000000126843074e-28)) tmp = Float32(Float32(Float32(1.0) / Float32(Float32(4.0) + Float32(x * Float32(Float32(Float32(1.0) / s) * Float32(x / s))))) / s); else tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(x * Float32(x * Float32(Float32(1.0) / Float32(s * s)))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(4.0000000126843074e-28)) tmp = (single(1.0) / (single(4.0) + (x * ((single(1.0) / s) * (x / s))))) / s; else tmp = (single(1.0) / s) / (single(4.0) + (x * (x * (single(1.0) / (s * s))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.0000000126843074 \cdot 10^{-28}:\\
\;\;\;\;\frac{\frac{1}{4 + x \cdot \left(\frac{1}{s} \cdot \frac{x}{s}\right)}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{s}}{4 + x \cdot \left(x \cdot \frac{1}{s \cdot s}\right)}\\
\end{array}
\end{array}
if x < 4.00000001e-28Initial program 99.7%
Simplified99.7%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified77.8%
sub-negN/A
+-commutativeN/A
+-lowering-+.f32N/A
distribute-neg-fracN/A
/-lowering-/.f32N/A
distribute-frac-neg2N/A
remove-double-negN/A
associate-/l*N/A
*-lowering-*.f32N/A
/-lowering-/.f3278.4%
Applied egg-rr78.4%
associate-*l/N/A
div-invN/A
associate-*l*N/A
*-lowering-*.f32N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
/-lowering-/.f3286.3%
Applied egg-rr86.3%
if 4.00000001e-28 < x Initial program 99.9%
Simplified99.9%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified79.1%
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
sub-negN/A
+-lowering-+.f32N/A
distribute-neg-fracN/A
/-lowering-/.f32N/A
distribute-frac-neg2N/A
remove-double-negN/A
associate-/l*N/A
*-lowering-*.f32N/A
/-lowering-/.f3279.1%
Applied egg-rr79.1%
associate-*r/N/A
associate-/r*N/A
clear-numN/A
associate-/r/N/A
associate-*r*N/A
*-lowering-*.f32N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f3291.7%
Applied egg-rr91.7%
Final simplification88.7%
(FPCore (x s) :precision binary32 (if (<= x 3.000000157232057e-23) (/ (/ 1.0 s) (+ 4.0 (* (/ x s) (/ x s)))) (/ 1.0 (* s (+ 4.0 (/ (* x x) (* s s)))))))
float code(float x, float s) {
float tmp;
if (x <= 3.000000157232057e-23f) {
tmp = (1.0f / s) / (4.0f + ((x / s) * (x / s)));
} else {
tmp = 1.0f / (s * (4.0f + ((x * x) / (s * s))));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 3.000000157232057e-23) then
tmp = (1.0e0 / s) / (4.0e0 + ((x / s) * (x / s)))
else
tmp = 1.0e0 / (s * (4.0e0 + ((x * x) / (s * s))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(3.000000157232057e-23)) tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(Float32(x / s) * Float32(x / s)))); else tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(Float32(x * x) / Float32(s * s))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(3.000000157232057e-23)) tmp = (single(1.0) / s) / (single(4.0) + ((x / s) * (x / s))); else tmp = single(1.0) / (s * (single(4.0) + ((x * x) / (s * s)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.000000157232057 \cdot 10^{-23}:\\
\;\;\;\;\frac{\frac{1}{s}}{4 + \frac{x}{s} \cdot \frac{x}{s}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}\\
\end{array}
\end{array}
if x < 3.00000016e-23Initial program 99.7%
Simplified99.8%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified76.8%
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
sub-negN/A
+-lowering-+.f32N/A
distribute-neg-fracN/A
/-lowering-/.f32N/A
distribute-frac-neg2N/A
remove-double-negN/A
associate-/l*N/A
*-lowering-*.f32N/A
/-lowering-/.f3277.4%
Applied egg-rr77.4%
associate-*l/N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
/-lowering-/.f3277.4%
Applied egg-rr77.4%
if 3.00000016e-23 < x Initial program 99.9%
Simplified99.9%
associate-/l/N/A
associate-/r*N/A
clear-numN/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
Applied egg-rr99.9%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-lowering-+.f32N/A
unpow2N/A
sqr-absN/A
unpow2N/A
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3288.3%
Simplified88.3%
(FPCore (x s) :precision binary32 (if (<= x 1.0299999920896155e-13) (/ 0.25 s) (/ (/ 1.0 (/ (* x x) (* s s))) s)))
float code(float x, float s) {
float tmp;
if (x <= 1.0299999920896155e-13f) {
tmp = 0.25f / s;
} else {
tmp = (1.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 (x <= 1.0299999920896155e-13) then
tmp = 0.25e0 / s
else
tmp = (1.0e0 / ((x * x) / (s * s))) / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.0299999920896155e-13)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(Float32(1.0) / Float32(Float32(x * x) / Float32(s * s))) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.0299999920896155e-13)) tmp = single(0.25) / s; else tmp = (single(1.0) / ((x * x) / (s * s))) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.0299999920896155 \cdot 10^{-13}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\frac{x \cdot x}{s \cdot s}}}{s}\\
\end{array}
\end{array}
if x < 1.02999999e-13Initial program 99.7%
Taylor expanded in s around inf
/-lowering-/.f3239.0%
Simplified39.0%
if 1.02999999e-13 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified85.2%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3286.4%
Simplified86.4%
(FPCore (x s) :precision binary32 (if (<= x 1.0299999920896155e-13) (/ 0.25 s) (/ (/ (* s s) (* x x)) s)))
float code(float x, float s) {
float tmp;
if (x <= 1.0299999920896155e-13f) {
tmp = 0.25f / s;
} else {
tmp = ((s * s) / (x * 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 <= 1.0299999920896155e-13) then
tmp = 0.25e0 / s
else
tmp = ((s * s) / (x * x)) / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.0299999920896155e-13)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(Float32(s * s) / Float32(x * x)) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.0299999920896155e-13)) tmp = single(0.25) / s; else tmp = ((s * s) / (x * x)) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.0299999920896155 \cdot 10^{-13}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{s \cdot s}{x \cdot x}}{s}\\
\end{array}
\end{array}
if x < 1.02999999e-13Initial program 99.7%
Taylor expanded in s around inf
/-lowering-/.f3239.0%
Simplified39.0%
if 1.02999999e-13 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified85.2%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3282.4%
Simplified82.4%
(FPCore (x s) :precision binary32 (/ (/ 1.0 s) (+ 4.0 (* x (/ x (* s s))))))
float code(float x, float s) {
return (1.0f / s) / (4.0f + (x * (x / (s * s))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / s) / (4.0e0 + (x * (x / (s * s))))
end function
function code(x, s) return Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(x * Float32(x / Float32(s * s))))) end
function tmp = code(x, s) tmp = (single(1.0) / s) / (single(4.0) + (x * (x / (s * s)))); end
\begin{array}{l}
\\
\frac{\frac{1}{s}}{4 + x \cdot \frac{x}{s \cdot s}}
\end{array}
Initial program 99.8%
Simplified99.8%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified78.4%
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
sub-negN/A
+-lowering-+.f32N/A
distribute-neg-fracN/A
/-lowering-/.f32N/A
distribute-frac-neg2N/A
remove-double-negN/A
associate-/l*N/A
*-lowering-*.f32N/A
/-lowering-/.f3278.7%
Applied egg-rr78.7%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f32N/A
associate-/r*N/A
/-lowering-/.f32N/A
*-lowering-*.f3285.8%
Applied egg-rr85.8%
Final simplification85.8%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ 4.0 (/ (* x x) (* s s))))))
float code(float x, float s) {
return 1.0f / (s * (4.0f + ((x * x) / (s * s))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (s * (4.0e0 + ((x * x) / (s * s))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(Float32(x * x) / Float32(s * s))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (single(4.0) + ((x * x) / (s * s)))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}
\end{array}
Initial program 99.8%
Simplified99.8%
associate-/l/N/A
associate-/r*N/A
clear-numN/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
Applied egg-rr99.8%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-lowering-+.f32N/A
unpow2N/A
sqr-absN/A
unpow2N/A
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3280.2%
Simplified80.2%
(FPCore (x s) :precision binary32 (if (<= x 2.0000000233721948e-7) (/ 0.25 s) (/ 1.0 (/ x (/ s x)))))
float code(float x, float s) {
float tmp;
if (x <= 2.0000000233721948e-7f) {
tmp = 0.25f / s;
} else {
tmp = 1.0f / (x / (s / x));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 2.0000000233721948e-7) then
tmp = 0.25e0 / s
else
tmp = 1.0e0 / (x / (s / x))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(2.0000000233721948e-7)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(1.0) / Float32(x / Float32(s / x))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(2.0000000233721948e-7)) tmp = single(0.25) / s; else tmp = single(1.0) / (x / (s / x)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.0000000233721948 \cdot 10^{-7}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x}{\frac{s}{x}}}\\
\end{array}
\end{array}
if x < 2.00000002e-7Initial program 99.7%
Taylor expanded in s around inf
/-lowering-/.f3237.8%
Simplified37.8%
if 2.00000002e-7 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified88.0%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3273.0%
Simplified73.0%
clear-numN/A
associate-*r/N/A
/-lowering-/.f32N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f32N/A
/-lowering-/.f3274.5%
Applied egg-rr74.5%
(FPCore (x s) :precision binary32 (if (<= x 2.0000000233721948e-7) (/ 0.25 s) (/ 1.0 (* x (/ x s)))))
float code(float x, float s) {
float tmp;
if (x <= 2.0000000233721948e-7f) {
tmp = 0.25f / s;
} else {
tmp = 1.0f / (x * (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 <= 2.0000000233721948e-7) then
tmp = 0.25e0 / s
else
tmp = 1.0e0 / (x * (x / s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(2.0000000233721948e-7)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(1.0) / Float32(x * Float32(x / s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(2.0000000233721948e-7)) tmp = single(0.25) / s; else tmp = single(1.0) / (x * (x / s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.0000000233721948 \cdot 10^{-7}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \frac{x}{s}}\\
\end{array}
\end{array}
if x < 2.00000002e-7Initial program 99.7%
Taylor expanded in s around inf
/-lowering-/.f3237.8%
Simplified37.8%
if 2.00000002e-7 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified88.0%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3273.0%
Simplified73.0%
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f3273.0%
Applied egg-rr73.0%
clear-numN/A
associate-/l/N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
/-lowering-/.f3274.5%
Applied egg-rr74.5%
(FPCore (x s) :precision binary32 (if (<= x 2.0000000233721948e-7) (/ 0.25 s) (* s (/ 1.0 (* x x)))))
float code(float x, float s) {
float tmp;
if (x <= 2.0000000233721948e-7f) {
tmp = 0.25f / s;
} else {
tmp = s * (1.0f / (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 <= 2.0000000233721948e-7) then
tmp = 0.25e0 / s
else
tmp = s * (1.0e0 / (x * x))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(2.0000000233721948e-7)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(s * Float32(Float32(1.0) / Float32(x * x))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(2.0000000233721948e-7)) tmp = single(0.25) / s; else tmp = s * (single(1.0) / (x * x)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.0000000233721948 \cdot 10^{-7}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;s \cdot \frac{1}{x \cdot x}\\
\end{array}
\end{array}
if x < 2.00000002e-7Initial program 99.7%
Taylor expanded in s around inf
/-lowering-/.f3237.8%
Simplified37.8%
if 2.00000002e-7 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified88.0%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3273.0%
Simplified73.0%
clear-numN/A
associate-/r/N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f3273.0%
Applied egg-rr73.0%
Final simplification48.2%
(FPCore (x s) :precision binary32 (if (<= x 2.0000000233721948e-7) (/ 0.25 s) (/ s (* x x))))
float code(float x, float s) {
float tmp;
if (x <= 2.0000000233721948e-7f) {
tmp = 0.25f / s;
} else {
tmp = s / (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 <= 2.0000000233721948e-7) then
tmp = 0.25e0 / s
else
tmp = s / (x * x)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(2.0000000233721948e-7)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(s / Float32(x * x)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(2.0000000233721948e-7)) tmp = single(0.25) / s; else tmp = s / (x * x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.0000000233721948 \cdot 10^{-7}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{s}{x \cdot x}\\
\end{array}
\end{array}
if x < 2.00000002e-7Initial program 99.7%
Taylor expanded in s around inf
/-lowering-/.f3237.8%
Simplified37.8%
if 2.00000002e-7 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified88.0%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3273.0%
Simplified73.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.8%
Taylor expanded in s around inf
/-lowering-/.f3227.9%
Simplified27.9%
herbie shell --seed 2024155
(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))))))