
(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 (/ (exp (- (log (+ 2.0 (* 2.0 (cosh (/ (fabs x) s))))))) s))
float code(float x, float s) {
return expf(-logf((2.0f + (2.0f * coshf((fabsf(x) / s)))))) / s;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = exp(-log((2.0e0 + (2.0e0 * cosh((abs(x) / s)))))) / s
end function
function code(x, s) return Float32(exp(Float32(-log(Float32(Float32(2.0) + Float32(Float32(2.0) * cosh(Float32(abs(x) / s))))))) / s) end
function tmp = code(x, s) tmp = exp(-log((single(2.0) + (single(2.0) * cosh((abs(x) / s)))))) / s; end
\begin{array}{l}
\\
\frac{e^{-\log \left(2 + 2 \cdot \cosh \left(\frac{\left|x\right|}{s}\right)\right)}}{s}
\end{array}
Initial program 99.3%
Simplified99.4%
inv-powN/A
pow-to-expN/A
exp-lowering-exp.f32N/A
*-lowering-*.f32N/A
Applied egg-rr99.4%
exp-lowering-exp.f32N/A
*-commutativeN/A
mul-1-negN/A
neg-lowering-neg.f32N/A
+-commutativeN/A
log-lowering-log.f32N/A
+-commutativeN/A
+-lowering-+.f32N/A
*-lowering-*.f32N/A
cosh-lowering-cosh.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.4%
Applied egg-rr99.4%
(FPCore (x s) :precision binary32 (/ (/ 1.0 (+ 2.0 (* 2.0 (cosh (/ (fabs x) s))))) s))
float code(float x, float s) {
return (1.0f / (2.0f + (2.0f * coshf((fabsf(x) / s))))) / s;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / (2.0e0 + (2.0e0 * cosh((abs(x) / s))))) / s
end function
function code(x, s) return Float32(Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(Float32(2.0) * cosh(Float32(abs(x) / s))))) / s) end
function tmp = code(x, s) tmp = (single(1.0) / (single(2.0) + (single(2.0) * cosh((abs(x) / s))))) / s; end
\begin{array}{l}
\\
\frac{\frac{1}{2 + 2 \cdot \cosh \left(\frac{\left|x\right|}{s}\right)}}{s}
\end{array}
Initial program 99.3%
Simplified99.4%
associate-+r+N/A
+-lowering-+.f32N/A
distribute-frac-negN/A
+-commutativeN/A
distribute-frac-negN/A
cosh-undefN/A
*-lowering-*.f32N/A
cosh-lowering-cosh.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ 2.0 (* 2.0 (cosh (/ (fabs x) s)))))))
float code(float x, float s) {
return 1.0f / (s * (2.0f + (2.0f * coshf((fabsf(x) / s)))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (s * (2.0e0 + (2.0e0 * cosh((abs(x) / s)))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * cosh(Float32(abs(x) / s)))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * cosh((abs(x) / s))))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(2 + 2 \cdot \cosh \left(\frac{\left|x\right|}{s}\right)\right)}
\end{array}
Initial program 99.3%
Simplified99.4%
associate-/l/N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
associate-+r+N/A
+-commutativeN/A
+-lowering-+.f32N/A
distribute-frac-negN/A
+-commutativeN/A
distribute-frac-negN/A
cosh-undefN/A
*-lowering-*.f32N/A
cosh-lowering-cosh.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.4%
Applied egg-rr99.4%
(FPCore (x s)
:precision binary32
(let* ((t_0 (/ x (/ (* s s) x))) (t_1 (/ x (/ s x))))
(if (<= x 1.9999999996399175e-23)
(/ (/ 1.0 (- (/ x (/ s (/ x s))) -4.0)) s)
(/
(/
256.0
(*
(+ (/ t_0 (/ (/ (* s (* s s)) (* x x)) t_1)) 64.0)
(- 16.0 (/ (+ -4.0 t_0) (/ s t_1)))))
s))))
float code(float x, float s) {
float t_0 = x / ((s * s) / x);
float t_1 = x / (s / x);
float tmp;
if (x <= 1.9999999996399175e-23f) {
tmp = (1.0f / ((x / (s / (x / s))) - -4.0f)) / s;
} else {
tmp = (256.0f / (((t_0 / (((s * (s * s)) / (x * x)) / t_1)) + 64.0f) * (16.0f - ((-4.0f + t_0) / (s / t_1))))) / 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 = x / ((s * s) / x)
t_1 = x / (s / x)
if (x <= 1.9999999996399175e-23) then
tmp = (1.0e0 / ((x / (s / (x / s))) - (-4.0e0))) / s
else
tmp = (256.0e0 / (((t_0 / (((s * (s * s)) / (x * x)) / t_1)) + 64.0e0) * (16.0e0 - (((-4.0e0) + t_0) / (s / t_1))))) / s
end if
code = tmp
end function
function code(x, s) t_0 = Float32(x / Float32(Float32(s * s) / x)) t_1 = Float32(x / Float32(s / x)) tmp = Float32(0.0) if (x <= Float32(1.9999999996399175e-23)) tmp = Float32(Float32(Float32(1.0) / Float32(Float32(x / Float32(s / Float32(x / s))) - Float32(-4.0))) / s); else tmp = Float32(Float32(Float32(256.0) / Float32(Float32(Float32(t_0 / Float32(Float32(Float32(s * Float32(s * s)) / Float32(x * x)) / t_1)) + Float32(64.0)) * Float32(Float32(16.0) - Float32(Float32(Float32(-4.0) + t_0) / Float32(s / t_1))))) / s); end return tmp end
function tmp_2 = code(x, s) t_0 = x / ((s * s) / x); t_1 = x / (s / x); tmp = single(0.0); if (x <= single(1.9999999996399175e-23)) tmp = (single(1.0) / ((x / (s / (x / s))) - single(-4.0))) / s; else tmp = (single(256.0) / (((t_0 / (((s * (s * s)) / (x * x)) / t_1)) + single(64.0)) * (single(16.0) - ((single(-4.0) + t_0) / (s / t_1))))) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{\frac{s \cdot s}{x}}\\
t_1 := \frac{x}{\frac{s}{x}}\\
\mathbf{if}\;x \leq 1.9999999996399175 \cdot 10^{-23}:\\
\;\;\;\;\frac{\frac{1}{\frac{x}{\frac{s}{\frac{x}{s}}} - -4}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{256}{\left(\frac{t\_0}{\frac{\frac{s \cdot \left(s \cdot s\right)}{x \cdot x}}{t\_1}} + 64\right) \cdot \left(16 - \frac{-4 + t\_0}{\frac{s}{t\_1}}\right)}}{s}\\
\end{array}
\end{array}
if x < 2e-23Initial program 99.1%
Simplified99.2%
Taylor expanded in s around inf
+-commutativeN/A
associate-+r+N/A
distribute-lft1-inN/A
metadata-evalN/A
mul0-lftN/A
+-lft-identityN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3277.3%
Simplified77.3%
times-fracN/A
associate-*r/N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
/-lowering-/.f3277.0%
Applied egg-rr77.0%
associate-/l*N/A
frac-timesN/A
associate-*l/N/A
associate-/r/N/A
metadata-evalN/A
sub-negN/A
--lowering--.f32N/A
/-lowering-/.f32N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f32N/A
/-lowering-/.f3280.6%
Applied egg-rr80.6%
if 2e-23 < x Initial program 99.7%
Simplified99.7%
Taylor expanded in s around inf
+-commutativeN/A
associate-+r+N/A
distribute-lft1-inN/A
metadata-evalN/A
mul0-lftN/A
+-lft-identityN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3283.0%
Simplified83.0%
Applied egg-rr13.5%
Applied egg-rr10.6%
Taylor expanded in x around 0
Simplified92.7%
Final simplification85.4%
(FPCore (x s) :precision binary32 (/ (/ -4.0 (+ (/ (/ (/ x (/ (* s s) x)) (/ s x)) (/ s x)) -16.0)) s))
float code(float x, float s) {
return (-4.0f / ((((x / ((s * s) / x)) / (s / x)) / (s / x)) + -16.0f)) / s;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = ((-4.0e0) / ((((x / ((s * s) / x)) / (s / x)) / (s / x)) + (-16.0e0))) / s
end function
function code(x, s) return Float32(Float32(Float32(-4.0) / Float32(Float32(Float32(Float32(x / Float32(Float32(s * s) / x)) / Float32(s / x)) / Float32(s / x)) + Float32(-16.0))) / s) end
function tmp = code(x, s) tmp = (single(-4.0) / ((((x / ((s * s) / x)) / (s / x)) / (s / x)) + single(-16.0))) / s; end
\begin{array}{l}
\\
\frac{\frac{-4}{\frac{\frac{\frac{x}{\frac{s \cdot s}{x}}}{\frac{s}{x}}}{\frac{s}{x}} + -16}}{s}
\end{array}
Initial program 99.3%
Simplified99.4%
Taylor expanded in s around inf
+-commutativeN/A
associate-+r+N/A
distribute-lft1-inN/A
metadata-evalN/A
mul0-lftN/A
+-lft-identityN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3279.6%
Simplified79.6%
flip-+N/A
clear-numN/A
/-lowering-/.f32N/A
sub-negN/A
+-lowering-+.f32N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
metadata-evalN/A
sub-negN/A
+-lowering-+.f32N/A
Applied egg-rr26.4%
Taylor expanded in x around 0
Simplified87.6%
(FPCore (x s) :precision binary32 (if (<= x 1.000000031374395e-22) (/ 0.25 s) (/ (/ 1.0 (/ (* x x) (* s s))) s)))
float code(float x, float s) {
float tmp;
if (x <= 1.000000031374395e-22f) {
tmp = 0.25f / s;
} else {
tmp = (1.0f / ((x * x) / (s * s))) / 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.000000031374395e-22) then
tmp = 0.25e0 / s
else
tmp = (1.0e0 / ((x * x) / (s * s))) / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.000000031374395e-22)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(Float32(1.0) / Float32(Float32(x * x) / Float32(s * s))) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.000000031374395e-22)) tmp = single(0.25) / s; else tmp = (single(1.0) / ((x * x) / (s * s))) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.000000031374395 \cdot 10^{-22}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\frac{x \cdot x}{s \cdot s}}}{s}\\
\end{array}
\end{array}
if x < 1.00000003e-22Initial program 99.1%
Taylor expanded in s around inf
/-lowering-/.f3234.6%
Simplified34.6%
if 1.00000003e-22 < x Initial program 99.7%
Simplified99.7%
Taylor expanded in s around inf
+-commutativeN/A
associate-+r+N/A
distribute-lft1-inN/A
metadata-evalN/A
mul0-lftN/A
+-lft-identityN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3283.0%
Simplified83.0%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3273.5%
Simplified73.5%
(FPCore (x s) :precision binary32 (if (<= x 1.000000031374395e-22) (/ 0.25 s) (/ (/ (* s s) (* x x)) s)))
float code(float x, float s) {
float tmp;
if (x <= 1.000000031374395e-22f) {
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.000000031374395e-22) 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.000000031374395e-22)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(Float32(s * s) / Float32(x * x)) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.000000031374395e-22)) 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.000000031374395 \cdot 10^{-22}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{s \cdot s}{x \cdot x}}{s}\\
\end{array}
\end{array}
if x < 1.00000003e-22Initial program 99.1%
Taylor expanded in s around inf
/-lowering-/.f3234.6%
Simplified34.6%
if 1.00000003e-22 < x Initial program 99.7%
Simplified99.7%
Taylor expanded in s around inf
+-commutativeN/A
associate-+r+N/A
distribute-lft1-inN/A
metadata-evalN/A
mul0-lftN/A
+-lft-identityN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3283.0%
Simplified83.0%
times-fracN/A
associate-*r/N/A
div-invN/A
*-lowering-*.f32N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
/-lowering-/.f3279.3%
Applied egg-rr79.3%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3271.0%
Simplified71.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(x / Float32(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}{\frac{s \cdot s}{x}} + 4}
\end{array}
Initial program 99.3%
Simplified99.4%
Taylor expanded in s around inf
+-commutativeN/A
associate-+r+N/A
distribute-lft1-inN/A
metadata-evalN/A
mul0-lftN/A
+-lft-identityN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3279.6%
Simplified79.6%
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
+-lowering-+.f32N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f3283.4%
Applied egg-rr83.4%
(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(1.0) / Float32(s * Float32(Float32(x / Float32(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{1}{s \cdot \left(\frac{x}{\frac{s \cdot s}{x}} + 4\right)}
\end{array}
Initial program 99.3%
Simplified99.4%
Taylor expanded in s around inf
+-commutativeN/A
associate-+r+N/A
distribute-lft1-inN/A
metadata-evalN/A
mul0-lftN/A
+-lft-identityN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3279.6%
Simplified79.6%
associate-/l/N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
+-lowering-+.f32N/A
associate-/l*N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f3283.3%
Applied egg-rr83.3%
(FPCore (x s) :precision binary32 (if (<= x 4.999999873689376e-6) (/ 0.25 s) (/ 1.0 (/ x (/ s x)))))
float code(float x, float s) {
float tmp;
if (x <= 4.999999873689376e-6f) {
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.999999873689376e-6) 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.999999873689376e-6)) 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.999999873689376e-6)) 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.999999873689376 \cdot 10^{-6}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x}{\frac{s}{x}}}\\
\end{array}
\end{array}
if x < 4.99999987e-6Initial program 99.0%
Taylor expanded in s around inf
/-lowering-/.f3235.4%
Simplified35.4%
if 4.99999987e-6 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in s around inf
+-commutativeN/A
associate-+r+N/A
distribute-lft1-inN/A
metadata-evalN/A
mul0-lftN/A
+-lft-identityN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3285.3%
Simplified85.3%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3266.4%
Simplified66.4%
clear-numN/A
associate-*l/N/A
/-lowering-/.f32N/A
*-commutativeN/A
clear-numN/A
un-div-invN/A
/-lowering-/.f32N/A
/-lowering-/.f3267.0%
Applied egg-rr67.0%
(FPCore (x s) :precision binary32 (if (<= x 4.999999873689376e-6) (/ 0.25 s) (/ s (* x x))))
float code(float x, float s) {
float tmp;
if (x <= 4.999999873689376e-6f) {
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.999999873689376e-6) 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.999999873689376e-6)) 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.999999873689376e-6)) 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.999999873689376 \cdot 10^{-6}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{s}{x \cdot x}\\
\end{array}
\end{array}
if x < 4.99999987e-6Initial program 99.0%
Taylor expanded in s around inf
/-lowering-/.f3235.4%
Simplified35.4%
if 4.99999987e-6 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in s around inf
+-commutativeN/A
associate-+r+N/A
distribute-lft1-inN/A
metadata-evalN/A
mul0-lftN/A
+-lft-identityN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3285.3%
Simplified85.3%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3266.4%
Simplified66.4%
(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%
Taylor expanded in s around inf
/-lowering-/.f3226.4%
Simplified26.4%
herbie shell --seed 2024158
(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))))))