
(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 10 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 s) (+ (exp (/ (fabs x) s)) (+ (exp (/ (fabs x) (- s))) 2.0))))
float code(float x, float s) {
return (1.0f / s) / (expf((fabsf(x) / s)) + (expf((fabsf(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((abs(x) / s)) + (exp((abs(x) / -s)) + 2.0e0))
end function
function code(x, s) return Float32(Float32(Float32(1.0) / s) / Float32(exp(Float32(abs(x) / s)) + Float32(exp(Float32(abs(x) / Float32(-s))) + Float32(2.0)))) end
function tmp = code(x, s) tmp = (single(1.0) / s) / (exp((abs(x) / s)) + (exp((abs(x) / -s)) + single(2.0))); end
\begin{array}{l}
\\
\frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{-s}} + 2\right)}
\end{array}
Initial program 99.6%
*-lft-identity99.6%
associate-*r/99.6%
associate-*l*99.6%
times-frac99.6%
associate-*r/99.6%
associate-/l*99.5%
distribute-frac-neg99.5%
exp-neg99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x s)
:precision binary32
(let* ((t_0 (exp (/ x s))))
(if (<= x -9.999999350456404e-39)
(/ (/ t_0 s) (pow (+ 1.0 t_0) 2.0))
(/ (/ 1.0 (+ (exp (/ (fabs x) (- s))) (+ 2.0 t_0))) s))))
float code(float x, float s) {
float t_0 = expf((x / s));
float tmp;
if (x <= -9.999999350456404e-39f) {
tmp = (t_0 / s) / powf((1.0f + t_0), 2.0f);
} else {
tmp = (1.0f / (expf((fabsf(x) / -s)) + (2.0f + t_0))) / s;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: tmp
t_0 = exp((x / s))
if (x <= (-9.999999350456404e-39)) then
tmp = (t_0 / s) / ((1.0e0 + t_0) ** 2.0e0)
else
tmp = (1.0e0 / (exp((abs(x) / -s)) + (2.0e0 + t_0))) / s
end if
code = tmp
end function
function code(x, s) t_0 = exp(Float32(x / s)) tmp = Float32(0.0) if (x <= Float32(-9.999999350456404e-39)) tmp = Float32(Float32(t_0 / s) / (Float32(Float32(1.0) + t_0) ^ Float32(2.0))); else tmp = Float32(Float32(Float32(1.0) / Float32(exp(Float32(abs(x) / Float32(-s))) + Float32(Float32(2.0) + t_0))) / s); end return tmp end
function tmp_2 = code(x, s) t_0 = exp((x / s)); tmp = single(0.0); if (x <= single(-9.999999350456404e-39)) tmp = (t_0 / s) / ((single(1.0) + t_0) ^ single(2.0)); else tmp = (single(1.0) / (exp((abs(x) / -s)) + (single(2.0) + t_0))) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{x}{s}}\\
\mathbf{if}\;x \leq -9.999999350456404 \cdot 10^{-39}:\\
\;\;\;\;\frac{\frac{t_0}{s}}{{\left(1 + t_0\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{e^{\frac{\left|x\right|}{-s}} + \left(2 + t_0\right)}}{s}\\
\end{array}
\end{array}
if x < -9.99999935e-39Initial program 99.6%
associate-*l*99.5%
+-commutative99.5%
+-commutative99.5%
Simplified99.5%
div-inv99.5%
pow299.5%
+-commutative99.5%
Applied egg-rr99.5%
expm1-log1p-u98.0%
expm1-udef97.2%
Applied egg-rr97.2%
expm1-def98.0%
expm1-log1p99.5%
associate-/r*99.6%
Simplified99.6%
if -9.99999935e-39 < x Initial program 99.6%
*-lft-identity99.6%
associate-*r/99.6%
associate-*l*99.6%
times-frac99.6%
associate-*r/99.5%
associate-/l*99.5%
distribute-frac-neg99.5%
exp-neg99.6%
Simplified99.6%
div-inv99.6%
Applied egg-rr99.6%
associate-*l/99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
expm1-log1p-u99.6%
Applied egg-rr99.6%
expm1-log1p-u99.6%
add-sqr-sqrt99.5%
fabs-sqr99.5%
add-sqr-sqrt99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
*-lft-identity99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x s) :precision binary32 (/ (/ 1.0 (+ 1.0 (+ (exp (/ (fabs x) s)) 2.0))) s))
float code(float x, float s) {
return (1.0f / (1.0f + (expf((fabsf(x) / s)) + 2.0f))) / s;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / (1.0e0 + (exp((abs(x) / s)) + 2.0e0))) / s
end function
function code(x, s) return Float32(Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(exp(Float32(abs(x) / s)) + Float32(2.0)))) / s) end
function tmp = code(x, s) tmp = (single(1.0) / (single(1.0) + (exp((abs(x) / s)) + single(2.0)))) / s; end
\begin{array}{l}
\\
\frac{\frac{1}{1 + \left(e^{\frac{\left|x\right|}{s}} + 2\right)}}{s}
\end{array}
Initial program 99.6%
*-lft-identity99.6%
associate-*r/99.6%
associate-*l*99.6%
times-frac99.6%
associate-*r/99.6%
associate-/l*99.5%
distribute-frac-neg99.5%
exp-neg99.6%
Simplified99.6%
div-inv99.6%
Applied egg-rr99.6%
associate-*l/99.6%
*-un-lft-identity99.6%
Applied egg-rr99.6%
Taylor expanded in s around inf 95.7%
Final simplification95.7%
(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.6%
*-lft-identity99.6%
associate-*r/99.6%
associate-*l*99.6%
times-frac99.6%
associate-*r/99.6%
associate-/l*99.5%
distribute-frac-neg99.5%
exp-neg99.6%
Simplified99.6%
div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in s around inf 95.7%
Taylor expanded in s around 0 95.7%
associate-/r*95.7%
Simplified95.7%
Final simplification95.7%
(FPCore (x s) :precision binary32 (if (<= x -5.000000156871975e-23) (/ (/ 1.0 s) (+ (/ (* x x) (* s s)) 4.0)) (/ 1.0 (* s (+ (exp (/ x s)) 3.0)))))
float code(float x, float s) {
float tmp;
if (x <= -5.000000156871975e-23f) {
tmp = (1.0f / s) / (((x * x) / (s * s)) + 4.0f);
} else {
tmp = 1.0f / (s * (expf((x / s)) + 3.0f));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-5.000000156871975e-23)) then
tmp = (1.0e0 / s) / (((x * x) / (s * s)) + 4.0e0)
else
tmp = 1.0e0 / (s * (exp((x / s)) + 3.0e0))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-5.000000156871975e-23)) tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(Float32(x * x) / Float32(s * s)) + Float32(4.0))); else tmp = Float32(Float32(1.0) / Float32(s * Float32(exp(Float32(x / s)) + Float32(3.0)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-5.000000156871975e-23)) tmp = (single(1.0) / s) / (((x * x) / (s * s)) + single(4.0)); else tmp = single(1.0) / (s * (exp((x / s)) + single(3.0))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.000000156871975 \cdot 10^{-23}:\\
\;\;\;\;\frac{\frac{1}{s}}{\frac{x \cdot x}{s \cdot s} + 4}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(e^{\frac{x}{s}} + 3\right)}\\
\end{array}
\end{array}
if x < -5.00000016e-23Initial program 99.6%
*-lft-identity99.6%
associate-*r/99.6%
associate-*l*99.6%
times-frac99.7%
associate-*r/99.6%
associate-/l*99.6%
distribute-frac-neg99.6%
exp-neg99.7%
Simplified99.7%
Taylor expanded in s around inf 52.9%
associate-+r+52.9%
distribute-lft1-in52.9%
metadata-eval52.9%
mul0-lft81.3%
associate-+r+81.3%
metadata-eval81.3%
unpow281.3%
sqr-abs81.3%
unpow281.3%
Simplified81.3%
if -5.00000016e-23 < x Initial program 99.5%
*-lft-identity99.5%
associate-*r/99.5%
associate-*l*99.6%
times-frac99.5%
associate-*r/99.5%
associate-/l*99.5%
distribute-frac-neg99.5%
exp-neg99.5%
Simplified99.6%
div-inv99.6%
Applied egg-rr99.6%
Taylor expanded in s around inf 94.5%
expm1-log1p-u92.9%
expm1-udef92.9%
frac-times92.9%
metadata-eval92.9%
+-commutative92.9%
add-sqr-sqrt80.1%
fabs-sqr80.1%
add-sqr-sqrt88.6%
Applied egg-rr88.6%
expm1-def88.7%
expm1-log1p90.3%
/-rgt-identity90.3%
/-rgt-identity90.3%
/-rgt-identity90.3%
/-rgt-identity90.3%
associate-+r+90.3%
metadata-eval90.3%
Simplified90.3%
Final simplification87.0%
(FPCore (x s) :precision binary32 (/ (/ 1.0 s) (+ (/ (* x x) (* s s)) 4.0)))
float code(float x, float s) {
return (1.0f / s) / (((x * x) / (s * s)) + 4.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / s) / (((x * x) / (s * s)) + 4.0e0)
end function
function code(x, s) return Float32(Float32(Float32(1.0) / s) / Float32(Float32(Float32(x * x) / Float32(s * s)) + Float32(4.0))) end
function tmp = code(x, s) tmp = (single(1.0) / s) / (((x * x) / (s * s)) + single(4.0)); end
\begin{array}{l}
\\
\frac{\frac{1}{s}}{\frac{x \cdot x}{s \cdot s} + 4}
\end{array}
Initial program 99.6%
*-lft-identity99.6%
associate-*r/99.6%
associate-*l*99.6%
times-frac99.6%
associate-*r/99.6%
associate-/l*99.5%
distribute-frac-neg99.5%
exp-neg99.6%
Simplified99.6%
Taylor expanded in s around inf 51.5%
associate-+r+51.5%
distribute-lft1-in51.5%
metadata-eval51.5%
mul0-lft77.7%
associate-+r+77.7%
metadata-eval77.7%
unpow277.7%
sqr-abs77.7%
unpow277.7%
Simplified77.7%
Final simplification77.7%
(FPCore (x s) :precision binary32 (if (or (<= x -5.000000018137469e-16) (not (<= x 1.999999967550318e-17))) (* s (/ 1.0 (* x x))) (/ 0.25 s)))
float code(float x, float s) {
float tmp;
if ((x <= -5.000000018137469e-16f) || !(x <= 1.999999967550318e-17f)) {
tmp = s * (1.0f / (x * x));
} 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 ((x <= (-5.000000018137469e-16)) .or. (.not. (x <= 1.999999967550318e-17))) then
tmp = s * (1.0e0 / (x * x))
else
tmp = 0.25e0 / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if ((x <= Float32(-5.000000018137469e-16)) || !(x <= Float32(1.999999967550318e-17))) tmp = Float32(s * Float32(Float32(1.0) / Float32(x * x))); else tmp = Float32(Float32(0.25) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((x <= single(-5.000000018137469e-16)) || ~((x <= single(1.999999967550318e-17)))) tmp = s * (single(1.0) / (x * x)); else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.000000018137469 \cdot 10^{-16} \lor \neg \left(x \leq 1.999999967550318 \cdot 10^{-17}\right):\\
\;\;\;\;s \cdot \frac{1}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
\end{array}
if x < -5.00000002e-16 or 1.99999997e-17 < x Initial program 99.8%
*-lft-identity99.8%
associate-*r/99.8%
associate-/l*99.8%
distribute-frac-neg99.8%
exp-neg99.8%
associate-/r/99.8%
/-rgt-identity99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in s around inf 4.7%
associate-+r+4.7%
distribute-rgt-out4.7%
metadata-eval4.7%
mul0-rgt4.7%
+-commutative4.7%
associate-+r+4.7%
Simplified4.7%
Taylor expanded in x around inf 61.6%
unpow261.6%
associate-/r*61.2%
Simplified61.2%
associate-/l/61.6%
div-inv61.6%
Applied egg-rr61.6%
if -5.00000002e-16 < x < 1.99999997e-17Initial program 99.0%
*-lft-identity99.0%
associate-*r/99.0%
associate-*l*99.0%
times-frac98.9%
associate-*r/99.0%
associate-/l*98.9%
distribute-frac-neg98.9%
exp-neg99.0%
Simplified99.2%
Taylor expanded in s around inf 66.7%
Final simplification63.2%
(FPCore (x s) :precision binary32 (if (<= x -5.000000018137469e-16) (/ 1.0 (/ x (/ s x))) (if (<= x 1.999999967550318e-17) (/ 0.25 s) (* s (/ 1.0 (* x x))))))
float code(float x, float s) {
float tmp;
if (x <= -5.000000018137469e-16f) {
tmp = 1.0f / (x / (s / x));
} else if (x <= 1.999999967550318e-17f) {
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 <= (-5.000000018137469e-16)) then
tmp = 1.0e0 / (x / (s / x))
else if (x <= 1.999999967550318e-17) 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(-5.000000018137469e-16)) tmp = Float32(Float32(1.0) / Float32(x / Float32(s / x))); elseif (x <= Float32(1.999999967550318e-17)) 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(-5.000000018137469e-16)) tmp = single(1.0) / (x / (s / x)); elseif (x <= single(1.999999967550318e-17)) 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 -5.000000018137469 \cdot 10^{-16}:\\
\;\;\;\;\frac{1}{\frac{x}{\frac{s}{x}}}\\
\mathbf{elif}\;x \leq 1.999999967550318 \cdot 10^{-17}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;s \cdot \frac{1}{x \cdot x}\\
\end{array}
\end{array}
if x < -5.00000002e-16Initial program 99.8%
*-lft-identity99.8%
associate-*r/99.8%
associate-/l*99.8%
distribute-frac-neg99.8%
exp-neg99.8%
associate-/r/99.8%
/-rgt-identity99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in s around inf 5.0%
associate-+r+5.0%
distribute-rgt-out5.0%
metadata-eval5.0%
mul0-rgt5.0%
+-commutative5.0%
associate-+r+5.0%
Simplified5.0%
Taylor expanded in x around inf 58.0%
unpow258.0%
Simplified58.0%
clear-num59.3%
inv-pow59.3%
Applied egg-rr59.3%
unpow-159.3%
associate-/l*59.3%
Simplified59.3%
if -5.00000002e-16 < x < 1.99999997e-17Initial program 99.0%
*-lft-identity99.0%
associate-*r/99.0%
associate-*l*99.0%
times-frac98.9%
associate-*r/99.0%
associate-/l*98.9%
distribute-frac-neg98.9%
exp-neg99.0%
Simplified99.2%
Taylor expanded in s around inf 66.7%
if 1.99999997e-17 < x Initial program 99.9%
*-lft-identity99.9%
associate-*r/99.9%
associate-/l*99.8%
distribute-frac-neg99.8%
exp-neg99.9%
associate-/r/99.9%
/-rgt-identity99.9%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in s around inf 4.4%
associate-+r+4.4%
distribute-rgt-out4.4%
metadata-eval4.4%
mul0-rgt4.4%
+-commutative4.4%
associate-+r+4.4%
Simplified4.4%
Taylor expanded in x around inf 64.6%
unpow264.6%
associate-/r*64.3%
Simplified64.3%
associate-/l/64.6%
div-inv64.6%
Applied egg-rr64.6%
Final simplification63.6%
(FPCore (x s) :precision binary32 (if (or (<= x -5.000000018137469e-16) (not (<= x 1.999999967550318e-17))) (/ s (* x x)) (/ 0.25 s)))
float code(float x, float s) {
float tmp;
if ((x <= -5.000000018137469e-16f) || !(x <= 1.999999967550318e-17f)) {
tmp = s / (x * x);
} 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 ((x <= (-5.000000018137469e-16)) .or. (.not. (x <= 1.999999967550318e-17))) then
tmp = s / (x * x)
else
tmp = 0.25e0 / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if ((x <= Float32(-5.000000018137469e-16)) || !(x <= Float32(1.999999967550318e-17))) tmp = Float32(s / Float32(x * x)); else tmp = Float32(Float32(0.25) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((x <= single(-5.000000018137469e-16)) || ~((x <= single(1.999999967550318e-17)))) tmp = s / (x * x); else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.000000018137469 \cdot 10^{-16} \lor \neg \left(x \leq 1.999999967550318 \cdot 10^{-17}\right):\\
\;\;\;\;\frac{s}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
\end{array}
if x < -5.00000002e-16 or 1.99999997e-17 < x Initial program 99.8%
*-lft-identity99.8%
associate-*r/99.8%
associate-/l*99.8%
distribute-frac-neg99.8%
exp-neg99.8%
associate-/r/99.8%
/-rgt-identity99.8%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in s around inf 4.7%
associate-+r+4.7%
distribute-rgt-out4.7%
metadata-eval4.7%
mul0-rgt4.7%
+-commutative4.7%
associate-+r+4.7%
Simplified4.7%
Taylor expanded in x around inf 61.6%
unpow261.6%
Simplified61.6%
if -5.00000002e-16 < x < 1.99999997e-17Initial program 99.0%
*-lft-identity99.0%
associate-*r/99.0%
associate-*l*99.0%
times-frac98.9%
associate-*r/99.0%
associate-/l*98.9%
distribute-frac-neg98.9%
exp-neg99.0%
Simplified99.2%
Taylor expanded in s around inf 66.7%
Final simplification63.2%
(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.6%
*-lft-identity99.6%
associate-*r/99.6%
associate-*l*99.6%
times-frac99.6%
associate-*r/99.6%
associate-/l*99.5%
distribute-frac-neg99.5%
exp-neg99.6%
Simplified99.6%
Taylor expanded in s around inf 24.7%
Final simplification24.7%
herbie shell --seed 2023181
(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))))))