
(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 14 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) (fma s t_0 s)))))
float code(float x, float s) {
float t_0 = expf((fabsf(x) / -s));
return t_0 / ((t_0 + 1.0f) * fmaf(s, t_0, s));
}
function code(x, s) t_0 = exp(Float32(abs(x) / Float32(-s))) return Float32(t_0 / Float32(Float32(t_0 + Float32(1.0)) * fma(s, t_0, 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 \mathsf{fma}\left(s, t\_0, s\right)}
\end{array}
\end{array}
Initial program 99.3%
*-commutative99.3%
+-commutative99.3%
fabs-neg99.3%
distribute-lft-in99.3%
*-rgt-identity99.3%
fma-define99.3%
fabs-neg99.3%
Simplified99.3%
Final simplification99.3%
(FPCore (x s) :precision binary32 (/ (pow (exp -1.0) (/ x s)) (* s (pow (+ (exp (/ x (- s))) 1.0) 2.0))))
float code(float x, float s) {
return powf(expf(-1.0f), (x / s)) / (s * powf((expf((x / -s)) + 1.0f), 2.0f));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (exp((-1.0e0)) ** (x / s)) / (s * ((exp((x / -s)) + 1.0e0) ** 2.0e0))
end function
function code(x, s) return Float32((exp(Float32(-1.0)) ^ Float32(x / s)) / Float32(s * (Float32(exp(Float32(x / Float32(-s))) + Float32(1.0)) ^ Float32(2.0)))) end
function tmp = code(x, s) tmp = (exp(single(-1.0)) ^ (x / s)) / (s * ((exp((x / -s)) + single(1.0)) ^ single(2.0))); end
\begin{array}{l}
\\
\frac{{\left(e^{-1}\right)}^{\left(\frac{x}{s}\right)}}{s \cdot {\left(e^{\frac{x}{-s}} + 1\right)}^{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%
Taylor expanded in x around 0 99.3%
associate-/r*99.3%
exp-prod99.3%
rem-square-sqrt54.1%
fabs-sqr54.1%
rem-square-sqrt63.5%
exp-prod63.5%
neg-mul-163.5%
distribute-neg-frac263.5%
Simplified63.8%
Taylor expanded in x around inf 63.9%
exp-prod63.9%
Applied egg-rr63.9%
Final simplification63.9%
(FPCore (x s) :precision binary32 (/ (/ 1.0 (* s (exp (/ x s)))) (pow (+ 1.0 (exp (/ x (- s)))) 2.0)))
float code(float x, float s) {
return (1.0f / (s * expf((x / s)))) / powf((1.0f + expf((x / -s))), 2.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / (s * exp((x / s)))) / ((1.0e0 + exp((x / -s))) ** 2.0e0)
end function
function code(x, s) return Float32(Float32(Float32(1.0) / Float32(s * exp(Float32(x / s)))) / (Float32(Float32(1.0) + exp(Float32(x / Float32(-s)))) ^ Float32(2.0))) end
function tmp = code(x, s) tmp = (single(1.0) / (s * exp((x / s)))) / ((single(1.0) + exp((x / -s))) ^ single(2.0)); end
\begin{array}{l}
\\
\frac{\frac{1}{s \cdot e^{\frac{x}{s}}}}{{\left(1 + e^{\frac{x}{-s}}\right)}^{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%
Taylor expanded in x around 0 99.3%
associate-/r*99.3%
exp-prod99.3%
rem-square-sqrt54.1%
fabs-sqr54.1%
rem-square-sqrt63.5%
exp-prod63.5%
neg-mul-163.5%
distribute-neg-frac263.5%
Simplified63.8%
clear-num63.8%
inv-pow63.8%
Applied egg-rr63.8%
unpow-163.8%
Simplified63.8%
Final simplification63.8%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ x (- s))))) (/ t_0 (* s (pow (+ t_0 1.0) 2.0)))))
float code(float x, float s) {
float t_0 = expf((x / -s));
return t_0 / (s * powf((t_0 + 1.0f), 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 * ((t_0 + 1.0e0) ** 2.0e0))
end function
function code(x, s) t_0 = exp(Float32(x / Float32(-s))) return Float32(t_0 / Float32(s * (Float32(t_0 + Float32(1.0)) ^ Float32(2.0)))) end
function tmp = code(x, s) t_0 = exp((x / -s)); tmp = t_0 / (s * ((t_0 + single(1.0)) ^ single(2.0))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{x}{-s}}\\
\frac{t\_0}{s \cdot {\left(t\_0 + 1\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.3%
exp-prod99.3%
rem-square-sqrt54.1%
fabs-sqr54.1%
rem-square-sqrt63.5%
exp-prod63.5%
neg-mul-163.5%
distribute-neg-frac263.5%
Simplified63.8%
Taylor expanded in x around inf 63.9%
mul-1-neg63.9%
rec-exp63.9%
Applied egg-rr63.9%
rec-exp63.9%
distribute-neg-frac263.9%
Simplified63.9%
Final simplification63.9%
(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.3%
exp-prod99.3%
rem-square-sqrt54.1%
fabs-sqr54.1%
rem-square-sqrt63.5%
exp-prod63.5%
neg-mul-163.5%
distribute-neg-frac263.5%
Simplified63.8%
Final simplification63.8%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ x (- s))))) (/ (/ t_0 (+ 1.0 t_0)) (+ s (/ s (+ 1.0 (/ x s)))))))
float code(float x, float s) {
float t_0 = expf((x / -s));
return (t_0 / (1.0f + t_0)) / (s + (s / (1.0f + (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((x / -s))
code = (t_0 / (1.0e0 + t_0)) / (s + (s / (1.0e0 + (x / s))))
end function
function code(x, s) t_0 = exp(Float32(x / Float32(-s))) return Float32(Float32(t_0 / Float32(Float32(1.0) + t_0)) / Float32(s + Float32(s / Float32(Float32(1.0) + Float32(x / s))))) end
function tmp = code(x, s) t_0 = exp((x / -s)); tmp = (t_0 / (single(1.0) + t_0)) / (s + (s / (single(1.0) + (x / s)))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{x}{-s}}\\
\frac{\frac{t\_0}{1 + t\_0}}{s + \frac{s}{1 + \frac{x}{s}}}
\end{array}
\end{array}
Initial program 99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
distribute-lft-in99.3%
*-rgt-identity99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-/r*99.3%
Simplified64.5%
Taylor expanded in x around 0 61.6%
+-commutative61.6%
Simplified61.6%
Final simplification61.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.3%
exp-prod99.3%
rem-square-sqrt54.1%
fabs-sqr54.1%
rem-square-sqrt63.5%
exp-prod63.5%
neg-mul-163.5%
distribute-neg-frac263.5%
Simplified63.8%
Taylor expanded in x around 0 61.8%
associate-*r/61.8%
*-commutative61.8%
Simplified61.8%
(FPCore (x s) :precision binary32 (/ 0.5 (* s (+ (exp (/ x s)) 1.0))))
float code(float x, float s) {
return 0.5f / (s * (expf((x / s)) + 1.0f));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.5e0 / (s * (exp((x / s)) + 1.0e0))
end function
function code(x, s) return Float32(Float32(0.5) / Float32(s * Float32(exp(Float32(x / s)) + Float32(1.0)))) end
function tmp = code(x, s) tmp = single(0.5) / (s * (exp((x / s)) + single(1.0))); end
\begin{array}{l}
\\
\frac{0.5}{s \cdot \left(e^{\frac{x}{s}} + 1\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-rr59.0%
Taylor expanded in x around 0 61.9%
frac-times61.9%
metadata-eval61.9%
Applied egg-rr61.9%
Final simplification61.9%
(FPCore (x s) :precision binary32 (if (<= x 9.999999884841548e+26) (/ (- (+ 0.25 (* (/ x s) -0.125)) (* 0.5 (* (/ x s) -0.25))) s) (/ 0.5 (* s (+ (/ x s) 2.0)))))
float code(float x, float s) {
float tmp;
if (x <= 9.999999884841548e+26f) {
tmp = ((0.25f + ((x / s) * -0.125f)) - (0.5f * ((x / s) * -0.25f))) / s;
} else {
tmp = 0.5f / (s * ((x / s) + 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 <= 9.999999884841548e+26) then
tmp = ((0.25e0 + ((x / s) * (-0.125e0))) - (0.5e0 * ((x / s) * (-0.25e0)))) / s
else
tmp = 0.5e0 / (s * ((x / s) + 2.0e0))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(9.999999884841548e+26)) tmp = Float32(Float32(Float32(Float32(0.25) + Float32(Float32(x / s) * Float32(-0.125))) - Float32(Float32(0.5) * Float32(Float32(x / s) * Float32(-0.25)))) / s); else tmp = Float32(Float32(0.5) / Float32(s * Float32(Float32(x / s) + Float32(2.0)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(9.999999884841548e+26)) tmp = ((single(0.25) + ((x / s) * single(-0.125))) - (single(0.5) * ((x / s) * single(-0.25)))) / s; else tmp = single(0.5) / (s * ((x / s) + single(2.0))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.999999884841548 \cdot 10^{+26}:\\
\;\;\;\;\frac{\left(0.25 + \frac{x}{s} \cdot -0.125\right) - 0.5 \cdot \left(\frac{x}{s} \cdot -0.25\right)}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{s \cdot \left(\frac{x}{s} + 2\right)}\\
\end{array}
\end{array}
if x < 9.99999988e26Initial program 99.2%
fabs-neg99.2%
distribute-frac-neg99.2%
distribute-frac-neg299.2%
fabs-neg99.2%
*-commutative99.2%
fabs-neg99.2%
+-commutative99.2%
fabs-neg99.2%
Simplified99.2%
Applied egg-rr65.1%
Taylor expanded in s around inf 37.9%
Taylor expanded in s around -inf 71.5%
mul-1-neg71.5%
distribute-rgt-out--71.5%
metadata-eval71.5%
*-commutative71.5%
associate-*r/71.4%
*-commutative71.4%
*-commutative71.4%
Simplified71.4%
if 9.99999988e26 < 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-rr-0.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 96.3%
+-commutative96.3%
Simplified96.3%
frac-times96.3%
metadata-eval96.3%
Applied egg-rr96.3%
Final simplification73.8%
(FPCore (x s) :precision binary32 (if (<= x 9.99999993922529e-9) (/ 0.25 s) (* (/ 1.0 (/ x s)) (/ 0.5 s))))
float code(float x, float s) {
float tmp;
if (x <= 9.99999993922529e-9f) {
tmp = 0.25f / s;
} else {
tmp = (1.0f / (x / s)) * (0.5f / s);
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 9.99999993922529e-9) then
tmp = 0.25e0 / s
else
tmp = (1.0e0 / (x / s)) * (0.5e0 / s)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(9.99999993922529e-9)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(Float32(1.0) / Float32(x / s)) * Float32(Float32(0.5) / s)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(9.99999993922529e-9)) tmp = single(0.25) / s; else tmp = (single(1.0) / (x / s)) * (single(0.5) / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.99999993922529 \cdot 10^{-9}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x}{s}} \cdot \frac{0.5}{s}\\
\end{array}
\end{array}
if x < 9.99999994e-9Initial program 98.9%
fabs-neg98.9%
distribute-frac-neg98.9%
distribute-frac-neg298.9%
fabs-neg98.9%
*-commutative98.9%
fabs-neg98.9%
+-commutative98.9%
fabs-neg98.9%
Simplified98.9%
Taylor expanded in s around inf 34.9%
if 9.99999994e-9 < 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-rr-0.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 46.1%
+-commutative46.1%
Simplified46.1%
Taylor expanded in x around inf 46.1%
(FPCore (x s) :precision binary32 (if (<= x 9.99999993922529e-9) (/ 0.25 s) (* (/ 0.5 s) (/ s x))))
float code(float x, float s) {
float tmp;
if (x <= 9.99999993922529e-9f) {
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 <= 9.99999993922529e-9) 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(9.99999993922529e-9)) 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(9.99999993922529e-9)) 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 9.99999993922529 \cdot 10^{-9}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{s} \cdot \frac{s}{x}\\
\end{array}
\end{array}
if x < 9.99999994e-9Initial program 98.9%
fabs-neg98.9%
distribute-frac-neg98.9%
distribute-frac-neg298.9%
fabs-neg98.9%
*-commutative98.9%
fabs-neg98.9%
+-commutative98.9%
fabs-neg98.9%
Simplified98.9%
Taylor expanded in s around inf 34.9%
if 9.99999994e-9 < 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-rr-0.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 46.1%
+-commutative46.1%
Simplified46.1%
Taylor expanded in x around inf 33.3%
Final simplification34.3%
(FPCore (x s) :precision binary32 (/ 0.5 (* s (+ (/ x s) 2.0))))
float code(float x, float s) {
return 0.5f / (s * ((x / s) + 2.0f));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.5e0 / (s * ((x / s) + 2.0e0))
end function
function code(x, s) return Float32(Float32(0.5) / Float32(s * Float32(Float32(x / s) + Float32(2.0)))) end
function tmp = code(x, s) tmp = single(0.5) / (s * ((x / s) + single(2.0))); end
\begin{array}{l}
\\
\frac{0.5}{s \cdot \left(\frac{x}{s} + 2\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-rr59.0%
Taylor expanded in x around 0 61.9%
Taylor expanded in x around 0 47.0%
+-commutative47.0%
Simplified47.0%
frac-times47.0%
metadata-eval47.0%
Applied egg-rr47.0%
Final simplification47.0%
(FPCore (x s) :precision binary32 (if (<= x 9.99999993922529e-9) (/ 0.25 s) (/ 0.5 x)))
float code(float x, float s) {
float tmp;
if (x <= 9.99999993922529e-9f) {
tmp = 0.25f / s;
} else {
tmp = 0.5f / x;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 9.99999993922529e-9) then
tmp = 0.25e0 / s
else
tmp = 0.5e0 / x
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(9.99999993922529e-9)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(0.5) / x); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(9.99999993922529e-9)) tmp = single(0.25) / s; else tmp = single(0.5) / x; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.99999993922529 \cdot 10^{-9}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{x}\\
\end{array}
\end{array}
if x < 9.99999994e-9Initial program 98.9%
fabs-neg98.9%
distribute-frac-neg98.9%
distribute-frac-neg298.9%
fabs-neg98.9%
*-commutative98.9%
fabs-neg98.9%
+-commutative98.9%
fabs-neg98.9%
Simplified98.9%
Taylor expanded in s around inf 34.9%
if 9.99999994e-9 < 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-rr-0.0%
Taylor expanded in x around 0 100.0%
Taylor expanded in x around 0 46.1%
+-commutative46.1%
Simplified46.1%
Taylor expanded in x around inf 10.8%
(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 24.3%
herbie shell --seed 2024181
(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))))))