
(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 16 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 (- 0.0 (/ (fabs x) s))))) (/ (/ -1.0 (- (- (/ -1.0 t_0) 2.0) t_0)) s)))
float code(float x, float s) {
float t_0 = expf((0.0f - (fabsf(x) / s)));
return (-1.0f / (((-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((0.0e0 - (abs(x) / s)))
code = ((-1.0e0) / ((((-1.0e0) / t_0) - 2.0e0) - t_0)) / s
end function
function code(x, s) t_0 = exp(Float32(Float32(0.0) - Float32(abs(x) / s))) return Float32(Float32(Float32(-1.0) / Float32(Float32(Float32(Float32(-1.0) / t_0) - Float32(2.0)) - t_0)) / s) end
function tmp = code(x, s) t_0 = exp((single(0.0) - (abs(x) / s))); tmp = (single(-1.0) / (((single(-1.0) / t_0) - single(2.0)) - t_0)) / s; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{0 - \frac{\left|x\right|}{s}}\\
\frac{\frac{-1}{\left(\frac{-1}{t\_0} - 2\right) - t\_0}}{s}
\end{array}
\end{array}
Initial program 99.7%
Simplified99.9%
frac-2negN/A
distribute-frac-neg2N/A
rec-expN/A
/-lowering-/.f32N/A
exp-lowering-exp.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
neg-lowering-neg.f3299.9%
Applied egg-rr99.9%
sub0-negN/A
neg-lowering-neg.f32N/A
fabs-lowering-fabs.f3299.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x s) :precision binary32 (/ (/ 0.5 (+ (cosh (/ (fabs x) s)) 1.0)) s))
float code(float x, float s) {
return (0.5f / (coshf((fabsf(x) / s)) + 1.0f)) / s;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (0.5e0 / (cosh((abs(x) / s)) + 1.0e0)) / s
end function
function code(x, s) return Float32(Float32(Float32(0.5) / Float32(cosh(Float32(abs(x) / s)) + Float32(1.0))) / s) end
function tmp = code(x, s) tmp = (single(0.5) / (cosh((abs(x) / s)) + single(1.0))) / s; end
\begin{array}{l}
\\
\frac{\frac{0.5}{\cosh \left(\frac{\left|x\right|}{s}\right) + 1}}{s}
\end{array}
Initial program 99.7%
Simplified99.9%
associate-/l/N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
associate-+r+N/A
+-commutativeN/A
+-lowering-+.f32N/A
neg-sub0N/A
frac-2negN/A
distribute-frac-neg2N/A
cosh-undefN/A
*-lowering-*.f32N/A
distribute-frac-negN/A
cosh-negN/A
cosh-lowering-cosh.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.9%
Applied egg-rr99.9%
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
*-lowering-*.f32N/A
+-lowering-+.f32N/A
*-lowering-*.f32N/A
cosh-lowering-cosh.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.9%
Applied egg-rr99.9%
associate-/r*N/A
*-commutativeN/A
distribute-lft1-inN/A
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
metadata-evalN/A
+-lowering-+.f32N/A
cosh-lowering-cosh.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.9%
Applied egg-rr99.9%
(FPCore (x s) :precision binary32 (/ 0.5 (* s (+ (cosh (/ (fabs x) s)) 1.0))))
float code(float x, float s) {
return 0.5f / (s * (coshf((fabsf(x) / s)) + 1.0f));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.5e0 / (s * (cosh((abs(x) / s)) + 1.0e0))
end function
function code(x, s) return Float32(Float32(0.5) / Float32(s * Float32(cosh(Float32(abs(x) / s)) + Float32(1.0)))) end
function tmp = code(x, s) tmp = single(0.5) / (s * (cosh((abs(x) / s)) + single(1.0))); end
\begin{array}{l}
\\
\frac{0.5}{s \cdot \left(\cosh \left(\frac{\left|x\right|}{s}\right) + 1\right)}
\end{array}
Initial program 99.7%
Simplified99.9%
associate-/l/N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
associate-+r+N/A
+-commutativeN/A
+-lowering-+.f32N/A
neg-sub0N/A
frac-2negN/A
distribute-frac-neg2N/A
cosh-undefN/A
*-lowering-*.f32N/A
distribute-frac-negN/A
cosh-negN/A
cosh-lowering-cosh.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.9%
Applied egg-rr99.9%
+-commutativeN/A
distribute-lft-inN/A
*-commutativeN/A
associate-*r*N/A
distribute-rgt-outN/A
*-lowering-*.f32N/A
+-lowering-+.f32N/A
*-lowering-*.f32N/A
cosh-lowering-cosh.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.9%
Applied egg-rr99.9%
associate-/r*N/A
/-lowering-/.f32N/A
metadata-evalN/A
*-rgt-identityN/A
distribute-lft-outN/A
*-lowering-*.f32N/A
+-lowering-+.f32N/A
cosh-lowering-cosh.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.9%
Applied egg-rr99.9%
(FPCore (x s) :precision binary32 (/ (exp (- 0.0 (/ (fabs x) s))) (* s 4.0)))
float code(float x, float s) {
return expf((0.0f - (fabsf(x) / s))) / (s * 4.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = exp((0.0e0 - (abs(x) / s))) / (s * 4.0e0)
end function
function code(x, s) return Float32(exp(Float32(Float32(0.0) - Float32(abs(x) / s))) / Float32(s * Float32(4.0))) end
function tmp = code(x, s) tmp = exp((single(0.0) - (abs(x) / s))) / (s * single(4.0)); end
\begin{array}{l}
\\
\frac{e^{0 - \frac{\left|x\right|}{s}}}{s \cdot 4}
\end{array}
Initial program 99.7%
Taylor expanded in s around inf
*-commutativeN/A
*-lowering-*.f3295.9%
Simplified95.9%
Final simplification95.9%
(FPCore (x s) :precision binary32 (/ (/ 0.25 s) (exp (/ (fabs x) s))))
float code(float x, float s) {
return (0.25f / s) / expf((fabsf(x) / s));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (0.25e0 / s) / exp((abs(x) / s))
end function
function code(x, s) return Float32(Float32(Float32(0.25) / s) / exp(Float32(abs(x) / s))) end
function tmp = code(x, s) tmp = (single(0.25) / s) / exp((abs(x) / s)); end
\begin{array}{l}
\\
\frac{\frac{0.25}{s}}{e^{\frac{\left|x\right|}{s}}}
\end{array}
Initial program 99.7%
Taylor expanded in s around inf
*-commutativeN/A
*-lowering-*.f3295.9%
Simplified95.9%
clear-numN/A
div-invN/A
distribute-frac-negN/A
distribute-frac-neg2N/A
associate-/r*N/A
/-lowering-/.f32N/A
*-commutativeN/A
associate-/r*N/A
/-lowering-/.f32N/A
metadata-evalN/A
rec-expN/A
distribute-frac-neg2N/A
remove-double-negN/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3295.9%
Applied egg-rr95.9%
(FPCore (x s) :precision binary32 (if (<= s 1.5000000786160286e-23) (/ (/ 1.0 s) (/ (* x x) (* s s))) (/ 1.0 (+ (* x (/ x s)) (/ s 0.25)))))
float code(float x, float s) {
float tmp;
if (s <= 1.5000000786160286e-23f) {
tmp = (1.0f / s) / ((x * x) / (s * s));
} else {
tmp = 1.0f / ((x * (x / s)) + (s / 0.25f));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (s <= 1.5000000786160286e-23) then
tmp = (1.0e0 / s) / ((x * x) / (s * s))
else
tmp = 1.0e0 / ((x * (x / s)) + (s / 0.25e0))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (s <= Float32(1.5000000786160286e-23)) tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(x * x) / Float32(s * s))); else tmp = Float32(Float32(1.0) / Float32(Float32(x * Float32(x / s)) + Float32(s / Float32(0.25)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (s <= single(1.5000000786160286e-23)) tmp = (single(1.0) / s) / ((x * x) / (s * s)); else tmp = single(1.0) / ((x * (x / s)) + (s / single(0.25))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;s \leq 1.5000000786160286 \cdot 10^{-23}:\\
\;\;\;\;\frac{\frac{1}{s}}{\frac{x \cdot x}{s \cdot s}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \frac{x}{s} + \frac{s}{0.25}}\\
\end{array}
\end{array}
if s < 1.50000008e-23Initial program 99.9%
Simplified99.9%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified76.9%
associate-/r*N/A
associate-/l/N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
div-invN/A
sub0-negN/A
cancel-sign-subN/A
div-invN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
associate-/l*N/A
*-lowering-*.f32N/A
/-lowering-/.f3277.3%
Applied egg-rr77.3%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3284.7%
Simplified84.7%
if 1.50000008e-23 < s Initial program 99.7%
Simplified99.9%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified76.0%
associate-/l/N/A
/-lowering-/.f32N/A
div-invN/A
sub0-negN/A
cancel-sign-subN/A
div-invN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
associate-/r/N/A
clear-numN/A
div-invN/A
associate-*l*N/A
Applied egg-rr71.4%
(FPCore (x s) :precision binary32 (if (<= x 5.00000006675716e-11) (/ 1.0 (+ (* x (/ x s)) (/ s 0.25))) (/ (* s (/ s (* x x))) s)))
float code(float x, float s) {
float tmp;
if (x <= 5.00000006675716e-11f) {
tmp = 1.0f / ((x * (x / s)) + (s / 0.25f));
} else {
tmp = (s * (s / (x * 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 <= 5.00000006675716e-11) then
tmp = 1.0e0 / ((x * (x / s)) + (s / 0.25e0))
else
tmp = (s * (s / (x * x))) / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(5.00000006675716e-11)) tmp = Float32(Float32(1.0) / Float32(Float32(x * Float32(x / s)) + Float32(s / Float32(0.25)))); else tmp = Float32(Float32(s * Float32(s / Float32(x * x))) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(5.00000006675716e-11)) tmp = single(1.0) / ((x * (x / s)) + (s / single(0.25))); else tmp = (s * (s / (x * x))) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.00000006675716 \cdot 10^{-11}:\\
\;\;\;\;\frac{1}{x \cdot \frac{x}{s} + \frac{s}{0.25}}\\
\mathbf{else}:\\
\;\;\;\;\frac{s \cdot \frac{s}{x \cdot x}}{s}\\
\end{array}
\end{array}
if x < 5.00000007e-11Initial program 99.7%
Simplified99.9%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified73.8%
associate-/l/N/A
/-lowering-/.f32N/A
div-invN/A
sub0-negN/A
cancel-sign-subN/A
div-invN/A
+-commutativeN/A
distribute-rgt-inN/A
metadata-evalN/A
associate-/r/N/A
clear-numN/A
div-invN/A
associate-*l*N/A
Applied egg-rr66.0%
if 5.00000007e-11 < x Initial program 99.8%
Simplified99.8%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified81.3%
Taylor expanded in x around inf
unpow2N/A
associate-/l*N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3274.6%
Simplified74.6%
(FPCore (x s) :precision binary32 (/ (/ -1.0 (- (* x (* x (/ -1.0 (* s s)))) 4.0)) s))
float code(float x, float s) {
return (-1.0f / ((x * (x * (-1.0f / (s * s)))) - 4.0f)) / s;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = ((-1.0e0) / ((x * (x * ((-1.0e0) / (s * s)))) - 4.0e0)) / s
end function
function code(x, s) return Float32(Float32(Float32(-1.0) / Float32(Float32(x * Float32(x * Float32(Float32(-1.0) / Float32(s * s)))) - Float32(4.0))) / s) end
function tmp = code(x, s) tmp = (single(-1.0) / ((x * (x * (single(-1.0) / (s * s)))) - single(4.0))) / s; end
\begin{array}{l}
\\
\frac{\frac{-1}{x \cdot \left(x \cdot \frac{-1}{s \cdot s}\right) - 4}}{s}
\end{array}
Initial program 99.7%
Simplified99.9%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified76.4%
sub0-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
associate-/l*N/A
*-lowering-*.f32N/A
neg-lowering-neg.f32N/A
associate-/l/N/A
/-lowering-/.f32N/A
*-lowering-*.f3282.3%
Applied egg-rr82.3%
clear-numN/A
associate-/r/N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f3282.7%
Applied egg-rr82.7%
Final simplification82.7%
(FPCore (x s) :precision binary32 (if (<= x 1.9999999920083944e-12) (/ 0.25 s) (/ (* s (/ s (* x x))) s)))
float code(float x, float s) {
float tmp;
if (x <= 1.9999999920083944e-12f) {
tmp = 0.25f / s;
} else {
tmp = (s * (s / (x * 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 <= 1.9999999920083944e-12) then
tmp = 0.25e0 / s
else
tmp = (s * (s / (x * x))) / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.9999999920083944e-12)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(s * Float32(s / Float32(x * x))) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.9999999920083944e-12)) tmp = single(0.25) / s; else tmp = (s * (s / (x * x))) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.9999999920083944 \cdot 10^{-12}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{s \cdot \frac{s}{x \cdot x}}{s}\\
\end{array}
\end{array}
if x < 1.99999999e-12Initial program 99.7%
Taylor expanded in s around inf
/-lowering-/.f3237.5%
Simplified37.5%
if 1.99999999e-12 < x Initial program 99.8%
Simplified99.8%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified81.3%
Taylor expanded in x around inf
unpow2N/A
associate-/l*N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3274.6%
Simplified74.6%
(FPCore (x s) :precision binary32 (/ (/ 1.0 (+ 4.0 (* x (/ x (* s s))))) s))
float code(float x, float s) {
return (1.0f / (4.0f + (x * (x / (s * s))))) / s;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / (4.0e0 + (x * (x / (s * s))))) / s
end function
function code(x, s) return Float32(Float32(Float32(1.0) / Float32(Float32(4.0) + Float32(x * Float32(x / Float32(s * s))))) / s) end
function tmp = code(x, s) tmp = (single(1.0) / (single(4.0) + (x * (x / (s * s))))) / s; end
\begin{array}{l}
\\
\frac{\frac{1}{4 + x \cdot \frac{x}{s \cdot s}}}{s}
\end{array}
Initial program 99.7%
Simplified99.9%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified76.4%
sub0-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
associate-/l*N/A
*-lowering-*.f32N/A
neg-lowering-neg.f32N/A
associate-/l/N/A
/-lowering-/.f32N/A
*-lowering-*.f3282.3%
Applied egg-rr82.3%
Final simplification82.3%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ 4.0 (/ x (/ (* s s) x))))))
float code(float x, float s) {
return 1.0f / (s * (4.0f + (x / ((s * s) / x))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (s * (4.0e0 + (x / ((s * s) / x))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(x / Float32(Float32(s * s) / x))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (single(4.0) + (x / ((s * s) / x)))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(4 + \frac{x}{\frac{s \cdot s}{x}}\right)}
\end{array}
Initial program 99.7%
Simplified99.9%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified76.4%
sub0-negN/A
associate-/l*N/A
distribute-lft-neg-inN/A
associate-/l*N/A
*-lowering-*.f32N/A
neg-lowering-neg.f32N/A
associate-/l/N/A
/-lowering-/.f32N/A
*-lowering-*.f3282.3%
Applied egg-rr82.3%
associate-/r*N/A
associate-/l/N/A
cancel-sign-subN/A
+-commutativeN/A
div-invN/A
associate-*r*N/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
div-invN/A
*-commutativeN/A
distribute-lft-inN/A
associate-*l*N/A
associate-*l*N/A
associate-/r*N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
Applied egg-rr82.3%
(FPCore (x s) :precision binary32 (if (<= x 4.999999858590343e-10) (/ 0.25 s) (/ 1.0 (/ (* x x) s))))
float code(float x, float s) {
float tmp;
if (x <= 4.999999858590343e-10f) {
tmp = 0.25f / s;
} else {
tmp = 1.0f / ((x * 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 <= 4.999999858590343e-10) then
tmp = 0.25e0 / s
else
tmp = 1.0e0 / ((x * x) / s)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(4.999999858590343e-10)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(1.0) / Float32(Float32(x * x) / s)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(4.999999858590343e-10)) tmp = single(0.25) / s; else tmp = single(1.0) / ((x * x) / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.999999858590343 \cdot 10^{-10}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x}{s}}\\
\end{array}
\end{array}
if x < 4.99999986e-10Initial program 99.7%
Taylor expanded in s around inf
/-lowering-/.f3237.4%
Simplified37.4%
if 4.99999986e-10 < x Initial program 99.8%
Simplified99.8%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified82.1%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3264.3%
Simplified64.3%
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f3264.3%
Applied egg-rr64.3%
clear-numN/A
associate-/l/N/A
/-lowering-/.f32N/A
associate-*r/N/A
/-lowering-/.f32N/A
*-lowering-*.f3267.1%
Applied egg-rr67.1%
(FPCore (x s) :precision binary32 (if (<= x 4.999999858590343e-10) (/ 0.25 s) (/ 1.0 (/ x (/ s x)))))
float code(float x, float s) {
float tmp;
if (x <= 4.999999858590343e-10f) {
tmp = 0.25f / s;
} else {
tmp = 1.0f / (x / (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 <= 4.999999858590343e-10) then
tmp = 0.25e0 / s
else
tmp = 1.0e0 / (x / (s / x))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(4.999999858590343e-10)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(1.0) / Float32(x / Float32(s / x))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(4.999999858590343e-10)) tmp = single(0.25) / s; else tmp = single(1.0) / (x / (s / x)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.999999858590343 \cdot 10^{-10}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x}{\frac{s}{x}}}\\
\end{array}
\end{array}
if x < 4.99999986e-10Initial program 99.7%
Taylor expanded in s around inf
/-lowering-/.f3237.4%
Simplified37.4%
if 4.99999986e-10 < x Initial program 99.8%
Simplified99.8%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified82.1%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3264.3%
Simplified64.3%
clear-numN/A
/-lowering-/.f32N/A
clear-numN/A
associate-/r*N/A
clear-numN/A
/-lowering-/.f32N/A
/-lowering-/.f3267.1%
Applied egg-rr67.1%
(FPCore (x s) :precision binary32 (if (<= x 4.999999858590343e-10) (/ 0.25 s) (/ (/ s x) x)))
float code(float x, float s) {
float tmp;
if (x <= 4.999999858590343e-10f) {
tmp = 0.25f / s;
} else {
tmp = (s / 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 <= 4.999999858590343e-10) then
tmp = 0.25e0 / s
else
tmp = (s / x) / x
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(4.999999858590343e-10)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(s / x) / x); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(4.999999858590343e-10)) tmp = single(0.25) / s; else tmp = (s / x) / x; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.999999858590343 \cdot 10^{-10}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{s}{x}}{x}\\
\end{array}
\end{array}
if x < 4.99999986e-10Initial program 99.7%
Taylor expanded in s around inf
/-lowering-/.f3237.4%
Simplified37.4%
if 4.99999986e-10 < x Initial program 99.8%
Simplified99.8%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified82.1%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3264.3%
Simplified64.3%
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f3264.3%
Applied egg-rr64.3%
(FPCore (x s) :precision binary32 (if (<= x 4.999999858590343e-10) (/ 0.25 s) (/ s (* x x))))
float code(float x, float s) {
float tmp;
if (x <= 4.999999858590343e-10f) {
tmp = 0.25f / s;
} else {
tmp = s / (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 <= 4.999999858590343e-10) then
tmp = 0.25e0 / s
else
tmp = s / (x * x)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(4.999999858590343e-10)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(s / Float32(x * x)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(4.999999858590343e-10)) tmp = single(0.25) / s; else tmp = s / (x * x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.999999858590343 \cdot 10^{-10}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{s}{x \cdot x}\\
\end{array}
\end{array}
if x < 4.99999986e-10Initial program 99.7%
Taylor expanded in s around inf
/-lowering-/.f3237.4%
Simplified37.4%
if 4.99999986e-10 < x Initial program 99.8%
Simplified99.8%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
distribute-rgt1-inN/A
metadata-evalN/A
mul0-lftN/A
neg-sub0N/A
mul-1-negN/A
/-lowering-/.f32N/A
Simplified82.1%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3264.3%
Simplified64.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.7%
Taylor expanded in s around inf
/-lowering-/.f3226.6%
Simplified26.6%
herbie shell --seed 2024164
(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))))))