
(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 13 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.3%
Simplified99.3%
Final simplification99.3%
(FPCore (x s) :precision binary32 (if (<= (fabs x) 0.4000000059604645) (/ (exp (+ (/ x s) (* -2.0 (log1p (exp (/ x s)))))) s) (/ (/ (exp (/ x (- s))) s) 4.0)))
float code(float x, float s) {
float tmp;
if (fabsf(x) <= 0.4000000059604645f) {
tmp = expf(((x / s) + (-2.0f * log1pf(expf((x / s)))))) / s;
} else {
tmp = (expf((x / -s)) / s) / 4.0f;
}
return tmp;
}
function code(x, s) tmp = Float32(0.0) if (abs(x) <= Float32(0.4000000059604645)) tmp = Float32(exp(Float32(Float32(x / s) + Float32(Float32(-2.0) * log1p(exp(Float32(x / s)))))) / s); else tmp = Float32(Float32(exp(Float32(x / Float32(-s))) / s) / Float32(4.0)); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 0.4000000059604645:\\
\;\;\;\;\frac{e^{\frac{x}{s} + -2 \cdot \mathsf{log1p}\left(e^{\frac{x}{s}}\right)}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{e^{\frac{x}{-s}}}{s}}{4}\\
\end{array}
\end{array}
if (fabs.f32 x) < 0.400000006Initial program 98.7%
fabs-neg98.7%
distribute-frac-neg98.7%
distribute-frac-neg298.7%
fabs-neg98.7%
*-commutative98.7%
fabs-neg98.7%
+-commutative98.7%
fabs-neg98.7%
Simplified98.6%
Applied egg-rr72.2%
associate-*r/73.0%
*-rgt-identity73.0%
rem-exp-log69.8%
exp-to-pow69.8%
+-commutative69.8%
log1p-undefine69.8%
*-commutative69.8%
exp-sum70.2%
+-commutative70.2%
exp-diff94.5%
associate--r+94.6%
exp-diff94.8%
Simplified98.2%
if 0.400000006 < (fabs.f32 x) Initial program 100.0%
fabs-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
fabs-neg100.0%
*-commutative100.0%
fabs-neg100.0%
+-commutative100.0%
fabs-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
associate-/r*100.0%
mul-1-neg100.0%
distribute-neg-frac2100.0%
+-commutative100.0%
mul-1-neg100.0%
distribute-neg-frac2100.0%
Simplified100.0%
distribute-frac-neg2100.0%
rec-exp100.0%
remove-double-neg100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod-0.0%
add-sqr-sqrt100.0%
frac-2neg100.0%
add-sqr-sqrt-0.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
add-sqr-sqrt42.5%
fabs-sqr42.5%
add-sqr-sqrt100.0%
Applied egg-rr100.0%
rec-exp100.0%
distribute-neg-frac2100.0%
Simplified100.0%
distribute-frac-neg2100.0%
rec-exp100.0%
remove-double-neg100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod-0.0%
add-sqr-sqrt100.0%
frac-2neg100.0%
add-sqr-sqrt-0.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
add-sqr-sqrt42.5%
fabs-sqr42.5%
add-sqr-sqrt100.0%
Applied egg-rr42.5%
rec-exp100.0%
distribute-neg-frac2100.0%
Simplified42.5%
Taylor expanded in x around 0 44.3%
Final simplification73.0%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ x (- s))))) (/ (/ t_0 s) (pow (+ 1.0 t_0) 2.0))))
float code(float x, float s) {
float t_0 = expf((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((x / -s))
code = (t_0 / s) / ((1.0e0 + t_0) ** 2.0e0)
end function
function code(x, s) t_0 = exp(Float32(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((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{x}{-s}}\\
\frac{\frac{t\_0}{s}}{{\left(1 + t\_0\right)}^{2}}
\end{array}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-/r*99.2%
mul-1-neg99.2%
distribute-neg-frac299.2%
+-commutative99.2%
mul-1-neg99.2%
distribute-neg-frac299.2%
Simplified99.2%
distribute-frac-neg299.2%
rec-exp99.2%
remove-double-neg99.2%
add-sqr-sqrt99.2%
sqrt-unprod95.6%
sqr-neg95.6%
sqrt-unprod-0.0%
add-sqr-sqrt94.2%
frac-2neg94.2%
add-sqr-sqrt-0.0%
sqrt-unprod97.4%
sqr-neg97.4%
sqrt-unprod99.2%
add-sqr-sqrt99.2%
add-sqr-sqrt49.0%
fabs-sqr49.0%
add-sqr-sqrt97.6%
Applied egg-rr97.6%
rec-exp97.6%
distribute-neg-frac297.6%
Simplified97.6%
distribute-frac-neg299.2%
rec-exp99.2%
remove-double-neg99.2%
add-sqr-sqrt99.2%
sqrt-unprod95.6%
sqr-neg95.6%
sqrt-unprod-0.0%
add-sqr-sqrt94.2%
frac-2neg94.2%
add-sqr-sqrt-0.0%
sqrt-unprod97.4%
sqr-neg97.4%
sqrt-unprod99.2%
add-sqr-sqrt99.2%
add-sqr-sqrt49.0%
fabs-sqr49.0%
add-sqr-sqrt97.6%
Applied egg-rr60.3%
rec-exp97.6%
distribute-neg-frac297.6%
Simplified60.6%
Final simplification60.6%
(FPCore (x s) :precision binary32 (/ (/ (exp (/ x (- s))) s) (+ 4.0 (/ (* x -4.0) s))))
float code(float x, float s) {
return (expf((x / -s)) / s) / (4.0f + ((x * -4.0f) / s));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (exp((x / -s)) / s) / (4.0e0 + ((x * (-4.0e0)) / s))
end function
function code(x, s) return Float32(Float32(exp(Float32(x / Float32(-s))) / s) / Float32(Float32(4.0) + Float32(Float32(x * Float32(-4.0)) / s))) end
function tmp = code(x, s) tmp = (exp((x / -s)) / s) / (single(4.0) + ((x * single(-4.0)) / s)); end
\begin{array}{l}
\\
\frac{\frac{e^{\frac{x}{-s}}}{s}}{4 + \frac{x \cdot -4}{s}}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-/r*99.2%
mul-1-neg99.2%
distribute-neg-frac299.2%
+-commutative99.2%
mul-1-neg99.2%
distribute-neg-frac299.2%
Simplified99.2%
distribute-frac-neg299.2%
rec-exp99.2%
remove-double-neg99.2%
add-sqr-sqrt99.2%
sqrt-unprod95.6%
sqr-neg95.6%
sqrt-unprod-0.0%
add-sqr-sqrt94.2%
frac-2neg94.2%
add-sqr-sqrt-0.0%
sqrt-unprod97.4%
sqr-neg97.4%
sqrt-unprod99.2%
add-sqr-sqrt99.2%
add-sqr-sqrt49.0%
fabs-sqr49.0%
add-sqr-sqrt97.6%
Applied egg-rr97.6%
rec-exp97.6%
distribute-neg-frac297.6%
Simplified97.6%
distribute-frac-neg299.2%
rec-exp99.2%
remove-double-neg99.2%
add-sqr-sqrt99.2%
sqrt-unprod95.6%
sqr-neg95.6%
sqrt-unprod-0.0%
add-sqr-sqrt94.2%
frac-2neg94.2%
add-sqr-sqrt-0.0%
sqrt-unprod97.4%
sqr-neg97.4%
sqrt-unprod99.2%
add-sqr-sqrt99.2%
add-sqr-sqrt49.0%
fabs-sqr49.0%
add-sqr-sqrt97.6%
Applied egg-rr60.3%
rec-exp97.6%
distribute-neg-frac297.6%
Simplified60.6%
Taylor expanded in x around 0 58.1%
associate-*r/58.1%
Simplified58.1%
Final simplification58.1%
(FPCore (x s) :precision binary32 (/ (/ 1.0 (+ 1.0 (exp (/ x s)))) (* s 2.0)))
float code(float x, float s) {
return (1.0f / (1.0f + expf((x / s)))) / (s * 2.0f);
}
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 * 2.0e0)
end function
function code(x, s) return Float32(Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(x / s)))) / Float32(s * Float32(2.0))) end
function tmp = code(x, s) tmp = (single(1.0) / (single(1.0) + exp((x / s)))) / (s * single(2.0)); end
\begin{array}{l}
\\
\frac{\frac{1}{1 + e^{\frac{x}{s}}}}{s \cdot 2}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Applied egg-rr66.1%
Taylor expanded in x around 0 58.0%
clear-num58.0%
div-inv58.0%
metadata-eval58.0%
un-div-inv58.0%
+-commutative58.0%
Applied egg-rr58.0%
Final simplification58.0%
(FPCore (x s) :precision binary32 (/ (/ 0.5 s) (+ 1.0 (exp (/ x s)))))
float code(float x, float s) {
return (0.5f / s) / (1.0f + expf((x / s)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (0.5e0 / s) / (1.0e0 + exp((x / s)))
end function
function code(x, s) return Float32(Float32(Float32(0.5) / s) / Float32(Float32(1.0) + exp(Float32(x / s)))) end
function tmp = code(x, s) tmp = (single(0.5) / s) / (single(1.0) + exp((x / s))); end
\begin{array}{l}
\\
\frac{\frac{0.5}{s}}{1 + e^{\frac{x}{s}}}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Applied egg-rr66.1%
Taylor expanded in x around 0 58.0%
Taylor expanded in x around inf 58.0%
associate-/r*58.0%
Simplified58.0%
Final simplification58.0%
(FPCore (x s) :precision binary32 (/ (/ (exp (/ x (- s))) s) 4.0))
float code(float x, float s) {
return (expf((x / -s)) / s) / 4.0f;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (exp((x / -s)) / s) / 4.0e0
end function
function code(x, s) return Float32(Float32(exp(Float32(x / Float32(-s))) / s) / Float32(4.0)) end
function tmp = code(x, s) tmp = (exp((x / -s)) / s) / single(4.0); end
\begin{array}{l}
\\
\frac{\frac{e^{\frac{x}{-s}}}{s}}{4}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-/r*99.2%
mul-1-neg99.2%
distribute-neg-frac299.2%
+-commutative99.2%
mul-1-neg99.2%
distribute-neg-frac299.2%
Simplified99.2%
distribute-frac-neg299.2%
rec-exp99.2%
remove-double-neg99.2%
add-sqr-sqrt99.2%
sqrt-unprod95.6%
sqr-neg95.6%
sqrt-unprod-0.0%
add-sqr-sqrt94.2%
frac-2neg94.2%
add-sqr-sqrt-0.0%
sqrt-unprod97.4%
sqr-neg97.4%
sqrt-unprod99.2%
add-sqr-sqrt99.2%
add-sqr-sqrt49.0%
fabs-sqr49.0%
add-sqr-sqrt97.6%
Applied egg-rr97.6%
rec-exp97.6%
distribute-neg-frac297.6%
Simplified97.6%
distribute-frac-neg299.2%
rec-exp99.2%
remove-double-neg99.2%
add-sqr-sqrt99.2%
sqrt-unprod95.6%
sqr-neg95.6%
sqrt-unprod-0.0%
add-sqr-sqrt94.2%
frac-2neg94.2%
add-sqr-sqrt-0.0%
sqrt-unprod97.4%
sqr-neg97.4%
sqrt-unprod99.2%
add-sqr-sqrt99.2%
add-sqr-sqrt49.0%
fabs-sqr49.0%
add-sqr-sqrt97.6%
Applied egg-rr60.3%
rec-exp97.6%
distribute-neg-frac297.6%
Simplified60.6%
Taylor expanded in x around 0 57.2%
Final simplification57.2%
(FPCore (x s) :precision binary32 (if (<= x 0.00019999999494757503) (/ 0.25 s) (* (/ 0.5 s) (/ 1.0 (/ x s)))))
float code(float x, float s) {
float tmp;
if (x <= 0.00019999999494757503f) {
tmp = 0.25f / s;
} else {
tmp = (0.5f / s) * (1.0f / (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 <= 0.00019999999494757503e0) then
tmp = 0.25e0 / s
else
tmp = (0.5e0 / s) * (1.0e0 / (x / s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(0.00019999999494757503)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(Float32(0.5) / s) * Float32(Float32(1.0) / Float32(x / s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(0.00019999999494757503)) tmp = single(0.25) / s; else tmp = (single(0.5) / s) * (single(1.0) / (x / s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.00019999999494757503:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{s} \cdot \frac{1}{\frac{x}{s}}\\
\end{array}
\end{array}
if x < 1.99999995e-4Initial program 99.1%
fabs-neg99.1%
distribute-frac-neg99.1%
distribute-frac-neg299.1%
fabs-neg99.1%
*-commutative99.1%
fabs-neg99.1%
+-commutative99.1%
fabs-neg99.1%
Simplified99.0%
Taylor expanded in s around inf 35.5%
if 1.99999995e-4 < x Initial program 100.0%
fabs-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
fabs-neg100.0%
*-commutative100.0%
fabs-neg100.0%
+-commutative100.0%
fabs-neg100.0%
Simplified100.0%
Applied egg-rr1.6%
Taylor expanded in x around 0 98.9%
Taylor expanded in x around 0 43.7%
+-commutative43.7%
Simplified43.7%
Taylor expanded in x around inf 43.6%
Final simplification37.5%
(FPCore (x s) :precision binary32 (if (<= x 0.00019999999494757503) (/ 0.25 s) (* (/ 0.5 s) (/ s x))))
float code(float x, float s) {
float tmp;
if (x <= 0.00019999999494757503f) {
tmp = 0.25f / s;
} else {
tmp = (0.5f / s) * (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 <= 0.00019999999494757503e0) then
tmp = 0.25e0 / s
else
tmp = (0.5e0 / s) * (s / x)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(0.00019999999494757503)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(Float32(0.5) / s) * Float32(s / x)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(0.00019999999494757503)) tmp = single(0.25) / s; else tmp = (single(0.5) / s) * (s / x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.00019999999494757503:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{s} \cdot \frac{s}{x}\\
\end{array}
\end{array}
if x < 1.99999995e-4Initial program 99.1%
fabs-neg99.1%
distribute-frac-neg99.1%
distribute-frac-neg299.1%
fabs-neg99.1%
*-commutative99.1%
fabs-neg99.1%
+-commutative99.1%
fabs-neg99.1%
Simplified99.0%
Taylor expanded in s around inf 35.5%
if 1.99999995e-4 < x Initial program 100.0%
fabs-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
fabs-neg100.0%
*-commutative100.0%
fabs-neg100.0%
+-commutative100.0%
fabs-neg100.0%
Simplified100.0%
Applied egg-rr1.6%
Taylor expanded in x around 0 98.9%
Taylor expanded in x around 0 43.7%
+-commutative43.7%
Simplified43.7%
Taylor expanded in x around inf 36.3%
Final simplification35.7%
(FPCore (x s) :precision binary32 (* (/ 0.5 s) (/ 1.0 (+ 2.0 (/ x s)))))
float code(float x, float s) {
return (0.5f / s) * (1.0f / (2.0f + (x / s)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (0.5e0 / s) * (1.0e0 / (2.0e0 + (x / s)))
end function
function code(x, s) return Float32(Float32(Float32(0.5) / s) * Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(x / s)))) end
function tmp = code(x, s) tmp = (single(0.5) / s) * (single(1.0) / (single(2.0) + (x / s))); end
\begin{array}{l}
\\
\frac{0.5}{s} \cdot \frac{1}{2 + \frac{x}{s}}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Applied egg-rr66.1%
Taylor expanded in x around 0 58.0%
Taylor expanded in x around 0 47.3%
+-commutative47.3%
Simplified47.3%
Final simplification47.3%
(FPCore (x s) :precision binary32 (/ 0.5 (* s (+ 2.0 (/ x s)))))
float code(float x, float s) {
return 0.5f / (s * (2.0f + (x / s)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.5e0 / (s * (2.0e0 + (x / s)))
end function
function code(x, s) return Float32(Float32(0.5) / Float32(s * Float32(Float32(2.0) + Float32(x / s)))) end
function tmp = code(x, s) tmp = single(0.5) / (s * (single(2.0) + (x / s))); end
\begin{array}{l}
\\
\frac{0.5}{s \cdot \left(2 + \frac{x}{s}\right)}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Applied egg-rr66.1%
Taylor expanded in x around 0 58.0%
Taylor expanded in x around 0 47.3%
+-commutative47.3%
Simplified47.3%
frac-times47.3%
metadata-eval47.3%
+-commutative47.3%
Applied egg-rr47.3%
Final simplification47.3%
(FPCore (x s) :precision binary32 (/ (/ 0.5 s) (+ 2.0 (/ x s))))
float code(float x, float s) {
return (0.5f / s) / (2.0f + (x / s));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (0.5e0 / s) / (2.0e0 + (x / s))
end function
function code(x, s) return Float32(Float32(Float32(0.5) / s) / Float32(Float32(2.0) + Float32(x / s))) end
function tmp = code(x, s) tmp = (single(0.5) / s) / (single(2.0) + (x / s)); end
\begin{array}{l}
\\
\frac{\frac{0.5}{s}}{2 + \frac{x}{s}}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Applied egg-rr66.1%
Taylor expanded in x around 0 58.0%
Taylor expanded in x around 0 47.3%
+-commutative47.3%
Simplified47.3%
associate-*l/47.3%
*-un-lft-identity47.3%
+-commutative47.3%
Applied egg-rr47.3%
Final simplification47.3%
(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.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Taylor expanded in s around inf 28.1%
Final simplification28.1%
herbie shell --seed 2024053
(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))))))