
(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 12 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 (* (+ 1.0 t_0) (fma t_0 s s)))))
float code(float x, float s) {
float t_0 = expf((-fabsf(x) / s));
return t_0 / ((1.0f + t_0) * fmaf(t_0, s, s));
}
function code(x, s) t_0 = exp(Float32(Float32(-abs(x)) / s)) return Float32(t_0 / Float32(Float32(Float32(1.0) + t_0) * fma(t_0, s, s))) end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
\frac{t\_0}{\left(1 + t\_0\right) \cdot \mathsf{fma}\left(t\_0, s, s\right)}
\end{array}
\end{array}
Initial program 99.8%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f3299.8
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x s)
:precision binary32
(let* ((t_0 (/ (fabs x) s))
(t_1 (exp (/ (- (fabs x)) s)))
(t_2 (+ t_0 1.0))
(t_3 (+ 1.0 t_1)))
(if (<= (/ t_1 (* (* t_3 s) t_3)) 9.99999993922529e-9)
(/ (exp (- t_0)) s)
(/
(/ 1.0 s)
(fma (/ x s) (* 5.0 (/ x s)) (fma t_2 4.0 (* -4.0 (* t_2 t_0))))))))
float code(float x, float s) {
float t_0 = fabsf(x) / s;
float t_1 = expf((-fabsf(x) / s));
float t_2 = t_0 + 1.0f;
float t_3 = 1.0f + t_1;
float tmp;
if ((t_1 / ((t_3 * s) * t_3)) <= 9.99999993922529e-9f) {
tmp = expf(-t_0) / s;
} else {
tmp = (1.0f / s) / fmaf((x / s), (5.0f * (x / s)), fmaf(t_2, 4.0f, (-4.0f * (t_2 * t_0))));
}
return tmp;
}
function code(x, s) t_0 = Float32(abs(x) / s) t_1 = exp(Float32(Float32(-abs(x)) / s)) t_2 = Float32(t_0 + Float32(1.0)) t_3 = Float32(Float32(1.0) + t_1) tmp = Float32(0.0) if (Float32(t_1 / Float32(Float32(t_3 * s) * t_3)) <= Float32(9.99999993922529e-9)) tmp = Float32(exp(Float32(-t_0)) / s); else tmp = Float32(Float32(Float32(1.0) / s) / fma(Float32(x / s), Float32(Float32(5.0) * Float32(x / s)), fma(t_2, Float32(4.0), Float32(Float32(-4.0) * Float32(t_2 * t_0))))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left|x\right|}{s}\\
t_1 := e^{\frac{-\left|x\right|}{s}}\\
t_2 := t\_0 + 1\\
t_3 := 1 + t\_1\\
\mathbf{if}\;\frac{t\_1}{\left(t\_3 \cdot s\right) \cdot t\_3} \leq 9.99999993922529 \cdot 10^{-9}:\\
\;\;\;\;\frac{e^{-t\_0}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{s}}{\mathsf{fma}\left(\frac{x}{s}, 5 \cdot \frac{x}{s}, \mathsf{fma}\left(t\_2, 4, -4 \cdot \left(t\_2 \cdot t\_0\right)\right)\right)}\\
\end{array}
\end{array}
if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 9.99999994e-9Initial program 99.9%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f3299.9
Applied rewrites99.9%
lift-/.f32N/A
lift-*.f32N/A
lift-fma.f32N/A
distribute-lft1-inN/A
+-commutativeN/A
lift-+.f32N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
lift-pow.f32N/A
associate-/l/N/A
Applied rewrites99.9%
Taylor expanded in s around 0
lower-/.f32N/A
lower-fabs.f3299.9
Applied rewrites99.9%
if 9.99999994e-9 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) Initial program 99.3%
lift-/.f32N/A
clear-numN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-/l*N/A
associate-/r*N/A
Applied rewrites99.2%
Taylor expanded in s around inf
+-commutativeN/A
associate-+r+N/A
associate-+l+N/A
distribute-lft-outN/A
lower-fma.f32N/A
Applied rewrites79.6%
Applied rewrites90.5%
Final simplification97.4%
(FPCore (x s)
:precision binary32
(let* ((t_0 (exp (/ (- (fabs x)) s))) (t_1 (+ 1.0 t_0)))
(if (<= (/ t_0 (* (* t_1 s) t_1)) 9.99999993922529e-9)
(/ (/ 1.0 s) (* (/ x (* s s)) x))
(/ (fma (/ (* -0.0625 x) s) (/ x s) 0.25) s))))
float code(float x, float s) {
float t_0 = expf((-fabsf(x) / s));
float t_1 = 1.0f + t_0;
float tmp;
if ((t_0 / ((t_1 * s) * t_1)) <= 9.99999993922529e-9f) {
tmp = (1.0f / s) / ((x / (s * s)) * x);
} else {
tmp = fmaf(((-0.0625f * x) / s), (x / s), 0.25f) / s;
}
return tmp;
}
function code(x, s) t_0 = exp(Float32(Float32(-abs(x)) / s)) t_1 = Float32(Float32(1.0) + t_0) tmp = Float32(0.0) if (Float32(t_0 / Float32(Float32(t_1 * s) * t_1)) <= Float32(9.99999993922529e-9)) tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(x / Float32(s * s)) * x)); else tmp = Float32(fma(Float32(Float32(Float32(-0.0625) * x) / s), Float32(x / s), Float32(0.25)) / s); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
t_1 := 1 + t\_0\\
\mathbf{if}\;\frac{t\_0}{\left(t\_1 \cdot s\right) \cdot t\_1} \leq 9.99999993922529 \cdot 10^{-9}:\\
\;\;\;\;\frac{\frac{1}{s}}{\frac{x}{s \cdot s} \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\frac{-0.0625 \cdot x}{s}, \frac{x}{s}, 0.25\right)}{s}\\
\end{array}
\end{array}
if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 9.99999994e-9Initial program 99.9%
lift-/.f32N/A
clear-numN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-/l*N/A
associate-/r*N/A
Applied rewrites99.4%
Taylor expanded in s around inf
+-commutativeN/A
associate-+r+N/A
associate-+l+N/A
distribute-lft-outN/A
lower-fma.f32N/A
Applied rewrites1.6%
Taylor expanded in s around 0
Applied rewrites82.3%
if 9.99999994e-9 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) Initial program 99.3%
lift-/.f32N/A
clear-numN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-/l*N/A
associate-/r*N/A
Applied rewrites99.2%
Taylor expanded in s around inf
Applied rewrites78.1%
Applied rewrites88.5%
Final simplification84.0%
(FPCore (x s)
:precision binary32
(let* ((t_0 (exp (/ (- (fabs x)) s))) (t_1 (+ 1.0 t_0)))
(if (<= (/ t_0 (* (* t_1 s) t_1)) 9.99999993922529e-9)
(/ (/ 1.0 s) (* (/ x (* s s)) x))
(/ 0.25 s))))
float code(float x, float s) {
float t_0 = expf((-fabsf(x) / s));
float t_1 = 1.0f + t_0;
float tmp;
if ((t_0 / ((t_1 * s) * t_1)) <= 9.99999993922529e-9f) {
tmp = (1.0f / s) / ((x / (s * s)) * 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) :: t_0
real(4) :: t_1
real(4) :: tmp
t_0 = exp((-abs(x) / s))
t_1 = 1.0e0 + t_0
if ((t_0 / ((t_1 * s) * t_1)) <= 9.99999993922529e-9) then
tmp = (1.0e0 / s) / ((x / (s * s)) * x)
else
tmp = 0.25e0 / s
end if
code = tmp
end function
function code(x, s) t_0 = exp(Float32(Float32(-abs(x)) / s)) t_1 = Float32(Float32(1.0) + t_0) tmp = Float32(0.0) if (Float32(t_0 / Float32(Float32(t_1 * s) * t_1)) <= Float32(9.99999993922529e-9)) tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(x / Float32(s * s)) * x)); else tmp = Float32(Float32(0.25) / s); end return tmp end
function tmp_2 = code(x, s) t_0 = exp((-abs(x) / s)); t_1 = single(1.0) + t_0; tmp = single(0.0); if ((t_0 / ((t_1 * s) * t_1)) <= single(9.99999993922529e-9)) tmp = (single(1.0) / s) / ((x / (s * s)) * x); else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
t_1 := 1 + t\_0\\
\mathbf{if}\;\frac{t\_0}{\left(t\_1 \cdot s\right) \cdot t\_1} \leq 9.99999993922529 \cdot 10^{-9}:\\
\;\;\;\;\frac{\frac{1}{s}}{\frac{x}{s \cdot s} \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
\end{array}
if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 9.99999994e-9Initial program 99.9%
lift-/.f32N/A
clear-numN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-/l*N/A
associate-/r*N/A
Applied rewrites99.4%
Taylor expanded in s around inf
+-commutativeN/A
associate-+r+N/A
associate-+l+N/A
distribute-lft-outN/A
lower-fma.f32N/A
Applied rewrites1.6%
Taylor expanded in s around 0
Applied rewrites82.3%
if 9.99999994e-9 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) Initial program 99.3%
Taylor expanded in s around inf
lower-/.f3287.7
Applied rewrites87.7%
Final simplification83.8%
(FPCore (x s) :precision binary32 (/ 1.0 (* (pow (+ 1.0 (exp (/ (- (fabs x)) s))) 2.0) (* (exp (/ (fabs x) s)) s))))
float code(float x, float s) {
return 1.0f / (powf((1.0f + expf((-fabsf(x) / s))), 2.0f) * (expf((fabsf(x) / s)) * 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) * (exp((abs(x) / s)) * s))
end function
function code(x, s) return Float32(Float32(1.0) / Float32((Float32(Float32(1.0) + exp(Float32(Float32(-abs(x)) / s))) ^ Float32(2.0)) * Float32(exp(Float32(abs(x) / s)) * s))) end
function tmp = code(x, s) tmp = single(1.0) / (((single(1.0) + exp((-abs(x) / s))) ^ single(2.0)) * (exp((abs(x) / s)) * s)); end
\begin{array}{l}
\\
\frac{1}{{\left(1 + e^{\frac{-\left|x\right|}{s}}\right)}^{2} \cdot \left(e^{\frac{\left|x\right|}{s}} \cdot s\right)}
\end{array}
Initial program 99.8%
lift-/.f32N/A
clear-numN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-/l*N/A
associate-/r*N/A
Applied rewrites99.4%
Taylor expanded in s around 0
lower-/.f32N/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-exp.f32N/A
lower-/.f32N/A
lower-fabs.f32N/A
lower-pow.f32N/A
Applied rewrites99.8%
Final simplification99.8%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (- (fabs x)) s)))) (/ (* (pow (+ 1.0 t_0) -2.0) t_0) s)))
float code(float x, float s) {
float t_0 = expf((-fabsf(x) / s));
return (powf((1.0f + t_0), -2.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 = exp((-abs(x) / s))
code = (((1.0e0 + t_0) ** (-2.0e0)) * t_0) / s
end function
function code(x, s) t_0 = exp(Float32(Float32(-abs(x)) / s)) return Float32(Float32((Float32(Float32(1.0) + t_0) ^ Float32(-2.0)) * t_0) / s) end
function tmp = code(x, s) t_0 = exp((-abs(x) / s)); tmp = (((single(1.0) + t_0) ^ single(-2.0)) * t_0) / s; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
\frac{{\left(1 + t\_0\right)}^{-2} \cdot t\_0}{s}
\end{array}
\end{array}
Initial program 99.8%
Applied rewrites99.8%
(FPCore (x s) :precision binary32 (/ (exp (- (fma (log1p (exp (/ (- (fabs x)) s))) 2.0 (/ (fabs x) s)))) s))
float code(float x, float s) {
return expf(-fmaf(log1pf(expf((-fabsf(x) / s))), 2.0f, (fabsf(x) / s))) / s;
}
function code(x, s) return Float32(exp(Float32(-fma(log1p(exp(Float32(Float32(-abs(x)) / s))), Float32(2.0), Float32(abs(x) / s)))) / s) end
\begin{array}{l}
\\
\frac{e^{-\mathsf{fma}\left(\mathsf{log1p}\left(e^{\frac{-\left|x\right|}{s}}\right), 2, \frac{\left|x\right|}{s}\right)}}{s}
\end{array}
Initial program 99.8%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f3299.8
Applied rewrites99.8%
lift-/.f32N/A
lift-*.f32N/A
lift-fma.f32N/A
distribute-lft1-inN/A
+-commutativeN/A
lift-+.f32N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
lift-pow.f32N/A
associate-/l/N/A
Applied rewrites99.8%
(FPCore (x s)
:precision binary32
(/
(exp
(-
(fma
(- (log 2.0) (/ (fma x (* -0.125 (/ x s)) (* 0.5 (fabs x))) s))
2.0
(/ (fabs x) s))))
s))
float code(float x, float s) {
return expf(-fmaf((logf(2.0f) - (fmaf(x, (-0.125f * (x / s)), (0.5f * fabsf(x))) / s)), 2.0f, (fabsf(x) / s))) / s;
}
function code(x, s) return Float32(exp(Float32(-fma(Float32(log(Float32(2.0)) - Float32(fma(x, Float32(Float32(-0.125) * Float32(x / s)), Float32(Float32(0.5) * abs(x))) / s)), Float32(2.0), Float32(abs(x) / s)))) / s) end
\begin{array}{l}
\\
\frac{e^{-\mathsf{fma}\left(\log 2 - \frac{\mathsf{fma}\left(x, -0.125 \cdot \frac{x}{s}, 0.5 \cdot \left|x\right|\right)}{s}, 2, \frac{\left|x\right|}{s}\right)}}{s}
\end{array}
Initial program 99.8%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f3299.8
Applied rewrites99.8%
lift-/.f32N/A
lift-*.f32N/A
lift-fma.f32N/A
distribute-lft1-inN/A
+-commutativeN/A
lift-+.f32N/A
*-commutativeN/A
associate-*l*N/A
unpow2N/A
lift-pow.f32N/A
associate-/l/N/A
Applied rewrites99.8%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-log.f32N/A
lower-/.f32N/A
Applied rewrites95.2%
Applied rewrites97.1%
Final simplification97.1%
(FPCore (x s) :precision binary32 (let* ((t_0 (/ (fabs x) s))) (/ (exp (/ (- (fabs x)) s)) (* (+ (- 1.0 t_0) 1.0) (* (- 2.0 t_0) s)))))
float code(float x, float s) {
float t_0 = fabsf(x) / s;
return expf((-fabsf(x) / s)) / (((1.0f - t_0) + 1.0f) * ((2.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 = abs(x) / s
code = exp((-abs(x) / s)) / (((1.0e0 - t_0) + 1.0e0) * ((2.0e0 - t_0) * s))
end function
function code(x, s) t_0 = Float32(abs(x) / s) return Float32(exp(Float32(Float32(-abs(x)) / s)) / Float32(Float32(Float32(Float32(1.0) - t_0) + Float32(1.0)) * Float32(Float32(Float32(2.0) - t_0) * s))) end
function tmp = code(x, s) t_0 = abs(x) / s; tmp = exp((-abs(x) / s)) / (((single(1.0) - t_0) + single(1.0)) * ((single(2.0) - t_0) * s)); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left|x\right|}{s}\\
\frac{e^{\frac{-\left|x\right|}{s}}}{\left(\left(1 - t\_0\right) + 1\right) \cdot \left(\left(2 - t\_0\right) \cdot s\right)}
\end{array}
\end{array}
Initial program 99.8%
Taylor expanded in s around inf
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f32N/A
lower-fabs.f3295.9
Applied rewrites95.9%
Taylor expanded in s around inf
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f32N/A
lower-fabs.f3296.2
Applied rewrites96.2%
Final simplification96.2%
(FPCore (x s) :precision binary32 (/ (exp (/ (- (fabs x)) s)) (* 4.0 s)))
float code(float x, float s) {
return expf((-fabsf(x) / s)) / (4.0f * s);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = exp((-abs(x) / s)) / (4.0e0 * s)
end function
function code(x, s) return Float32(exp(Float32(Float32(-abs(x)) / s)) / Float32(Float32(4.0) * s)) end
function tmp = code(x, s) tmp = exp((-abs(x) / s)) / (single(4.0) * s); end
\begin{array}{l}
\\
\frac{e^{\frac{-\left|x\right|}{s}}}{4 \cdot s}
\end{array}
Initial program 99.8%
Taylor expanded in s around inf
lower-*.f3295.0
Applied rewrites95.0%
(FPCore (x s) :precision binary32 (/ (/ 1.0 s) (+ (* (/ x (* s s)) x) 4.0)))
float code(float x, float s) {
return (1.0f / s) / (((x / (s * s)) * x) + 4.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / s) / (((x / (s * s)) * x) + 4.0e0)
end function
function code(x, s) return Float32(Float32(Float32(1.0) / s) / Float32(Float32(Float32(x / Float32(s * s)) * x) + Float32(4.0))) end
function tmp = code(x, s) tmp = (single(1.0) / s) / (((x / (s * s)) * x) + single(4.0)); end
\begin{array}{l}
\\
\frac{\frac{1}{s}}{\frac{x}{s \cdot s} \cdot x + 4}
\end{array}
Initial program 99.8%
lift-/.f32N/A
clear-numN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-/l*N/A
associate-/r*N/A
Applied rewrites99.4%
Taylor expanded in s around inf
+-commutativeN/A
associate-+r+N/A
associate-+l+N/A
distribute-lft-outN/A
lower-fma.f32N/A
Applied rewrites22.6%
Taylor expanded in x around 0
Applied rewrites81.8%
Final simplification81.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.8%
Taylor expanded in s around inf
lower-/.f3227.0
Applied rewrites27.0%
herbie shell --seed 2024235
(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))))))