
(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 15 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 (+ s (* s t_0))) (+ t_0 1.0))))
float code(float x, float s) {
float t_0 = expf((-fabsf(x) / s));
return (t_0 / (s + (s * t_0))) / (t_0 + 1.0f);
}
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 / (s + (s * t_0))) / (t_0 + 1.0e0)
end function
function code(x, s) t_0 = exp(Float32(Float32(-abs(x)) / s)) return Float32(Float32(t_0 / Float32(s + Float32(s * t_0))) / Float32(t_0 + Float32(1.0))) end
function tmp = code(x, s) t_0 = exp((-abs(x) / s)); tmp = (t_0 / (s + (s * t_0))) / (t_0 + single(1.0)); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
\frac{\frac{t_0}{s + s \cdot t_0}}{t_0 + 1}
\end{array}
\end{array}
Initial program 99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (* (+ 1.0 (exp (/ (fabs x) s))) (+ (exp (/ (- (fabs x)) s)) 1.0)))))
float code(float x, float s) {
return 1.0f / (s * ((1.0f + expf((fabsf(x) / s))) * (expf((-fabsf(x) / s)) + 1.0f)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (s * ((1.0e0 + exp((abs(x) / s))) * (exp((-abs(x) / s)) + 1.0e0)))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(Float32(1.0) + exp(Float32(abs(x) / s))) * Float32(exp(Float32(Float32(-abs(x)) / s)) + Float32(1.0))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * ((single(1.0) + exp((abs(x) / s))) * (exp((-abs(x) / s)) + single(1.0)))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(\left(1 + e^{\frac{\left|x\right|}{s}}\right) \cdot \left(e^{\frac{-\left|x\right|}{s}} + 1\right)\right)}
\end{array}
Initial program 99.4%
Simplified99.3%
Taylor expanded in s around 0 99.4%
+-commutative99.4%
neg-mul-199.4%
distribute-frac-neg99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x s) :precision binary32 (/ 1.0 (* (+ s (* s (exp (/ (- (fabs x)) s)))) (+ 1.0 (exp (/ (fabs x) s))))))
float code(float x, float s) {
return 1.0f / ((s + (s * expf((-fabsf(x) / s)))) * (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 + (s * exp((-abs(x) / s)))) * (1.0e0 + exp((abs(x) / s))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(s + Float32(s * exp(Float32(Float32(-abs(x)) / s)))) * Float32(Float32(1.0) + exp(Float32(abs(x) / s))))) end
function tmp = code(x, s) tmp = single(1.0) / ((s + (s * exp((-abs(x) / s)))) * (single(1.0) + exp((abs(x) / s)))); end
\begin{array}{l}
\\
\frac{1}{\left(s + s \cdot e^{\frac{-\left|x\right|}{s}}\right) \cdot \left(1 + e^{\frac{\left|x\right|}{s}}\right)}
\end{array}
Initial program 99.4%
Simplified99.3%
Taylor expanded in s around 0 99.4%
associate-*r*99.5%
+-commutative99.5%
neg-mul-199.5%
distribute-lft-in99.4%
*-rgt-identity99.4%
rem-exp-log98.0%
neg-mul-198.0%
exp-sum97.9%
neg-mul-197.9%
sub-neg97.9%
exp-diff98.0%
rem-exp-log99.4%
Simplified99.4%
div-inv99.4%
exp-neg99.4%
*-commutative99.4%
distribute-neg-frac99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (fabs x) s)))) (/ 1.0 (* (+ 1.0 t_0) (+ s (/ s t_0))))))
float code(float x, float s) {
float t_0 = expf((fabsf(x) / s));
return 1.0f / ((1.0f + t_0) * (s + (s / t_0)));
}
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 / ((1.0e0 + t_0) * (s + (s / t_0)))
end function
function code(x, s) t_0 = exp(Float32(abs(x) / s)) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + t_0) * Float32(s + Float32(s / t_0)))) end
function tmp = code(x, s) t_0 = exp((abs(x) / s)); tmp = single(1.0) / ((single(1.0) + t_0) * (s + (s / t_0))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left|x\right|}{s}}\\
\frac{1}{\left(1 + t_0\right) \cdot \left(s + \frac{s}{t_0}\right)}
\end{array}
\end{array}
Initial program 99.4%
Simplified99.3%
Taylor expanded in s around 0 99.4%
associate-*r*99.5%
+-commutative99.5%
neg-mul-199.5%
distribute-lft-in99.4%
*-rgt-identity99.4%
rem-exp-log98.0%
neg-mul-198.0%
exp-sum97.9%
neg-mul-197.9%
sub-neg97.9%
exp-diff98.0%
rem-exp-log99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x s) :precision binary32 (let* ((t_0 (/ (fabs x) s))) (/ 1.0 (* (+ 1.0 (exp t_0)) (+ s (/ s (+ t_0 1.0)))))))
float code(float x, float s) {
float t_0 = fabsf(x) / s;
return 1.0f / ((1.0f + expf(t_0)) * (s + (s / (t_0 + 1.0f))));
}
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 = 1.0e0 / ((1.0e0 + exp(t_0)) * (s + (s / (t_0 + 1.0e0))))
end function
function code(x, s) t_0 = Float32(abs(x) / s) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + exp(t_0)) * Float32(s + Float32(s / Float32(t_0 + Float32(1.0)))))) end
function tmp = code(x, s) t_0 = abs(x) / s; tmp = single(1.0) / ((single(1.0) + exp(t_0)) * (s + (s / (t_0 + single(1.0))))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left|x\right|}{s}\\
\frac{1}{\left(1 + e^{t_0}\right) \cdot \left(s + \frac{s}{t_0 + 1}\right)}
\end{array}
\end{array}
Initial program 99.4%
Simplified99.3%
Taylor expanded in s around 0 99.4%
associate-*r*99.5%
+-commutative99.5%
neg-mul-199.5%
distribute-lft-in99.4%
*-rgt-identity99.4%
rem-exp-log98.0%
neg-mul-198.0%
exp-sum97.9%
neg-mul-197.9%
sub-neg97.9%
exp-diff98.0%
rem-exp-log99.4%
Simplified99.4%
Taylor expanded in s around inf 97.4%
+-commutative95.7%
Simplified97.4%
Final simplification97.4%
(FPCore (x s) :precision binary32 (/ (exp (/ (fabs x) (- s))) (+ s (/ (* s 3.0) (+ (/ (fabs x) s) 1.0)))))
float code(float x, float s) {
return expf((fabsf(x) / -s)) / (s + ((s * 3.0f) / ((fabsf(x) / s) + 1.0f)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = exp((abs(x) / -s)) / (s + ((s * 3.0e0) / ((abs(x) / s) + 1.0e0)))
end function
function code(x, s) return Float32(exp(Float32(abs(x) / Float32(-s))) / Float32(s + Float32(Float32(s * Float32(3.0)) / Float32(Float32(abs(x) / s) + Float32(1.0))))) end
function tmp = code(x, s) tmp = exp((abs(x) / -s)) / (s + ((s * single(3.0)) / ((abs(x) / s) + single(1.0)))); end
\begin{array}{l}
\\
\frac{e^{\frac{\left|x\right|}{-s}}}{s + \frac{s \cdot 3}{\frac{\left|x\right|}{s} + 1}}
\end{array}
Initial program 99.4%
Simplified99.4%
Taylor expanded in s around inf 96.2%
*-commutative96.2%
Simplified96.2%
Taylor expanded in s around inf 95.7%
+-commutative95.7%
Simplified95.7%
Final simplification95.7%
(FPCore (x s) :precision binary32 (/ 1.0 (* (+ s s) (+ 1.0 (pow E (/ (fabs x) s))))))
float code(float x, float s) {
return 1.0f / ((s + s) * (1.0f + powf(((float) M_E), (fabsf(x) / s))));
}
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(s + s) * Float32(Float32(1.0) + (Float32(exp(1)) ^ Float32(abs(x) / s))))) end
function tmp = code(x, s) tmp = single(1.0) / ((s + s) * (single(1.0) + (single(2.71828182845904523536) ^ (abs(x) / s)))); end
\begin{array}{l}
\\
\frac{1}{\left(s + s\right) \cdot \left(1 + {e}^{\left(\frac{\left|x\right|}{s}\right)}\right)}
\end{array}
Initial program 99.4%
Simplified99.3%
Taylor expanded in s around 0 99.4%
associate-*r*99.5%
+-commutative99.5%
neg-mul-199.5%
distribute-lft-in99.4%
*-rgt-identity99.4%
rem-exp-log98.0%
neg-mul-198.0%
exp-sum97.9%
neg-mul-197.9%
sub-neg97.9%
exp-diff98.0%
rem-exp-log99.4%
Simplified99.4%
Taylor expanded in s around inf 95.3%
*-un-lft-identity95.3%
exp-prod95.3%
exp-1-e95.3%
Applied egg-rr95.3%
Final simplification95.3%
(FPCore (x s)
:precision binary32
(let* ((t_0 (* x (/ x s))))
(if (<= (fabs x) 1.3500000359991076e-17)
(/ 1.0 (- (fma 2.0 t_0 (* s 4.0)) t_0))
(/ 0.5 (* s (exp (/ (fabs x) s)))))))
float code(float x, float s) {
float t_0 = x * (x / s);
float tmp;
if (fabsf(x) <= 1.3500000359991076e-17f) {
tmp = 1.0f / (fmaf(2.0f, t_0, (s * 4.0f)) - t_0);
} else {
tmp = 0.5f / (s * expf((fabsf(x) / s)));
}
return tmp;
}
function code(x, s) t_0 = Float32(x * Float32(x / s)) tmp = Float32(0.0) if (abs(x) <= Float32(1.3500000359991076e-17)) tmp = Float32(Float32(1.0) / Float32(fma(Float32(2.0), t_0, Float32(s * Float32(4.0))) - t_0)); else tmp = Float32(Float32(0.5) / Float32(s * exp(Float32(abs(x) / s)))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{x}{s}\\
\mathbf{if}\;\left|x\right| \leq 1.3500000359991076 \cdot 10^{-17}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(2, t_0, s \cdot 4\right) - t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{s \cdot e^{\frac{\left|x\right|}{s}}}\\
\end{array}
\end{array}
if (fabs.f32 x) < 1.35000004e-17Initial program 97.9%
Simplified97.9%
Taylor expanded in x around 0 98.2%
Taylor expanded in s around inf 80.3%
Simplified80.3%
expm1-log1p-u73.8%
expm1-udef73.8%
associate-/l*73.9%
associate-/l*75.2%
Applied egg-rr75.2%
expm1-def75.3%
expm1-log1p82.1%
associate-/r/82.1%
associate-/r/82.1%
Simplified82.1%
if 1.35000004e-17 < (fabs.f32 x) Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
add-exp-log99.7%
*-commutative99.7%
log-prod99.6%
add-log-exp99.6%
Applied egg-rr99.6%
Taylor expanded in s around inf 97.7%
Taylor expanded in s around 0 93.1%
exp-sum93.1%
rem-exp-log93.1%
Simplified93.1%
Final simplification90.2%
(FPCore (x s)
:precision binary32
(let* ((t_0 (* x (/ x s))))
(if (<= (fabs x) 5.0000000843119176e-17)
(/ 1.0 (- (fma 2.0 t_0 (* s 4.0)) t_0))
0.0)))
float code(float x, float s) {
float t_0 = x * (x / s);
float tmp;
if (fabsf(x) <= 5.0000000843119176e-17f) {
tmp = 1.0f / (fmaf(2.0f, t_0, (s * 4.0f)) - t_0);
} else {
tmp = 0.0f;
}
return tmp;
}
function code(x, s) t_0 = Float32(x * Float32(x / s)) tmp = Float32(0.0) if (abs(x) <= Float32(5.0000000843119176e-17)) tmp = Float32(Float32(1.0) / Float32(fma(Float32(2.0), t_0, Float32(s * Float32(4.0))) - t_0)); else tmp = Float32(0.0); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{x}{s}\\
\mathbf{if}\;\left|x\right| \leq 5.0000000843119176 \cdot 10^{-17}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(2, t_0, s \cdot 4\right) - t_0}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if (fabs.f32 x) < 5.00000008e-17Initial program 98.1%
Simplified98.0%
Taylor expanded in x around 0 98.3%
Taylor expanded in s around inf 78.1%
Simplified78.1%
expm1-log1p-u71.9%
expm1-udef71.9%
associate-/l*72.0%
associate-/l*73.2%
Applied egg-rr73.2%
expm1-def73.3%
expm1-log1p79.8%
associate-/r/79.8%
associate-/r/79.8%
Simplified79.8%
if 5.00000008e-17 < (fabs.f32 x) Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
add-exp-log99.7%
*-commutative99.7%
log-prod99.7%
add-log-exp99.7%
Applied egg-rr99.7%
Taylor expanded in s around inf 97.6%
Taylor expanded in s around inf 92.2%
Final simplification88.6%
(FPCore (x s) :precision binary32 (if (<= (fabs x) 5.0000000843119176e-17) (/ 1.0 (fma s 4.0 (/ x (/ s x)))) 0.0))
float code(float x, float s) {
float tmp;
if (fabsf(x) <= 5.0000000843119176e-17f) {
tmp = 1.0f / fmaf(s, 4.0f, (x / (s / x)));
} else {
tmp = 0.0f;
}
return tmp;
}
function code(x, s) tmp = Float32(0.0) if (abs(x) <= Float32(5.0000000843119176e-17)) tmp = Float32(Float32(1.0) / fma(s, Float32(4.0), Float32(x / Float32(s / x)))); else tmp = Float32(0.0); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 5.0000000843119176 \cdot 10^{-17}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(s, 4, \frac{x}{\frac{s}{x}}\right)}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if (fabs.f32 x) < 5.00000008e-17Initial program 98.1%
Simplified98.0%
Taylor expanded in x around 0 98.3%
Taylor expanded in s around inf 78.1%
Simplified78.1%
Taylor expanded in x around 0 78.1%
*-commutative78.1%
fma-def78.1%
unpow278.1%
associate-/l*79.8%
Simplified79.8%
if 5.00000008e-17 < (fabs.f32 x) Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
add-exp-log99.7%
*-commutative99.7%
log-prod99.7%
add-log-exp99.7%
Applied egg-rr99.7%
Taylor expanded in s around inf 97.6%
Taylor expanded in s around inf 92.2%
Final simplification88.6%
(FPCore (x s) :precision binary32 (/ 0.5 (* s (+ 1.0 (exp (/ (fabs x) s))))))
float code(float x, float s) {
return 0.5f / (s * (1.0f + expf((fabsf(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((abs(x) / s))))
end function
function code(x, s) return Float32(Float32(0.5) / Float32(s * Float32(Float32(1.0) + exp(Float32(abs(x) / s))))) end
function tmp = code(x, s) tmp = single(0.5) / (s * (single(1.0) + exp((abs(x) / s)))); end
\begin{array}{l}
\\
\frac{0.5}{s \cdot \left(1 + e^{\frac{\left|x\right|}{s}}\right)}
\end{array}
Initial program 99.4%
Simplified99.3%
Taylor expanded in s around 0 99.4%
associate-*r*99.5%
+-commutative99.5%
neg-mul-199.5%
distribute-lft-in99.4%
*-rgt-identity99.4%
rem-exp-log98.0%
neg-mul-198.0%
exp-sum97.9%
neg-mul-197.9%
sub-neg97.9%
exp-diff98.0%
rem-exp-log99.4%
Simplified99.4%
Taylor expanded in s around inf 95.3%
Taylor expanded in s around 0 95.3%
Final simplification95.3%
(FPCore (x s) :precision binary32 (/ (exp (/ (fabs x) (- s))) (* s 4.0)))
float code(float x, float s) {
return expf((fabsf(x) / -s)) / (s * 4.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = exp((abs(x) / -s)) / (s * 4.0e0)
end function
function code(x, s) return Float32(exp(Float32(abs(x) / Float32(-s))) / Float32(s * Float32(4.0))) end
function tmp = code(x, s) tmp = exp((abs(x) / -s)) / (s * single(4.0)); end
\begin{array}{l}
\\
\frac{e^{\frac{\left|x\right|}{-s}}}{s \cdot 4}
\end{array}
Initial program 99.4%
Simplified99.4%
Taylor expanded in s around inf 94.9%
*-commutative94.9%
Simplified94.9%
Final simplification94.9%
(FPCore (x s) :precision binary32 (if (<= (fabs x) 5.0000000843119176e-17) (/ 1.0 (- (+ (* s 4.0) (* 2.0 (/ x (/ s x)))) (/ (* x x) s))) 0.0))
float code(float x, float s) {
float tmp;
if (fabsf(x) <= 5.0000000843119176e-17f) {
tmp = 1.0f / (((s * 4.0f) + (2.0f * (x / (s / x)))) - ((x * x) / s));
} else {
tmp = 0.0f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (abs(x) <= 5.0000000843119176e-17) then
tmp = 1.0e0 / (((s * 4.0e0) + (2.0e0 * (x / (s / x)))) - ((x * x) / s))
else
tmp = 0.0e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (abs(x) <= Float32(5.0000000843119176e-17)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(s * Float32(4.0)) + Float32(Float32(2.0) * Float32(x / Float32(s / x)))) - Float32(Float32(x * x) / s))); else tmp = Float32(0.0); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (abs(x) <= single(5.0000000843119176e-17)) tmp = single(1.0) / (((s * single(4.0)) + (single(2.0) * (x / (s / x)))) - ((x * x) / s)); else tmp = single(0.0); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 5.0000000843119176 \cdot 10^{-17}:\\
\;\;\;\;\frac{1}{\left(s \cdot 4 + 2 \cdot \frac{x}{\frac{s}{x}}\right) - \frac{x \cdot x}{s}}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if (fabs.f32 x) < 5.00000008e-17Initial program 98.1%
Simplified98.0%
Taylor expanded in x around 0 98.3%
Taylor expanded in s around inf 78.1%
Simplified78.1%
fma-udef78.1%
associate-/l*78.2%
Applied egg-rr78.2%
if 5.00000008e-17 < (fabs.f32 x) Initial program 99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
add-exp-log99.7%
*-commutative99.7%
log-prod99.7%
add-log-exp99.7%
Applied egg-rr99.7%
Taylor expanded in s around inf 97.6%
Taylor expanded in s around inf 92.2%
Final simplification88.1%
(FPCore (x s) :precision binary32 (if (<= x 1.3500000359991076e-17) (/ 0.25 s) 0.0))
float code(float x, float s) {
float tmp;
if (x <= 1.3500000359991076e-17f) {
tmp = 0.25f / s;
} else {
tmp = 0.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.3500000359991076e-17) then
tmp = 0.25e0 / s
else
tmp = 0.0e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.3500000359991076e-17)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(0.0); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.3500000359991076e-17)) tmp = single(0.25) / s; else tmp = single(0.0); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.3500000359991076 \cdot 10^{-17}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.35000004e-17Initial program 99.1%
Simplified99.1%
Taylor expanded in s around inf 42.6%
if 1.35000004e-17 < x Initial program 99.8%
Simplified99.9%
Taylor expanded in x around 0 99.9%
add-exp-log99.7%
*-commutative99.7%
log-prod99.6%
add-log-exp99.6%
Applied egg-rr99.6%
Taylor expanded in s around inf 97.7%
Taylor expanded in s around inf 91.4%
Final simplification61.5%
(FPCore (x s) :precision binary32 0.0)
float code(float x, float s) {
return 0.0f;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.0e0
end function
function code(x, s) return Float32(0.0) end
function tmp = code(x, s) tmp = single(0.0); end
\begin{array}{l}
\\
0
\end{array}
Initial program 99.4%
Simplified99.3%
Taylor expanded in x around 0 99.4%
add-exp-log97.9%
*-commutative97.9%
log-prod97.9%
add-log-exp98.1%
Applied egg-rr98.1%
Taylor expanded in s around inf 94.4%
Taylor expanded in s around inf 71.1%
Final simplification71.1%
herbie shell --seed 2023274
(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))))))