
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
float code(float x, float s) {
return 1.0f / (1.0f + expf((-x / s)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (1.0e0 + exp((-x / s)))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-x) / s)))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + exp((-x / s))); end
\begin{array}{l}
\\
\frac{1}{1 + e^{\frac{-x}{s}}}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (/ (- x) s)))))
float code(float x, float s) {
return 1.0f / (1.0f + expf((-x / s)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (1.0e0 + exp((-x / s)))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(-x) / s)))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + exp((-x / s))); end
\begin{array}{l}
\\
\frac{1}{1 + e^{\frac{-x}{s}}}
\end{array}
(FPCore (x s) :precision binary32 (exp (- (log1p (exp (- 0.0 (/ x s)))))))
float code(float x, float s) {
return expf(-log1pf(expf((0.0f - (x / s)))));
}
function code(x, s) return exp(Float32(-log1p(exp(Float32(Float32(0.0) - Float32(x / s)))))) end
\begin{array}{l}
\\
e^{-\mathsf{log1p}\left(e^{0 - \frac{x}{s}}\right)}
\end{array}
Initial program 99.7%
inv-powN/A
pow-to-expN/A
*-commutativeN/A
log-powN/A
inv-powN/A
exp-lowering-exp.f32N/A
log-recN/A
neg-lowering-neg.f32N/A
log1p-defineN/A
log1p-lowering-log1p.f32N/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3299.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (pow (exp -1.0) (/ x s)))))
float code(float x, float s) {
return 1.0f / (1.0f + powf(expf(-1.0f), (x / s)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (1.0e0 + (exp((-1.0e0)) ** (x / s)))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + (exp(Float32(-1.0)) ^ Float32(x / s)))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + (exp(single(-1.0)) ^ (x / s))); end
\begin{array}{l}
\\
\frac{1}{1 + {\left(e^{-1}\right)}^{\left(\frac{x}{s}\right)}}
\end{array}
Initial program 99.7%
distribute-frac-negN/A
neg-mul-1N/A
exp-prodN/A
pow-lowering-pow.f32N/A
exp-lowering-exp.f32N/A
/-lowering-/.f3299.7%
Applied egg-rr99.7%
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (pow E (- 0.0 (/ x s))))))
float code(float x, float s) {
return 1.0f / (1.0f + powf(((float) M_E), (0.0f - (x / s))));
}
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + (Float32(exp(1)) ^ Float32(Float32(0.0) - Float32(x / s))))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + (single(2.71828182845904523536) ^ (single(0.0) - (x / s)))); end
\begin{array}{l}
\\
\frac{1}{1 + {e}^{\left(0 - \frac{x}{s}\right)}}
\end{array}
Initial program 99.7%
*-lft-identityN/A
exp-prodN/A
pow-lowering-pow.f32N/A
exp-1-eN/A
E-lowering-E.f32N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3299.7%
Applied egg-rr99.7%
Final simplification99.7%
(FPCore (x s) :precision binary32 (/ 1.0 (+ (exp (- 0.0 (/ x s))) 1.0)))
float code(float x, float s) {
return 1.0f / (expf((0.0f - (x / s))) + 1.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (exp((0.0e0 - (x / s))) + 1.0e0)
end function
function code(x, s) return Float32(Float32(1.0) / Float32(exp(Float32(Float32(0.0) - Float32(x / s))) + Float32(1.0))) end
function tmp = code(x, s) tmp = single(1.0) / (exp((single(0.0) - (x / s))) + single(1.0)); end
\begin{array}{l}
\\
\frac{1}{e^{0 - \frac{x}{s}} + 1}
\end{array}
Initial program 99.7%
Final simplification99.7%
(FPCore (x s)
:precision binary32
(if (<= (- 0.0 (/ x s)) -20.0)
0.5
(/
1.0
(+
2.0
(/
(/ 1.0 s)
(/
1.0
(*
x
(+ -1.0 (* x (/ (+ 0.5 (/ x (/ s -0.16666666666666666))) s))))))))))
float code(float x, float s) {
float tmp;
if ((0.0f - (x / s)) <= -20.0f) {
tmp = 0.5f;
} else {
tmp = 1.0f / (2.0f + ((1.0f / s) / (1.0f / (x * (-1.0f + (x * ((0.5f + (x / (s / -0.16666666666666666f))) / s)))))));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((0.0e0 - (x / s)) <= (-20.0e0)) then
tmp = 0.5e0
else
tmp = 1.0e0 / (2.0e0 + ((1.0e0 / s) / (1.0e0 / (x * ((-1.0e0) + (x * ((0.5e0 + (x / (s / (-0.16666666666666666e0)))) / s)))))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(0.0) - Float32(x / s)) <= Float32(-20.0)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(Float32(Float32(1.0) / s) / Float32(Float32(1.0) / Float32(x * Float32(Float32(-1.0) + Float32(x * Float32(Float32(Float32(0.5) + Float32(x / Float32(s / Float32(-0.16666666666666666)))) / s)))))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((single(0.0) - (x / s)) <= single(-20.0)) tmp = single(0.5); else tmp = single(1.0) / (single(2.0) + ((single(1.0) / s) / (single(1.0) / (x * (single(-1.0) + (x * ((single(0.5) + (x / (s / single(-0.16666666666666666)))) / s))))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0 - \frac{x}{s} \leq -20:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + \frac{\frac{1}{s}}{\frac{1}{x \cdot \left(-1 + x \cdot \frac{0.5 + \frac{x}{\frac{s}{-0.16666666666666666}}}{s}\right)}}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -20Initial program 100.0%
Taylor expanded in x around 0
Simplified28.1%
if -20 < (/.f32 (neg.f32 x) s) Initial program 99.6%
Taylor expanded in s around -inf
+-lowering-+.f32N/A
associate-*r/N/A
/-lowering-/.f32N/A
Simplified83.8%
clear-numN/A
associate-/r/N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f32N/A
+-commutativeN/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f32N/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f3284.7%
Applied egg-rr84.7%
clear-numN/A
div-invN/A
associate-/r*N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
sub-negN/A
*-commutativeN/A
associate-*r*N/A
neg-mul-1N/A
distribute-rgt-outN/A
associate-*r*N/A
Applied egg-rr87.9%
Final simplification68.3%
(FPCore (x s)
:precision binary32
(if (<= (- 0.0 (/ x s)) -20.0)
0.5
(/
1.0
(-
(/ (* x (+ 0.5 (/ x (/ s -0.16666666666666666)))) (/ s (/ x s)))
(+ (/ x s) -2.0)))))
float code(float x, float s) {
float tmp;
if ((0.0f - (x / s)) <= -20.0f) {
tmp = 0.5f;
} else {
tmp = 1.0f / (((x * (0.5f + (x / (s / -0.16666666666666666f)))) / (s / (x / s))) - ((x / s) + -2.0f));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((0.0e0 - (x / s)) <= (-20.0e0)) then
tmp = 0.5e0
else
tmp = 1.0e0 / (((x * (0.5e0 + (x / (s / (-0.16666666666666666e0))))) / (s / (x / s))) - ((x / s) + (-2.0e0)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(0.0) - Float32(x / s)) <= Float32(-20.0)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(Float32(Float32(x * Float32(Float32(0.5) + Float32(x / Float32(s / Float32(-0.16666666666666666))))) / Float32(s / Float32(x / s))) - Float32(Float32(x / s) + Float32(-2.0)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((single(0.0) - (x / s)) <= single(-20.0)) tmp = single(0.5); else tmp = single(1.0) / (((x * (single(0.5) + (x / (s / single(-0.16666666666666666))))) / (s / (x / s))) - ((x / s) + single(-2.0))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0 - \frac{x}{s} \leq -20:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x \cdot \left(0.5 + \frac{x}{\frac{s}{-0.16666666666666666}}\right)}{\frac{s}{\frac{x}{s}}} - \left(\frac{x}{s} + -2\right)}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -20Initial program 100.0%
Taylor expanded in x around 0
Simplified28.1%
if -20 < (/.f32 (neg.f32 x) s) Initial program 99.6%
Taylor expanded in s around -inf
+-lowering-+.f32N/A
associate-*r/N/A
/-lowering-/.f32N/A
Simplified83.8%
clear-numN/A
associate-/r/N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f32N/A
+-commutativeN/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f32N/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f3284.7%
Applied egg-rr84.7%
+-commutativeN/A
div-subN/A
associate-+l-N/A
sub-negN/A
remove-double-negN/A
distribute-neg-inN/A
+-commutativeN/A
sub-negN/A
--lowering--.f32N/A
Applied egg-rr86.3%
Final simplification67.2%
(FPCore (x s)
:precision binary32
(if (<= (- 0.0 (/ x s)) -20.0)
0.5
(/
1.0
(+
2.0
(/ (- (/ (* x (+ 0.5 (/ x (/ s -0.16666666666666666)))) (/ s x)) x) s)))))
float code(float x, float s) {
float tmp;
if ((0.0f - (x / s)) <= -20.0f) {
tmp = 0.5f;
} else {
tmp = 1.0f / (2.0f + ((((x * (0.5f + (x / (s / -0.16666666666666666f)))) / (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 ((0.0e0 - (x / s)) <= (-20.0e0)) then
tmp = 0.5e0
else
tmp = 1.0e0 / (2.0e0 + ((((x * (0.5e0 + (x / (s / (-0.16666666666666666e0))))) / (s / x)) - x) / s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(0.0) - Float32(x / s)) <= Float32(-20.0)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(Float32(Float32(Float32(x * Float32(Float32(0.5) + Float32(x / Float32(s / Float32(-0.16666666666666666))))) / Float32(s / x)) - x) / s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((single(0.0) - (x / s)) <= single(-20.0)) tmp = single(0.5); else tmp = single(1.0) / (single(2.0) + ((((x * (single(0.5) + (x / (s / single(-0.16666666666666666))))) / (s / x)) - x) / s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0 - \frac{x}{s} \leq -20:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + \frac{\frac{x \cdot \left(0.5 + \frac{x}{\frac{s}{-0.16666666666666666}}\right)}{\frac{s}{x}} - x}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -20Initial program 100.0%
Taylor expanded in x around 0
Simplified28.1%
if -20 < (/.f32 (neg.f32 x) s) Initial program 99.6%
Taylor expanded in s around -inf
+-lowering-+.f32N/A
associate-*r/N/A
/-lowering-/.f32N/A
Simplified83.8%
clear-numN/A
associate-/r/N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f32N/A
+-commutativeN/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f32N/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f3284.7%
Applied egg-rr84.7%
--lowering--.f32N/A
*-commutativeN/A
*-commutativeN/A
associate-*l*N/A
div-invN/A
clear-numN/A
un-div-invN/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-/.f3285.9%
Applied egg-rr85.9%
Final simplification66.9%
(FPCore (x s)
:precision binary32
(if (<= (- 0.0 (/ x s)) -20.0)
0.5
(/
1.0
(+
2.0
(/ (- (* x (/ (* x (+ 0.5 (/ (* x -0.16666666666666666) s))) s)) x) s)))))
float code(float x, float s) {
float tmp;
if ((0.0f - (x / s)) <= -20.0f) {
tmp = 0.5f;
} else {
tmp = 1.0f / (2.0f + (((x * ((x * (0.5f + ((x * -0.16666666666666666f) / s))) / s)) - x) / s));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((0.0e0 - (x / s)) <= (-20.0e0)) then
tmp = 0.5e0
else
tmp = 1.0e0 / (2.0e0 + (((x * ((x * (0.5e0 + ((x * (-0.16666666666666666e0)) / s))) / s)) - x) / s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(0.0) - Float32(x / s)) <= Float32(-20.0)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(Float32(Float32(x * Float32(Float32(x * Float32(Float32(0.5) + Float32(Float32(x * Float32(-0.16666666666666666)) / s))) / s)) - x) / s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((single(0.0) - (x / s)) <= single(-20.0)) tmp = single(0.5); else tmp = single(1.0) / (single(2.0) + (((x * ((x * (single(0.5) + ((x * single(-0.16666666666666666)) / s))) / s)) - x) / s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0 - \frac{x}{s} \leq -20:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + \frac{x \cdot \frac{x \cdot \left(0.5 + \frac{x \cdot -0.16666666666666666}{s}\right)}{s} - x}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -20Initial program 100.0%
Taylor expanded in x around 0
Simplified28.1%
if -20 < (/.f32 (neg.f32 x) s) Initial program 99.6%
Taylor expanded in s around -inf
+-lowering-+.f32N/A
associate-*r/N/A
/-lowering-/.f32N/A
Simplified83.8%
associate-/l*N/A
distribute-lft-outN/A
associate-/l*N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
+-commutativeN/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f32N/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f3285.9%
Applied egg-rr85.9%
Final simplification66.9%
(FPCore (x s) :precision binary32 (if (<= (- 0.0 (/ x s)) -20.0) 0.5 (/ 1.0 (+ 2.0 (* x (+ (/ -1.0 s) (/ (/ (/ x 2.0) s) s)))))))
float code(float x, float s) {
float tmp;
if ((0.0f - (x / s)) <= -20.0f) {
tmp = 0.5f;
} else {
tmp = 1.0f / (2.0f + (x * ((-1.0f / s) + (((x / 2.0f) / s) / s))));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((0.0e0 - (x / s)) <= (-20.0e0)) then
tmp = 0.5e0
else
tmp = 1.0e0 / (2.0e0 + (x * (((-1.0e0) / s) + (((x / 2.0e0) / s) / s))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(0.0) - Float32(x / s)) <= Float32(-20.0)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(x * Float32(Float32(Float32(-1.0) / s) + Float32(Float32(Float32(x / Float32(2.0)) / s) / s))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((single(0.0) - (x / s)) <= single(-20.0)) tmp = single(0.5); else tmp = single(1.0) / (single(2.0) + (x * ((single(-1.0) / s) + (((x / single(2.0)) / s) / s)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0 - \frac{x}{s} \leq -20:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + x \cdot \left(\frac{-1}{s} + \frac{\frac{\frac{x}{2}}{s}}{s}\right)}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -20Initial program 100.0%
Taylor expanded in x around 0
Simplified28.1%
if -20 < (/.f32 (neg.f32 x) s) Initial program 99.6%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f32N/A
Simplified83.9%
Taylor expanded in x around 0
+-lowering-+.f32N/A
*-lowering-*.f32N/A
sub-negN/A
associate-*r/N/A
*-commutativeN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
+-commutativeN/A
+-lowering-+.f32N/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f32N/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
*-commutativeN/A
unpow2N/A
associate-/r*N/A
Simplified83.9%
Final simplification65.6%
(FPCore (x s) :precision binary32 (if (<= (- 0.0 (/ x s)) 5000000.0) 0.5 (/ 1.0 (/ (* -0.16666666666666666 (* x (/ (* x x) s))) (* s s)))))
float code(float x, float s) {
float tmp;
if ((0.0f - (x / s)) <= 5000000.0f) {
tmp = 0.5f;
} else {
tmp = 1.0f / ((-0.16666666666666666f * (x * ((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 ((0.0e0 - (x / s)) <= 5000000.0e0) then
tmp = 0.5e0
else
tmp = 1.0e0 / (((-0.16666666666666666e0) * (x * ((x * x) / s))) / (s * s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(0.0) - Float32(x / s)) <= Float32(5000000.0)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(Float32(Float32(-0.16666666666666666) * Float32(x * Float32(Float32(x * x) / s))) / Float32(s * s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((single(0.0) - (x / s)) <= single(5000000.0)) tmp = single(0.5); else tmp = single(1.0) / ((single(-0.16666666666666666) * (x * ((x * x) / s))) / (s * s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0 - \frac{x}{s} \leq 5000000:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{-0.16666666666666666 \cdot \left(x \cdot \frac{x \cdot x}{s}\right)}{s \cdot s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 5e6Initial program 99.6%
Taylor expanded in x around 0
Simplified47.6%
if 5e6 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in s around -inf
+-lowering-+.f32N/A
associate-*r/N/A
/-lowering-/.f32N/A
Simplified89.7%
clear-numN/A
associate-/r/N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f32N/A
+-commutativeN/A
associate-/l*N/A
distribute-lft-outN/A
*-lowering-*.f32N/A
+-lowering-+.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f3290.8%
Applied egg-rr90.8%
Taylor expanded in s around 0
associate-*r/N/A
cube-multN/A
unpow2N/A
associate-/r*N/A
associate-*r/N/A
/-lowering-/.f32N/A
*-commutativeN/A
*-lowering-*.f32N/A
cube-multN/A
unpow2N/A
associate-/l*N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3292.6%
Simplified92.6%
Final simplification63.9%
(FPCore (x s) :precision binary32 (if (<= (- 0.0 (/ x s)) 50.0) 0.5 (/ (* -2.0 (/ (* s s) x)) x)))
float code(float x, float s) {
float tmp;
if ((0.0f - (x / s)) <= 50.0f) {
tmp = 0.5f;
} else {
tmp = (-2.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 ((0.0e0 - (x / s)) <= 50.0e0) then
tmp = 0.5e0
else
tmp = ((-2.0e0) * ((s * s) / x)) / x
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(0.0) - Float32(x / s)) <= Float32(50.0)) tmp = Float32(0.5); else tmp = Float32(Float32(Float32(-2.0) * Float32(Float32(s * s) / x)) / x); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((single(0.0) - (x / s)) <= single(50.0)) tmp = single(0.5); else tmp = (single(-2.0) * ((s * s) / x)) / x; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0 - \frac{x}{s} \leq 50:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{-2 \cdot \frac{s \cdot s}{x}}{x}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 50Initial program 99.6%
Taylor expanded in x around 0
Simplified50.6%
if 50 < (/.f32 (neg.f32 x) s) Initial program 99.9%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f3245.5%
Simplified45.5%
Taylor expanded in x around inf
+-commutativeN/A
metadata-evalN/A
cancel-sign-sub-invN/A
/-lowering-/.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f32N/A
metadata-evalN/A
*-commutativeN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3240.6%
Simplified40.6%
Taylor expanded in s around inf
*-lowering-*.f32N/A
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3281.9%
Simplified81.9%
Final simplification63.3%
(FPCore (x s) :precision binary32 (if (<= (- 0.0 (/ x s)) 5000000.0) 0.5 (/ 2.0 (/ (* x x) (* s s)))))
float code(float x, float s) {
float tmp;
if ((0.0f - (x / s)) <= 5000000.0f) {
tmp = 0.5f;
} else {
tmp = 2.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 ((0.0e0 - (x / s)) <= 5000000.0e0) then
tmp = 0.5e0
else
tmp = 2.0e0 / ((x * x) / (s * s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(0.0) - Float32(x / s)) <= Float32(5000000.0)) tmp = Float32(0.5); else tmp = Float32(Float32(2.0) / Float32(Float32(x * x) / Float32(s * s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((single(0.0) - (x / s)) <= single(5000000.0)) tmp = single(0.5); else tmp = single(2.0) / ((x * x) / (s * s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0 - \frac{x}{s} \leq 5000000:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{2}{\frac{x \cdot x}{s \cdot s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 5e6Initial program 99.6%
Taylor expanded in x around 0
Simplified47.6%
if 5e6 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f32N/A
Simplified89.7%
Taylor expanded in s around inf
sub-negN/A
+-commutativeN/A
mul-1-negN/A
associate-+l+N/A
+-lowering-+.f32N/A
associate-*r/N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f32N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f3286.0%
Simplified86.0%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f32N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f32N/A
metadata-evalN/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3287.1%
Simplified87.1%
div-invN/A
associate-*r/N/A
associate-*l/N/A
div-invN/A
div-invN/A
metadata-evalN/A
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
*-lowering-*.f3287.1%
Applied egg-rr87.1%
Final simplification61.9%
(FPCore (x s) :precision binary32 (if (<= (- 0.0 (/ x s)) 5000000.0) 0.5 (* (* s s) (/ 2.0 (* x x)))))
float code(float x, float s) {
float tmp;
if ((0.0f - (x / s)) <= 5000000.0f) {
tmp = 0.5f;
} else {
tmp = (s * s) * (2.0f / (x * x));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((0.0e0 - (x / s)) <= 5000000.0e0) then
tmp = 0.5e0
else
tmp = (s * s) * (2.0e0 / (x * x))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(0.0) - Float32(x / s)) <= Float32(5000000.0)) tmp = Float32(0.5); else tmp = Float32(Float32(s * s) * Float32(Float32(2.0) / Float32(x * x))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((single(0.0) - (x / s)) <= single(5000000.0)) tmp = single(0.5); else tmp = (s * s) * (single(2.0) / (x * x)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0 - \frac{x}{s} \leq 5000000:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\left(s \cdot s\right) \cdot \frac{2}{x \cdot x}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 5e6Initial program 99.6%
Taylor expanded in x around 0
Simplified47.6%
if 5e6 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in s around -inf
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f32N/A
Simplified89.7%
Taylor expanded in s around inf
sub-negN/A
+-commutativeN/A
mul-1-negN/A
associate-+l+N/A
+-lowering-+.f32N/A
associate-*r/N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f32N/A
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f3286.0%
Simplified86.0%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f32N/A
*-commutativeN/A
unpow2N/A
associate-*l*N/A
*-commutativeN/A
*-lowering-*.f32N/A
metadata-evalN/A
associate-*l/N/A
*-lft-identityN/A
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3287.1%
Simplified87.1%
associate-/r/N/A
associate-*r/N/A
clear-numN/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
*-lowering-*.f3283.6%
Applied egg-rr83.6%
Final simplification60.7%
(FPCore (x s) :precision binary32 (if (<= (- 0.0 (/ x s)) -1.0) 0.5 (/ 1.0 (- 2.0 (/ x s)))))
float code(float x, float s) {
float tmp;
if ((0.0f - (x / s)) <= -1.0f) {
tmp = 0.5f;
} else {
tmp = 1.0f / (2.0f - (x / s));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((0.0e0 - (x / s)) <= (-1.0e0)) then
tmp = 0.5e0
else
tmp = 1.0e0 / (2.0e0 - (x / s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(0.0) - Float32(x / s)) <= Float32(-1.0)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(Float32(2.0) - Float32(x / s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((single(0.0) - (x / s)) <= single(-1.0)) tmp = single(0.5); else tmp = single(1.0) / (single(2.0) - (x / s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0 - \frac{x}{s} \leq -1:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -1Initial program 100.0%
Taylor expanded in x around 0
Simplified28.1%
if -1 < (/.f32 (neg.f32 x) s) Initial program 99.6%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f3261.5%
Simplified61.5%
Final simplification50.4%
(FPCore (x s) :precision binary32 (if (<= (- 0.0 (/ x s)) 0.4000000059604645) 0.5 (/ -1.0 (/ x s))))
float code(float x, float s) {
float tmp;
if ((0.0f - (x / s)) <= 0.4000000059604645f) {
tmp = 0.5f;
} else {
tmp = -1.0f / (x / s);
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if ((0.0e0 - (x / s)) <= 0.4000000059604645e0) then
tmp = 0.5e0
else
tmp = (-1.0e0) / (x / s)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(0.0) - Float32(x / s)) <= Float32(0.4000000059604645)) tmp = Float32(0.5); else tmp = Float32(Float32(-1.0) / Float32(x / s)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((single(0.0) - (x / s)) <= single(0.4000000059604645)) tmp = single(0.5); else tmp = single(-1.0) / (x / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;0 - \frac{x}{s} \leq 0.4000000059604645:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{x}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 0.400000006Initial program 99.7%
Taylor expanded in x around 0
Simplified51.3%
if 0.400000006 < (/.f32 (neg.f32 x) s) Initial program 99.7%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f3244.6%
Simplified44.6%
Taylor expanded in x around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f32N/A
/-lowering-/.f3239.9%
Simplified39.9%
sub0-negN/A
clear-numN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f32N/A
/-lowering-/.f3244.6%
Applied egg-rr44.6%
Final simplification48.5%
(FPCore (x s) :precision binary32 (if (<= x -4.0000000467443897e-7) (- (/ s x)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -4.0000000467443897e-7f) {
tmp = -(s / x);
} else {
tmp = 0.5f;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-4.0000000467443897e-7)) then
tmp = -(s / x)
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-4.0000000467443897e-7)) tmp = Float32(-Float32(s / x)); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-4.0000000467443897e-7)) tmp = -(s / x); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.0000000467443897 \cdot 10^{-7}:\\
\;\;\;\;-\frac{s}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -4.00000005e-7Initial program 100.0%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f3254.3%
Simplified54.3%
Taylor expanded in x around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f32N/A
/-lowering-/.f3248.3%
Simplified48.3%
sub0-negN/A
distribute-neg-fracN/A
/-lowering-/.f32N/A
neg-lowering-neg.f3248.3%
Applied egg-rr48.3%
if -4.00000005e-7 < x Initial program 99.6%
Taylor expanded in x around 0
Simplified45.4%
Final simplification46.4%
(FPCore (x s) :precision binary32 0.5)
float code(float x, float s) {
return 0.5f;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.5e0
end function
function code(x, s) return Float32(0.5) end
function tmp = code(x, s) tmp = single(0.5); end
\begin{array}{l}
\\
0.5
\end{array}
Initial program 99.7%
Taylor expanded in x around 0
Simplified32.6%
herbie shell --seed 2024159
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))