
(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 (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(Float32(-abs(x)) / 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.8%
*-commutative99.8%
distribute-lft-in99.8%
*-rgt-identity99.8%
fabs-neg99.8%
distribute-frac-neg99.8%
exp-neg99.8%
associate-*r/99.8%
*-rgt-identity99.8%
*-lft-identity99.8%
metadata-eval99.8%
times-frac99.8%
neg-mul-199.8%
neg-mul-199.8%
fabs-neg99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x s) :precision binary32 (/ 1.0 (* (+ 1.0 (exp (/ x s))) (+ s (* s (exp (/ (- x) s)))))))
float code(float x, float s) {
return 1.0f / ((1.0f + expf((x / s))) * (s + (s * expf((-x / 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))) * (s + (s * exp((-x / s)))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + exp(Float32(x / s))) * Float32(s + Float32(s * exp(Float32(Float32(-x) / s)))))) end
function tmp = code(x, s) tmp = single(1.0) / ((single(1.0) + exp((x / s))) * (s + (s * exp((-x / s))))); end
\begin{array}{l}
\\
\frac{1}{\left(1 + e^{\frac{x}{s}}\right) \cdot \left(s + s \cdot e^{\frac{-x}{s}}\right)}
\end{array}
Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
mul-1-neg99.8%
exp-neg99.8%
add-sqr-sqrt50.3%
fabs-sqr50.3%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
rec-exp98.6%
distribute-neg-frac98.6%
Simplified98.6%
add-sqr-sqrt98.5%
sqrt-unprod98.6%
sqr-neg98.6%
distribute-frac-neg98.6%
distribute-frac-neg98.6%
sqrt-unprod-0.0%
add-sqr-sqrt62.4%
expm1-log1p-u62.3%
expm1-udef62.3%
Applied egg-rr99.7%
expm1-def99.7%
expm1-log1p99.8%
+-commutative99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x s) :precision binary32 (/ 1.0 (* (* s 2.0) (+ 1.0 (exp (/ (fabs x) s))))))
float code(float x, float s) {
return 1.0f / ((s * 2.0f) * (1.0f + expf((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) * (1.0e0 + exp((abs(x) / s))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(s * Float32(2.0)) * Float32(Float32(1.0) + exp(Float32(abs(x) / s))))) end
function tmp = code(x, s) tmp = single(1.0) / ((s * single(2.0)) * (single(1.0) + exp((abs(x) / s)))); end
\begin{array}{l}
\\
\frac{1}{\left(s \cdot 2\right) \cdot \left(1 + e^{\frac{\left|x\right|}{s}}\right)}
\end{array}
Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
mul-1-neg99.8%
exp-neg99.8%
add-sqr-sqrt50.3%
fabs-sqr50.3%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
rec-exp98.6%
distribute-neg-frac98.6%
Simplified98.6%
Taylor expanded in x around 0 96.7%
associate-*r*96.7%
Simplified96.7%
Final simplification96.7%
(FPCore (x s) :precision binary32 (/ 1.0 (* (* s 2.0) (+ 1.0 (pow E (/ x s))))))
float code(float x, float s) {
return 1.0f / ((s * 2.0f) * (1.0f + powf(((float) M_E), (x / s))));
}
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(s * Float32(2.0)) * Float32(Float32(1.0) + (Float32(exp(1)) ^ Float32(x / s))))) end
function tmp = code(x, s) tmp = single(1.0) / ((s * single(2.0)) * (single(1.0) + (single(2.71828182845904523536) ^ (x / s)))); end
\begin{array}{l}
\\
\frac{1}{\left(s \cdot 2\right) \cdot \left(1 + {e}^{\left(\frac{x}{s}\right)}\right)}
\end{array}
Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
mul-1-neg99.8%
exp-neg99.8%
add-sqr-sqrt50.3%
fabs-sqr50.3%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
rec-exp98.6%
distribute-neg-frac98.6%
Simplified98.6%
Taylor expanded in x around 0 96.7%
associate-*r*96.7%
Simplified96.7%
*-un-lft-identity96.7%
exp-prod96.7%
add-sqr-sqrt48.2%
fabs-sqr48.2%
add-sqr-sqrt59.6%
Applied egg-rr59.6%
exp-1-e59.6%
Simplified59.6%
Final simplification59.6%
(FPCore (x s) :precision binary32 (/ (/ 1.0 (* s 2.0)) (+ 1.0 (exp (/ x s)))))
float code(float x, float s) {
return (1.0f / (s * 2.0f)) / (1.0f + expf((x / s)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / (s * 2.0e0)) / (1.0e0 + exp((x / s)))
end function
function code(x, s) return Float32(Float32(Float32(1.0) / Float32(s * Float32(2.0))) / Float32(Float32(1.0) + exp(Float32(x / s)))) end
function tmp = code(x, s) tmp = (single(1.0) / (s * single(2.0))) / (single(1.0) + exp((x / s))); end
\begin{array}{l}
\\
\frac{\frac{1}{s \cdot 2}}{1 + e^{\frac{x}{s}}}
\end{array}
Initial program 99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
mul-1-neg99.8%
exp-neg99.8%
add-sqr-sqrt50.3%
fabs-sqr50.3%
add-sqr-sqrt98.6%
Applied egg-rr98.6%
rec-exp98.6%
distribute-neg-frac98.6%
Simplified98.6%
Taylor expanded in x around 0 96.7%
associate-*r*96.7%
Simplified96.7%
expm1-log1p-u95.5%
expm1-udef95.3%
associate-/r*95.3%
*-commutative95.3%
div-inv95.3%
add-sqr-sqrt47.5%
fabs-sqr47.5%
add-sqr-sqrt58.3%
div-inv58.3%
Applied egg-rr58.3%
expm1-def58.4%
expm1-log1p59.6%
Simplified59.6%
Final simplification59.6%
(FPCore (x s) :precision binary32 (if (<= x 1.999999987845058e-8) (/ 0.25 s) (/ 1.0 (* 3.0 (/ (pow x 2.0) s)))))
float code(float x, float s) {
float tmp;
if (x <= 1.999999987845058e-8f) {
tmp = 0.25f / s;
} else {
tmp = 1.0f / (3.0f * (powf(x, 2.0f) / 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.999999987845058e-8) then
tmp = 0.25e0 / s
else
tmp = 1.0e0 / (3.0e0 * ((x ** 2.0e0) / s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.999999987845058e-8)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(1.0) / Float32(Float32(3.0) * Float32((x ^ Float32(2.0)) / s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.999999987845058e-8)) tmp = single(0.25) / s; else tmp = single(1.0) / (single(3.0) * ((x ^ single(2.0)) / s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.999999987845058 \cdot 10^{-8}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{3 \cdot \frac{{x}^{2}}{s}}\\
\end{array}
\end{array}
if x < 1.99999999e-8Initial program 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in s around inf 34.5%
if 1.99999999e-8 < x Initial program 99.9%
Simplified99.9%
Applied egg-rr98.8%
associate-+r+98.8%
*-lft-identity98.8%
distribute-rgt-in98.8%
+-commutative98.8%
*-commutative98.8%
fma-udef98.8%
distribute-rgt-in98.8%
*-rgt-identity98.8%
distribute-lft-in98.8%
associate-*r*98.8%
distribute-lft-out98.8%
*-lft-identity98.8%
distribute-rgt-in98.8%
Simplified98.8%
Taylor expanded in x around 0 72.6%
Taylor expanded in x around inf 72.6%
Final simplification45.8%
(FPCore (x s) :precision binary32 (if (<= x 1.999999987845058e-8) (/ 0.25 s) (/ 1.0 (* (pow x 2.0) (/ 3.0 s)))))
float code(float x, float s) {
float tmp;
if (x <= 1.999999987845058e-8f) {
tmp = 0.25f / s;
} else {
tmp = 1.0f / (powf(x, 2.0f) * (3.0f / 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.999999987845058e-8) then
tmp = 0.25e0 / s
else
tmp = 1.0e0 / ((x ** 2.0e0) * (3.0e0 / s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.999999987845058e-8)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(1.0) / Float32((x ^ Float32(2.0)) * Float32(Float32(3.0) / s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.999999987845058e-8)) tmp = single(0.25) / s; else tmp = single(1.0) / ((x ^ single(2.0)) * (single(3.0) / s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.999999987845058 \cdot 10^{-8}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{{x}^{2} \cdot \frac{3}{s}}\\
\end{array}
\end{array}
if x < 1.99999999e-8Initial program 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in s around inf 34.5%
if 1.99999999e-8 < x Initial program 99.9%
Simplified99.9%
Applied egg-rr98.8%
associate-+r+98.8%
*-lft-identity98.8%
distribute-rgt-in98.8%
+-commutative98.8%
*-commutative98.8%
fma-udef98.8%
distribute-rgt-in98.8%
*-rgt-identity98.8%
distribute-lft-in98.8%
associate-*r*98.8%
distribute-lft-out98.8%
*-lft-identity98.8%
distribute-rgt-in98.8%
Simplified98.8%
Taylor expanded in x around 0 72.6%
Taylor expanded in x around inf 72.6%
associate-*r/72.6%
associate-/l*72.6%
Simplified72.6%
Taylor expanded in s around 0 72.6%
associate-*r/72.6%
associate-*l/72.6%
*-commutative72.6%
Simplified72.6%
Final simplification45.8%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (pow (+ (/ x s) 2.0) 2.0))))
float code(float x, float s) {
return 1.0f / (s * powf(((x / s) + 2.0f), 2.0f));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (s * (((x / s) + 2.0e0) ** 2.0e0))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * (Float32(Float32(x / s) + Float32(2.0)) ^ Float32(2.0)))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (((x / s) + single(2.0)) ^ single(2.0))); end
\begin{array}{l}
\\
\frac{1}{s \cdot {\left(\frac{x}{s} + 2\right)}^{2}}
\end{array}
Initial program 99.8%
Simplified99.8%
Applied egg-rr59.2%
associate-+r+59.2%
*-lft-identity59.2%
distribute-rgt-in59.2%
+-commutative59.2%
*-commutative59.2%
fma-udef59.2%
distribute-rgt-in59.2%
*-rgt-identity59.2%
distribute-lft-in59.2%
associate-*r*59.2%
distribute-lft-out59.3%
*-lft-identity59.3%
distribute-rgt-in59.3%
Simplified59.3%
Taylor expanded in x around 0 70.0%
Final simplification70.0%
(FPCore (x s) :precision binary32 (if (<= x 1.999999987845058e-8) (/ 0.25 s) (* 0.3333333333333333 (* s (pow x -2.0)))))
float code(float x, float s) {
float tmp;
if (x <= 1.999999987845058e-8f) {
tmp = 0.25f / s;
} else {
tmp = 0.3333333333333333f * (s * powf(x, -2.0f));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 1.999999987845058e-8) then
tmp = 0.25e0 / s
else
tmp = 0.3333333333333333e0 * (s * (x ** (-2.0e0)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.999999987845058e-8)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(0.3333333333333333) * Float32(s * (x ^ Float32(-2.0)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.999999987845058e-8)) tmp = single(0.25) / s; else tmp = single(0.3333333333333333) * (s * (x ^ single(-2.0))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.999999987845058 \cdot 10^{-8}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \left(s \cdot {x}^{-2}\right)\\
\end{array}
\end{array}
if x < 1.99999999e-8Initial program 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in s around inf 34.5%
if 1.99999999e-8 < x Initial program 99.9%
Simplified99.9%
Applied egg-rr98.8%
associate-+r+98.8%
*-lft-identity98.8%
distribute-rgt-in98.8%
+-commutative98.8%
*-commutative98.8%
fma-udef98.8%
distribute-rgt-in98.8%
*-rgt-identity98.8%
distribute-lft-in98.8%
associate-*r*98.8%
distribute-lft-out98.8%
*-lft-identity98.8%
distribute-rgt-in98.8%
Simplified98.8%
Taylor expanded in x around 0 72.6%
Taylor expanded in x around inf 72.6%
associate-*r/72.6%
associate-/l*72.6%
Simplified72.6%
expm1-log1p-u72.6%
expm1-udef90.2%
associate-/r/90.2%
metadata-eval90.2%
div-inv90.2%
pow-flip90.2%
metadata-eval90.2%
Applied egg-rr90.2%
expm1-def69.8%
expm1-log1p69.8%
Simplified69.8%
Final simplification45.0%
(FPCore (x s) :precision binary32 (if (<= x 1.999999987845058e-8) (/ 0.25 s) (* 0.3333333333333333 (/ s (pow x 2.0)))))
float code(float x, float s) {
float tmp;
if (x <= 1.999999987845058e-8f) {
tmp = 0.25f / s;
} else {
tmp = 0.3333333333333333f * (s / powf(x, 2.0f));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 1.999999987845058e-8) then
tmp = 0.25e0 / s
else
tmp = 0.3333333333333333e0 * (s / (x ** 2.0e0))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.999999987845058e-8)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(0.3333333333333333) * Float32(s / (x ^ Float32(2.0)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.999999987845058e-8)) tmp = single(0.25) / s; else tmp = single(0.3333333333333333) * (s / (x ^ single(2.0))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.999999987845058 \cdot 10^{-8}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;0.3333333333333333 \cdot \frac{s}{{x}^{2}}\\
\end{array}
\end{array}
if x < 1.99999999e-8Initial program 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in s around inf 34.5%
if 1.99999999e-8 < x Initial program 99.9%
Simplified99.9%
Applied egg-rr98.8%
associate-+r+98.8%
*-lft-identity98.8%
distribute-rgt-in98.8%
+-commutative98.8%
*-commutative98.8%
fma-udef98.8%
distribute-rgt-in98.8%
*-rgt-identity98.8%
distribute-lft-in98.8%
associate-*r*98.8%
distribute-lft-out98.8%
*-lft-identity98.8%
distribute-rgt-in98.8%
Simplified98.8%
Taylor expanded in x around 0 72.6%
Taylor expanded in x around inf 70.6%
Final simplification45.2%
(FPCore (x s) :precision binary32 (if (<= x 1.999999987845058e-8) (/ 0.25 s) (* s (/ 0.3333333333333333 (pow x 2.0)))))
float code(float x, float s) {
float tmp;
if (x <= 1.999999987845058e-8f) {
tmp = 0.25f / s;
} else {
tmp = s * (0.3333333333333333f / powf(x, 2.0f));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 1.999999987845058e-8) then
tmp = 0.25e0 / s
else
tmp = s * (0.3333333333333333e0 / (x ** 2.0e0))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.999999987845058e-8)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(s * Float32(Float32(0.3333333333333333) / (x ^ Float32(2.0)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.999999987845058e-8)) tmp = single(0.25) / s; else tmp = s * (single(0.3333333333333333) / (x ^ single(2.0))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.999999987845058 \cdot 10^{-8}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;s \cdot \frac{0.3333333333333333}{{x}^{2}}\\
\end{array}
\end{array}
if x < 1.99999999e-8Initial program 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in s around inf 34.5%
if 1.99999999e-8 < x Initial program 99.9%
Simplified99.9%
Applied egg-rr98.8%
associate-+r+98.8%
*-lft-identity98.8%
distribute-rgt-in98.8%
+-commutative98.8%
*-commutative98.8%
fma-udef98.8%
distribute-rgt-in98.8%
*-rgt-identity98.8%
distribute-lft-in98.8%
associate-*r*98.8%
distribute-lft-out98.8%
*-lft-identity98.8%
distribute-rgt-in98.8%
Simplified98.8%
Taylor expanded in x around 0 72.6%
Taylor expanded in x around inf 72.6%
associate-*r/72.6%
associate-/l*72.6%
Simplified72.6%
Taylor expanded in s around 0 70.6%
associate-*r/70.6%
*-rgt-identity70.6%
times-frac70.6%
/-rgt-identity70.6%
Simplified70.6%
Final simplification45.2%
(FPCore (x s) :precision binary32 (if (<= x 1.999999987845058e-8) (/ 0.25 s) (/ (* s 0.3333333333333333) (pow x 2.0))))
float code(float x, float s) {
float tmp;
if (x <= 1.999999987845058e-8f) {
tmp = 0.25f / s;
} else {
tmp = (s * 0.3333333333333333f) / powf(x, 2.0f);
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 1.999999987845058e-8) then
tmp = 0.25e0 / s
else
tmp = (s * 0.3333333333333333e0) / (x ** 2.0e0)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.999999987845058e-8)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(s * Float32(0.3333333333333333)) / (x ^ Float32(2.0))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.999999987845058e-8)) tmp = single(0.25) / s; else tmp = (s * single(0.3333333333333333)) / (x ^ single(2.0)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.999999987845058 \cdot 10^{-8}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{s \cdot 0.3333333333333333}{{x}^{2}}\\
\end{array}
\end{array}
if x < 1.99999999e-8Initial program 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in s around inf 34.5%
if 1.99999999e-8 < x Initial program 99.9%
Simplified99.9%
Applied egg-rr98.8%
associate-+r+98.8%
*-lft-identity98.8%
distribute-rgt-in98.8%
+-commutative98.8%
*-commutative98.8%
fma-udef98.8%
distribute-rgt-in98.8%
*-rgt-identity98.8%
distribute-lft-in98.8%
associate-*r*98.8%
distribute-lft-out98.8%
*-lft-identity98.8%
distribute-rgt-in98.8%
Simplified98.8%
Taylor expanded in x around 0 72.6%
Taylor expanded in x around inf 72.6%
associate-*r/72.6%
associate-/l*72.6%
Simplified72.6%
Taylor expanded in s around 0 70.6%
associate-*r/70.6%
Simplified70.6%
Final simplification45.2%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ 4.0 (* (/ x s) 4.0)))))
float code(float x, float s) {
return 1.0f / (s * (4.0f + ((x / s) * 4.0f)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (s * (4.0e0 + ((x / s) * 4.0e0)))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(Float32(x / s) * Float32(4.0))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (single(4.0) + ((x / s) * single(4.0)))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(4 + \frac{x}{s} \cdot 4\right)}
\end{array}
Initial program 99.8%
Simplified99.8%
Applied egg-rr59.2%
associate-+r+59.2%
*-lft-identity59.2%
distribute-rgt-in59.2%
+-commutative59.2%
*-commutative59.2%
fma-udef59.2%
distribute-rgt-in59.2%
*-rgt-identity59.2%
distribute-lft-in59.2%
associate-*r*59.2%
distribute-lft-out59.3%
*-lft-identity59.3%
distribute-rgt-in59.3%
Simplified59.3%
Taylor expanded in x around 0 49.7%
Final simplification49.7%
(FPCore (x s) :precision binary32 (/ 1.0 (* 4.0 (+ x s))))
float code(float x, float s) {
return 1.0f / (4.0f * (x + s));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (4.0e0 * (x + s))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(4.0) * Float32(x + s))) end
function tmp = code(x, s) tmp = single(1.0) / (single(4.0) * (x + s)); end
\begin{array}{l}
\\
\frac{1}{4 \cdot \left(x + s\right)}
\end{array}
Initial program 99.8%
Simplified99.8%
Applied egg-rr59.2%
associate-+r+59.2%
*-lft-identity59.2%
distribute-rgt-in59.2%
+-commutative59.2%
*-commutative59.2%
fma-udef59.2%
distribute-rgt-in59.2%
*-rgt-identity59.2%
distribute-lft-in59.2%
associate-*r*59.2%
distribute-lft-out59.3%
*-lft-identity59.3%
distribute-rgt-in59.3%
Simplified59.3%
Taylor expanded in s around inf 28.2%
distribute-lft-out28.2%
Simplified28.2%
Final simplification28.2%
(FPCore (x s) :precision binary32 (if (<= x 1.999999987845058e-8) (/ 0.25 s) (/ 0.25 x)))
float code(float x, float s) {
float tmp;
if (x <= 1.999999987845058e-8f) {
tmp = 0.25f / s;
} else {
tmp = 0.25f / x;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 1.999999987845058e-8) then
tmp = 0.25e0 / s
else
tmp = 0.25e0 / x
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.999999987845058e-8)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(0.25) / x); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.999999987845058e-8)) tmp = single(0.25) / s; else tmp = single(0.25) / x; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.999999987845058 \cdot 10^{-8}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{x}\\
\end{array}
\end{array}
if x < 1.99999999e-8Initial program 99.7%
*-commutative99.7%
Simplified99.7%
Taylor expanded in s around inf 34.5%
if 1.99999999e-8 < x Initial program 99.9%
Simplified99.9%
Applied egg-rr98.8%
associate-+r+98.8%
*-lft-identity98.8%
distribute-rgt-in98.8%
+-commutative98.8%
*-commutative98.8%
fma-udef98.8%
distribute-rgt-in98.8%
*-rgt-identity98.8%
distribute-lft-in98.8%
associate-*r*98.8%
distribute-lft-out98.8%
*-lft-identity98.8%
distribute-rgt-in98.8%
Simplified98.8%
Taylor expanded in s around inf 11.5%
distribute-lft-out11.5%
Simplified11.5%
Taylor expanded in s around 0 10.7%
Final simplification27.5%
(FPCore (x s) :precision binary32 (/ 0.25 (+ x s)))
float code(float x, float s) {
return 0.25f / (x + s);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.25e0 / (x + s)
end function
function code(x, s) return Float32(Float32(0.25) / Float32(x + s)) end
function tmp = code(x, s) tmp = single(0.25) / (x + s); end
\begin{array}{l}
\\
\frac{0.25}{x + s}
\end{array}
Initial program 99.8%
Simplified99.8%
Applied egg-rr59.2%
associate-+r+59.2%
*-lft-identity59.2%
distribute-rgt-in59.2%
+-commutative59.2%
*-commutative59.2%
fma-udef59.2%
distribute-rgt-in59.2%
*-rgt-identity59.2%
distribute-lft-in59.2%
associate-*r*59.2%
distribute-lft-out59.3%
*-lft-identity59.3%
distribute-rgt-in59.3%
Simplified59.3%
Taylor expanded in s around inf 28.2%
distribute-lft-out28.2%
Simplified28.2%
expm1-log1p-u26.4%
expm1-udef63.3%
associate-/r*63.3%
metadata-eval63.3%
+-commutative63.3%
Applied egg-rr63.3%
expm1-def25.9%
expm1-log1p27.7%
+-commutative27.7%
Simplified27.7%
Final simplification27.7%
(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%
*-commutative99.8%
Simplified99.8%
Taylor expanded in s around inf 25.7%
Final simplification25.7%
herbie shell --seed 2023334
(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))))))