
(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 (/ 1.0 (* s (+ 2.0 (* 2.0 (cosh (/ -1.0 (/ s (fabs x)))))))))
float code(float x, float s) {
return 1.0f / (s * (2.0f + (2.0f * coshf((-1.0f / (s / fabsf(x)))))));
}
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(((-1.0e0) / (s / abs(x)))))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * cosh(Float32(Float32(-1.0) / Float32(s / abs(x)))))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * cosh((single(-1.0) / (s / abs(x))))))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(2 + 2 \cdot \cosh \left(\frac{-1}{\frac{s}{\left|x\right|}}\right)\right)}
\end{array}
Initial program 99.5%
Simplified99.5%
associate-/l/N/A
/-lowering-/.f32N/A
*-commutativeN/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.5%
Applied egg-rr99.5%
frac-2negN/A
distribute-frac-negN/A
cosh-negN/A
cosh-lowering-cosh.f32N/A
distribute-frac-neg2N/A
clear-numN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3299.5%
Applied egg-rr99.5%
(FPCore (x s)
:precision binary32
(if (<= (fabs x) 2.0000000063421537e-29)
(/ 1.0 (* s (+ 4.0 (* (/ x s) (/ x s)))))
(if (<= (fabs x) 5.999999941330714e-10)
(/ 1.0 (* s (+ 4.0 (* x (/ x (* s s))))))
(exp (/ (fabs x) (- s))))))
float code(float x, float s) {
float tmp;
if (fabsf(x) <= 2.0000000063421537e-29f) {
tmp = 1.0f / (s * (4.0f + ((x / s) * (x / s))));
} else if (fabsf(x) <= 5.999999941330714e-10f) {
tmp = 1.0f / (s * (4.0f + (x * (x / (s * s)))));
} else {
tmp = expf((fabsf(x) / -s));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (abs(x) <= 2.0000000063421537e-29) then
tmp = 1.0e0 / (s * (4.0e0 + ((x / s) * (x / s))))
else if (abs(x) <= 5.999999941330714e-10) then
tmp = 1.0e0 / (s * (4.0e0 + (x * (x / (s * s)))))
else
tmp = exp((abs(x) / -s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (abs(x) <= Float32(2.0000000063421537e-29)) tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(Float32(x / s) * Float32(x / s))))); elseif (abs(x) <= Float32(5.999999941330714e-10)) tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(x * Float32(x / Float32(s * s)))))); else tmp = exp(Float32(abs(x) / Float32(-s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (abs(x) <= single(2.0000000063421537e-29)) tmp = single(1.0) / (s * (single(4.0) + ((x / s) * (x / s)))); elseif (abs(x) <= single(5.999999941330714e-10)) tmp = single(1.0) / (s * (single(4.0) + (x * (x / (s * s))))); else tmp = exp((abs(x) / -s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 2.0000000063421537 \cdot 10^{-29}:\\
\;\;\;\;\frac{1}{s \cdot \left(4 + \frac{x}{s} \cdot \frac{x}{s}\right)}\\
\mathbf{elif}\;\left|x\right| \leq 5.999999941330714 \cdot 10^{-10}:\\
\;\;\;\;\frac{1}{s \cdot \left(4 + x \cdot \frac{x}{s \cdot s}\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{\left|x\right|}{-s}}\\
\end{array}
\end{array}
if (fabs.f32 x) < 2.00000001e-29Initial program 97.2%
Simplified97.4%
associate-/l/N/A
/-lowering-/.f32N/A
*-commutativeN/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.f3297.5%
Applied egg-rr97.5%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-commutativeN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3253.7%
Simplified53.7%
times-fracN/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
/-lowering-/.f3286.7%
Applied egg-rr86.7%
if 2.00000001e-29 < (fabs.f32 x) < 5.99999994e-10Initial program 99.9%
Simplified99.9%
associate-/l/N/A
/-lowering-/.f32N/A
*-commutativeN/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.9%
Applied egg-rr99.9%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-commutativeN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3284.2%
Simplified84.2%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f3290.6%
Applied egg-rr90.6%
if 5.99999994e-10 < (fabs.f32 x) Initial program 99.9%
Taylor expanded in s around inf
*-commutativeN/A
*-lowering-*.f3298.0%
Simplified98.0%
associate-/r*N/A
clear-numN/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
neg-lowering-neg.f3298.0%
Applied egg-rr98.0%
clear-numN/A
associate-/l/N/A
metadata-evalN/A
associate-/r/N/A
clear-numN/A
rem-exp-logN/A
div-expN/A
exp-lowering-exp.f32N/A
--lowering--.f32N/A
distribute-frac-neg2N/A
clear-numN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
rem-exp-logN/A
log-lowering-log.f32N/A
rem-exp-logN/A
/-lowering-/.f3298.0%
Applied egg-rr98.0%
Taylor expanded in s around 0
mul-1-negN/A
neg-sub0N/A
--lowering--.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3297.3%
Simplified97.3%
Final simplification93.9%
(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.5%
Simplified99.5%
associate-/l/N/A
/-lowering-/.f32N/A
*-commutativeN/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.5%
Applied egg-rr99.5%
(FPCore (x s) :precision binary32 (/ (/ 1.0 (+ 3.0 (exp (/ (fabs x) s)))) s))
float code(float x, float s) {
return (1.0f / (3.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 / (3.0e0 + exp((abs(x) / s)))) / s
end function
function code(x, s) return Float32(Float32(Float32(1.0) / Float32(Float32(3.0) + exp(Float32(abs(x) / s)))) / s) end
function tmp = code(x, s) tmp = (single(1.0) / (single(3.0) + exp((abs(x) / s)))) / s; end
\begin{array}{l}
\\
\frac{\frac{1}{3 + e^{\frac{\left|x\right|}{s}}}}{s}
\end{array}
Initial program 99.5%
Simplified99.5%
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f32N/A
Applied egg-rr99.5%
+-commutativeN/A
cosh-undefN/A
distribute-frac-negN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+r+N/A
+-lowering-+.f32N/A
+-lowering-+.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
neg-lowering-neg.f32N/A
exp-lowering-exp.f32N/A
Applied egg-rr99.5%
Taylor expanded in s around inf
Simplified96.0%
(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.5%
Taylor expanded in s around inf
*-commutativeN/A
*-lowering-*.f3294.9%
Simplified94.9%
Final simplification94.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.5%
Taylor expanded in s around inf
*-commutativeN/A
*-lowering-*.f3294.9%
Simplified94.9%
div-invN/A
distribute-frac-negN/A
exp-negN/A
associate-*l/N/A
div-invN/A
/-lowering-/.f32N/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
/-lowering-/.f32N/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f3294.9%
Applied egg-rr94.9%
(FPCore (x s) :precision binary32 (if (<= (fabs x) 2.0000000390829628e-25) (/ 1.0 (* s (+ 4.0 (* (/ x s) (/ x s))))) (/ 1.0 (* s (+ 4.0 (* (/ 1.0 (* s s)) (* x x)))))))
float code(float x, float s) {
float tmp;
if (fabsf(x) <= 2.0000000390829628e-25f) {
tmp = 1.0f / (s * (4.0f + ((x / s) * (x / s))));
} else {
tmp = 1.0f / (s * (4.0f + ((1.0f / (s * 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 (abs(x) <= 2.0000000390829628e-25) then
tmp = 1.0e0 / (s * (4.0e0 + ((x / s) * (x / s))))
else
tmp = 1.0e0 / (s * (4.0e0 + ((1.0e0 / (s * s)) * (x * x))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (abs(x) <= Float32(2.0000000390829628e-25)) tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(Float32(x / s) * Float32(x / s))))); else tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(Float32(Float32(1.0) / Float32(s * s)) * Float32(x * x))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (abs(x) <= single(2.0000000390829628e-25)) tmp = single(1.0) / (s * (single(4.0) + ((x / s) * (x / s)))); else tmp = single(1.0) / (s * (single(4.0) + ((single(1.0) / (s * s)) * (x * x)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 2.0000000390829628 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{s \cdot \left(4 + \frac{x}{s} \cdot \frac{x}{s}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(4 + \frac{1}{s \cdot s} \cdot \left(x \cdot x\right)\right)}\\
\end{array}
\end{array}
if (fabs.f32 x) < 2.00000004e-25Initial program 97.7%
Simplified97.8%
associate-/l/N/A
/-lowering-/.f32N/A
*-commutativeN/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.f3297.9%
Applied egg-rr97.9%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-commutativeN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3252.0%
Simplified52.0%
times-fracN/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
/-lowering-/.f3280.0%
Applied egg-rr80.0%
if 2.00000004e-25 < (fabs.f32 x) Initial program 99.9%
Simplified99.9%
associate-/l/N/A
/-lowering-/.f32N/A
*-commutativeN/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.9%
Applied egg-rr99.9%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-commutativeN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3283.6%
Simplified83.6%
clear-numN/A
associate-/r/N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
*-lowering-*.f3286.8%
Applied egg-rr86.8%
Final simplification85.5%
(FPCore (x s) :precision binary32 (if (<= x 2.0000000063421537e-29) (/ 1.0 (* s (+ 4.0 (* (/ x s) (/ x s))))) (/ 1.0 (* s (+ 4.0 (* x (/ x (* s s))))))))
float code(float x, float s) {
float tmp;
if (x <= 2.0000000063421537e-29f) {
tmp = 1.0f / (s * (4.0f + ((x / s) * (x / s))));
} else {
tmp = 1.0f / (s * (4.0f + (x * (x / (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 <= 2.0000000063421537e-29) then
tmp = 1.0e0 / (s * (4.0e0 + ((x / s) * (x / s))))
else
tmp = 1.0e0 / (s * (4.0e0 + (x * (x / (s * s)))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(2.0000000063421537e-29)) tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(Float32(x / s) * Float32(x / s))))); else tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(x * Float32(x / Float32(s * s)))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(2.0000000063421537e-29)) tmp = single(1.0) / (s * (single(4.0) + ((x / s) * (x / s)))); else tmp = single(1.0) / (s * (single(4.0) + (x * (x / (s * s))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.0000000063421537 \cdot 10^{-29}:\\
\;\;\;\;\frac{1}{s \cdot \left(4 + \frac{x}{s} \cdot \frac{x}{s}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(4 + x \cdot \frac{x}{s \cdot s}\right)}\\
\end{array}
\end{array}
if x < 2.00000001e-29Initial program 99.1%
Simplified99.2%
associate-/l/N/A
/-lowering-/.f32N/A
*-commutativeN/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.2%
Applied egg-rr99.2%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-commutativeN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3273.8%
Simplified73.8%
times-fracN/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
/-lowering-/.f3277.6%
Applied egg-rr77.6%
if 2.00000001e-29 < x Initial program 99.9%
Simplified99.9%
associate-/l/N/A
/-lowering-/.f32N/A
*-commutativeN/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.9%
Applied egg-rr99.9%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-commutativeN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3282.2%
Simplified82.2%
associate-/l*N/A
*-commutativeN/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f3283.1%
Applied egg-rr83.1%
Final simplification80.0%
(FPCore (x s) :precision binary32 (if (<= x 1.9000000043279782e-19) (/ 1.0 (- (/ (* x x) s) (/ s -0.25))) (/ (/ 1.0 (/ (* x x) (* s s))) s)))
float code(float x, float s) {
float tmp;
if (x <= 1.9000000043279782e-19f) {
tmp = 1.0f / (((x * x) / s) - (s / -0.25f));
} 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.9000000043279782e-19) then
tmp = 1.0e0 / (((x * x) / s) - (s / (-0.25e0)))
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.9000000043279782e-19)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(x * x) / s) - Float32(s / Float32(-0.25)))); 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.9000000043279782e-19)) tmp = single(1.0) / (((x * x) / s) - (s / single(-0.25))); 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.9000000043279782 \cdot 10^{-19}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x}{s} - \frac{s}{-0.25}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\frac{x \cdot x}{s \cdot s}}}{s}\\
\end{array}
\end{array}
if x < 1.9e-19Initial program 99.1%
Simplified99.2%
associate-/l/N/A
/-lowering-/.f32N/A
*-commutativeN/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.3%
Applied egg-rr99.3%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-commutativeN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3274.7%
Simplified74.7%
distribute-lft-inN/A
metadata-evalN/A
div-invN/A
fma-defineN/A
frac-2negN/A
distribute-frac-negN/A
fmm-undefN/A
*-commutativeN/A
div-invN/A
associate-*l*N/A
pow2N/A
pow-flipN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
inv-powN/A
div-invN/A
--lowering--.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
metadata-eval67.8%
Applied egg-rr67.8%
if 1.9e-19 < x Initial program 99.9%
Simplified99.9%
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f32N/A
Applied egg-rr99.9%
+-commutativeN/A
cosh-undefN/A
distribute-frac-negN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+r+N/A
+-lowering-+.f32N/A
+-lowering-+.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
neg-lowering-neg.f32N/A
exp-lowering-exp.f32N/A
Applied egg-rr99.9%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
Simplified72.5%
Taylor expanded in x around inf
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3274.7%
Simplified74.7%
(FPCore (x s) :precision binary32 (if (<= x 9.99999993922529e-9) (/ 1.0 (- (/ (* x x) s) (/ s -0.25))) (/ (* s (/ s (* x x))) s)))
float code(float x, float s) {
float tmp;
if (x <= 9.99999993922529e-9f) {
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 <= 9.99999993922529e-9) 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(9.99999993922529e-9)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(x * 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(9.99999993922529e-9)) 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 9.99999993922529 \cdot 10^{-9}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x}{s} - \frac{s}{-0.25}}\\
\mathbf{else}:\\
\;\;\;\;\frac{s \cdot \frac{s}{x \cdot x}}{s}\\
\end{array}
\end{array}
if x < 9.99999994e-9Initial program 99.2%
Simplified99.3%
associate-/l/N/A
/-lowering-/.f32N/A
*-commutativeN/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.3%
Applied egg-rr99.3%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-commutativeN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3274.8%
Simplified74.8%
distribute-lft-inN/A
metadata-evalN/A
div-invN/A
fma-defineN/A
frac-2negN/A
distribute-frac-negN/A
fmm-undefN/A
*-commutativeN/A
div-invN/A
associate-*l*N/A
pow2N/A
pow-flipN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
inv-powN/A
div-invN/A
--lowering--.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
metadata-eval62.7%
Applied egg-rr62.7%
if 9.99999994e-9 < x Initial program 100.0%
Simplified99.9%
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f32N/A
Applied egg-rr100.0%
+-commutativeN/A
cosh-undefN/A
distribute-frac-negN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+r+N/A
+-lowering-+.f32N/A
+-lowering-+.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
neg-lowering-neg.f32N/A
exp-lowering-exp.f32N/A
Applied egg-rr100.0%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
Simplified83.5%
Taylor expanded in x around inf
unpow2N/A
associate-/l*N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3273.4%
Simplified73.4%
(FPCore (x s) :precision binary32 (if (<= x 9.99999993922529e-9) (/ 0.25 s) (/ (* s (/ s (* x x))) s)))
float code(float x, float s) {
float tmp;
if (x <= 9.99999993922529e-9f) {
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 <= 9.99999993922529e-9) 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(9.99999993922529e-9)) 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(9.99999993922529e-9)) 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 9.99999993922529 \cdot 10^{-9}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{s \cdot \frac{s}{x \cdot x}}{s}\\
\end{array}
\end{array}
if x < 9.99999994e-9Initial program 99.2%
Taylor expanded in s around inf
/-lowering-/.f3237.1%
Simplified37.1%
if 9.99999994e-9 < x Initial program 100.0%
Simplified99.9%
associate-/l/N/A
associate-/r*N/A
/-lowering-/.f32N/A
Applied egg-rr100.0%
+-commutativeN/A
cosh-undefN/A
distribute-frac-negN/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
associate-+r+N/A
+-lowering-+.f32N/A
+-lowering-+.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
neg-lowering-neg.f32N/A
exp-lowering-exp.f32N/A
Applied egg-rr100.0%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
Simplified83.5%
Taylor expanded in x around inf
unpow2N/A
associate-/l*N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3273.4%
Simplified73.4%
(FPCore (x s) :precision binary32 (if (<= x 9.99999993922529e-9) (/ 0.25 s) (/ 1.0 (* 2.0 (/ (* x x) s)))))
float code(float x, float s) {
float tmp;
if (x <= 9.99999993922529e-9f) {
tmp = 0.25f / s;
} else {
tmp = 1.0f / (2.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 <= 9.99999993922529e-9) then
tmp = 0.25e0 / s
else
tmp = 1.0e0 / (2.0e0 * ((x * x) / s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(9.99999993922529e-9)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(1.0) / Float32(Float32(2.0) * Float32(Float32(x * x) / s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(9.99999993922529e-9)) tmp = single(0.25) / s; else tmp = single(1.0) / (single(2.0) * ((x * x) / s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 9.99999993922529 \cdot 10^{-9}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 \cdot \frac{x \cdot x}{s}}\\
\end{array}
\end{array}
if x < 9.99999994e-9Initial program 99.2%
Taylor expanded in s around inf
/-lowering-/.f3237.1%
Simplified37.1%
if 9.99999994e-9 < x Initial program 100.0%
Taylor expanded in s around inf
*-commutativeN/A
*-lowering-*.f3298.3%
Simplified98.3%
associate-/r*N/A
clear-numN/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
distribute-frac-negN/A
distribute-frac-neg2N/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
fabs-lowering-fabs.f32N/A
neg-lowering-neg.f3298.3%
Applied egg-rr98.3%
Taylor expanded in s around inf
Simplified82.9%
Taylor expanded in s around 0
*-lowering-*.f32N/A
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3258.1%
Simplified58.1%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ 4.0 (* (/ x s) (/ x s))))))
float code(float x, float s) {
return 1.0f / (s * (4.0f + ((x / s) * (x / s))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (s * (4.0e0 + ((x / s) * (x / s))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(Float32(x / s) * Float32(x / s))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (single(4.0) + ((x / s) * (x / s)))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(4 + \frac{x}{s} \cdot \frac{x}{s}\right)}
\end{array}
Initial program 99.5%
Simplified99.5%
associate-/l/N/A
/-lowering-/.f32N/A
*-commutativeN/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.5%
Applied egg-rr99.5%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-commutativeN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3277.5%
Simplified77.5%
times-fracN/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
/-lowering-/.f3274.8%
Applied egg-rr74.8%
Final simplification74.8%
(FPCore (x s) :precision binary32 (if (<= x 9.99999993922529e-9) (/ 0.25 s) (/ 1.0 (/ (* x x) s))))
float code(float x, float s) {
float tmp;
if (x <= 9.99999993922529e-9f) {
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 <= 9.99999993922529e-9) 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(9.99999993922529e-9)) 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(9.99999993922529e-9)) 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 9.99999993922529 \cdot 10^{-9}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x}{s}}\\
\end{array}
\end{array}
if x < 9.99999994e-9Initial program 99.2%
Taylor expanded in s around inf
/-lowering-/.f3237.1%
Simplified37.1%
if 9.99999994e-9 < x Initial program 100.0%
Simplified99.9%
associate-/l/N/A
/-lowering-/.f32N/A
*-commutativeN/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.f32100.0%
Applied egg-rr100.0%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-commutativeN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3283.5%
Simplified83.5%
Taylor expanded in s around 0
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3257.9%
Simplified57.9%
(FPCore (x s) :precision binary32 (if (<= x 9.99999993922529e-9) (/ 0.25 s) (/ s (* x x))))
float code(float x, float s) {
float tmp;
if (x <= 9.99999993922529e-9f) {
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 <= 9.99999993922529e-9) 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(9.99999993922529e-9)) 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(9.99999993922529e-9)) 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 9.99999993922529 \cdot 10^{-9}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{s}{x \cdot x}\\
\end{array}
\end{array}
if x < 9.99999994e-9Initial program 99.2%
Taylor expanded in s around inf
/-lowering-/.f3237.1%
Simplified37.1%
if 9.99999994e-9 < x Initial program 100.0%
Simplified99.9%
associate-/l/N/A
/-lowering-/.f32N/A
*-commutativeN/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.f32100.0%
Applied egg-rr100.0%
Taylor expanded in s around inf
*-lowering-*.f32N/A
+-commutativeN/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
unpow2N/A
sqr-absN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3283.5%
Simplified83.5%
Taylor expanded in s around 0
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3254.2%
Simplified54.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.5%
Taylor expanded in s around inf
/-lowering-/.f3227.6%
Simplified27.6%
herbie shell --seed 2024148
(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))))))