
(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 13 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 (pow (exp -2.0) (* (log1p (exp (- (/ x s)))) 0.5)))
float code(float x, float s) {
return powf(expf(-2.0f), (log1pf(expf(-(x / s))) * 0.5f));
}
function code(x, s) return exp(Float32(-2.0)) ^ Float32(log1p(exp(Float32(-Float32(x / s)))) * Float32(0.5)) end
\begin{array}{l}
\\
{\left(e^{-2}\right)}^{\left(\mathsf{log1p}\left(e^{-\frac{x}{s}}\right) \cdot 0.5\right)}
\end{array}
Initial program 99.8%
inv-powN/A
sqr-powN/A
pow2N/A
pow-lowering-pow.f32N/A
pow-lowering-pow.f32N/A
+-lowering-+.f32N/A
exp-lowering-exp.f32N/A
distribute-frac-negN/A
neg-lowering-neg.f32N/A
/-lowering-/.f32N/A
metadata-eval99.3
Applied egg-rr99.3%
pow-to-expN/A
pow-expN/A
*-commutativeN/A
exp-prodN/A
pow-lowering-pow.f32N/A
exp-lowering-exp.f32N/A
*-commutativeN/A
*-lowering-*.f32N/A
accelerator-lowering-log1p.f32N/A
exp-lowering-exp.f32N/A
distribute-neg-frac2N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3299.9
Applied egg-rr99.9%
sqr-powN/A
pow-prod-downN/A
associate-/l*N/A
pow-unpowN/A
pow-lowering-pow.f32N/A
pow-lowering-pow.f32N/A
prod-expN/A
exp-lowering-exp.f32N/A
metadata-evalN/A
/-lowering-/.f32N/A
accelerator-lowering-log1p.f32N/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3299.9
Applied egg-rr99.9%
pow-lowering-pow.f32N/A
pow-expN/A
rem-log-expN/A
pow-expN/A
exp-lowering-exp.f32N/A
pow-expN/A
rem-log-expN/A
metadata-evalN/A
div-invN/A
metadata-evalN/A
*-lowering-*.f32N/A
accelerator-lowering-log1p.f32N/A
exp-lowering-exp.f32N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3299.9
Applied egg-rr99.9%
Final simplification99.9%
(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}
Initial program 99.8%
Final simplification99.8%
(FPCore (x s)
:precision binary32
(if (<= (- (/ x s)) 1.0)
0.5
(/
1.0
(fma
x
(fma
x
(fma -0.16666666666666666 (/ x (* s (* s s))) (/ 0.5 (* s s)))
(/ -1.0 s))
2.0))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 1.0f) {
tmp = 0.5f;
} else {
tmp = 1.0f / fmaf(x, fmaf(x, fmaf(-0.16666666666666666f, (x / (s * (s * s))), (0.5f / (s * s))), (-1.0f / s)), 2.0f);
}
return tmp;
}
function code(x, s) tmp = Float32(0.0) if (Float32(-Float32(x / s)) <= Float32(1.0)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / fma(x, fma(x, fma(Float32(-0.16666666666666666), Float32(x / Float32(s * Float32(s * s))), Float32(Float32(0.5) / Float32(s * s))), Float32(Float32(-1.0) / s)), Float32(2.0))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-\frac{x}{s} \leq 1:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(-0.16666666666666666, \frac{x}{s \cdot \left(s \cdot s\right)}, \frac{0.5}{s \cdot s}\right), \frac{-1}{s}\right), 2\right)}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 1Initial program 99.7%
Taylor expanded in x around 0
Simplified50.8%
if 1 < (/.f32 (neg.f32 x) s) Initial program 99.9%
Taylor expanded in s around -inf
+-lowering-+.f32N/A
associate-*r/N/A
/-lowering-/.f32N/A
Simplified73.5%
Taylor expanded in x around 0
+-commutativeN/A
accelerator-lowering-fma.f32N/A
Simplified87.6%
Final simplification66.7%
(FPCore (x s)
:precision binary32
(if (<= (- x) 5.000000136226006e-28)
0.5
(/
1.0
(fma
x
(fma (/ x (* s s)) (fma -0.16666666666666666 (/ x s) 0.5) (/ -1.0 s))
2.0))))
float code(float x, float s) {
float tmp;
if (-x <= 5.000000136226006e-28f) {
tmp = 0.5f;
} else {
tmp = 1.0f / fmaf(x, fmaf((x / (s * s)), fmaf(-0.16666666666666666f, (x / s), 0.5f), (-1.0f / s)), 2.0f);
}
return tmp;
}
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(5.000000136226006e-28)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / fma(x, fma(Float32(x / Float32(s * s)), fma(Float32(-0.16666666666666666), Float32(x / s), Float32(0.5)), Float32(Float32(-1.0) / s)), Float32(2.0))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq 5.000000136226006 \cdot 10^{-28}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(x, \mathsf{fma}\left(\frac{x}{s \cdot s}, \mathsf{fma}\left(-0.16666666666666666, \frac{x}{s}, 0.5\right), \frac{-1}{s}\right), 2\right)}\\
\end{array}
\end{array}
if (neg.f32 x) < 5.00000014e-28Initial program 99.7%
Taylor expanded in x around 0
Simplified46.3%
if 5.00000014e-28 < (neg.f32 x) Initial program 99.9%
Taylor expanded in x around 0
+-commutativeN/A
accelerator-lowering-fma.f32N/A
Simplified85.8%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) 100.0) 0.5 (/ 1.0 (* x (* (* x x) (/ -0.16666666666666666 (* s (* s s))))))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 100.0f) {
tmp = 0.5f;
} else {
tmp = 1.0f / (x * ((x * x) * (-0.16666666666666666f / (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 / s) <= 100.0e0) then
tmp = 0.5e0
else
tmp = 1.0e0 / (x * ((x * x) * ((-0.16666666666666666e0) / (s * (s * s)))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-Float32(x / s)) <= Float32(100.0)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(x * x) * Float32(Float32(-0.16666666666666666) / Float32(s * Float32(s * s)))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-(x / s) <= single(100.0)) tmp = single(0.5); else tmp = single(1.0) / (x * ((x * x) * (single(-0.16666666666666666) / (s * (s * s))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-\frac{x}{s} \leq 100:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(\left(x \cdot x\right) \cdot \frac{-0.16666666666666666}{s \cdot \left(s \cdot s\right)}\right)}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 100Initial program 99.7%
Taylor expanded in x around 0
Simplified50.3%
if 100 < (/.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
Simplified74.5%
Taylor expanded in x around inf
cube-multN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f32N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f32N/A
sub-negN/A
+-lowering-+.f32N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f32N/A
*-commutativeN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f32N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
Simplified83.1%
Taylor expanded in x around inf
/-lowering-/.f32N/A
cube-multN/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3283.1
Simplified83.1%
Final simplification64.3%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) 2.0) 0.5 (/ 1.0 (* x (* 0.5 (/ x (* s s)))))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 2.0f) {
tmp = 0.5f;
} else {
tmp = 1.0f / (x * (0.5f * (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 / s) <= 2.0e0) then
tmp = 0.5e0
else
tmp = 1.0e0 / (x * (0.5e0 * (x / (s * s))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-Float32(x / s)) <= Float32(2.0)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(0.5) * Float32(x / Float32(s * s))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-(x / s) <= single(2.0)) tmp = single(0.5); else tmp = single(1.0) / (x * (single(0.5) * (x / (s * s)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-\frac{x}{s} \leq 2:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \left(0.5 \cdot \frac{x}{s \cdot s}\right)}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 2Initial program 99.7%
Taylor expanded in x around 0
Simplified50.6%
if 2 < (/.f32 (neg.f32 x) s) Initial program 99.9%
Taylor expanded in s around -inf
+-lowering-+.f32N/A
associate-*r/N/A
/-lowering-/.f32N/A
Simplified73.8%
Taylor expanded in x around inf
cube-multN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f32N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f32N/A
sub-negN/A
+-lowering-+.f32N/A
associate-*r/N/A
metadata-evalN/A
/-lowering-/.f32N/A
*-commutativeN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f32N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
Simplified82.4%
Taylor expanded in x around 0
*-lowering-*.f32N/A
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3278.8
Simplified78.8%
Final simplification62.7%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) 500.0) 0.5 (/ (* s (* (* s s) -6.0)) (* x (* x x)))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 500.0f) {
tmp = 0.5f;
} else {
tmp = (s * ((s * s) * -6.0f)) / (x * (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 / s) <= 500.0e0) then
tmp = 0.5e0
else
tmp = (s * ((s * s) * (-6.0e0))) / (x * (x * x))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-Float32(x / s)) <= Float32(500.0)) tmp = Float32(0.5); else tmp = Float32(Float32(s * Float32(Float32(s * s) * Float32(-6.0))) / Float32(x * Float32(x * x))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-(x / s) <= single(500.0)) tmp = single(0.5); else tmp = (s * ((s * s) * single(-6.0))) / (x * (x * x)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-\frac{x}{s} \leq 500:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{s \cdot \left(\left(s \cdot s\right) \cdot -6\right)}{x \cdot \left(x \cdot x\right)}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 500Initial program 99.7%
Taylor expanded in x around 0
Simplified49.7%
if 500 < (/.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
Simplified75.7%
+-commutativeN/A
*-commutativeN/A
accelerator-lowering-fma.f32N/A
*-lowering-*.f32N/A
associate-*l/N/A
/-lowering-/.f32N/A
associate-*l*N/A
*-lowering-*.f32N/A
*-lowering-*.f32N/A
*-lowering-*.f3275.7
Applied egg-rr75.7%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f32N/A
*-commutativeN/A
cube-multN/A
unpow2N/A
associate-*l*N/A
*-lowering-*.f32N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f32N/A
cube-multN/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3278.1
Simplified78.1%
Final simplification61.6%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) 50000.0) 0.5 (/ (* (* s s) 2.0) (* x x))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 50000.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 (-(x / s) <= 50000.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(x / s)) <= Float32(50000.0)) tmp = Float32(0.5); else tmp = Float32(Float32(Float32(s * s) * Float32(2.0)) / Float32(x * x)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-(x / s) <= single(50000.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}\;-\frac{x}{s} \leq 50000:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(s \cdot s\right) \cdot 2}{x \cdot x}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 5e4Initial program 99.7%
Taylor expanded in x around 0
Simplified48.6%
if 5e4 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
sub-negN/A
distribute-lft-inN/A
associate-*r*N/A
*-commutativeN/A
associate-/l*N/A
unpow2N/A
times-fracN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-/l*N/A
*-commutativeN/A
associate-*r/N/A
distribute-rgt-outN/A
accelerator-lowering-fma.f32N/A
Simplified73.8%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3276.1
Simplified76.1%
Final simplification59.7%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) -1.0) 0.5 (/ 1.0 (- 2.0 (/ x s)))))
float code(float x, float s) {
float tmp;
if (-(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 (-(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(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 (-(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}\;-\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 99.9%
Taylor expanded in x around 0
Simplified28.2%
if -1 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f3254.5
Simplified54.5%
Final simplification45.4%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) 2.0) 0.5 (/ -1.0 (/ x s))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 2.0f) {
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 (-(x / s) <= 2.0e0) 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(x / s)) <= Float32(2.0)) 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 (-(x / s) <= single(2.0)) tmp = single(0.5); else tmp = single(-1.0) / (x / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-\frac{x}{s} \leq 2:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{x}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 2Initial program 99.7%
Taylor expanded in x around 0
Simplified50.6%
if 2 < (/.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-/.f3234.4
Simplified34.4%
Taylor expanded in x around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3230.5
Simplified30.5%
clear-numN/A
frac-2negN/A
metadata-evalN/A
distribute-frac-neg2N/A
frac-2negN/A
/-lowering-/.f32N/A
/-lowering-/.f3234.4
Applied egg-rr34.4%
Final simplification43.7%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) 2.0) 0.5 (* s (/ -1.0 x))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 2.0f) {
tmp = 0.5f;
} else {
tmp = s * (-1.0f / x);
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (-(x / s) <= 2.0e0) then
tmp = 0.5e0
else
tmp = s * ((-1.0e0) / x)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-Float32(x / s)) <= Float32(2.0)) tmp = Float32(0.5); else tmp = Float32(s * Float32(Float32(-1.0) / x)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-(x / s) <= single(2.0)) tmp = single(0.5); else tmp = s * (single(-1.0) / x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-\frac{x}{s} \leq 2:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;s \cdot \frac{-1}{x}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 2Initial program 99.7%
Taylor expanded in x around 0
Simplified50.6%
if 2 < (/.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-/.f3234.4
Simplified34.4%
Taylor expanded in x around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3230.5
Simplified30.5%
clear-numN/A
associate-/r/N/A
*-lowering-*.f32N/A
metadata-evalN/A
frac-2negN/A
/-lowering-/.f3230.5
Applied egg-rr30.5%
Final simplification42.0%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) 2.0) 0.5 (/ s (- x))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 2.0f) {
tmp = 0.5f;
} else {
tmp = 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 / s) <= 2.0e0) then
tmp = 0.5e0
else
tmp = s / -x
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-Float32(x / s)) <= Float32(2.0)) tmp = Float32(0.5); else tmp = Float32(s / Float32(-x)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-(x / s) <= single(2.0)) tmp = single(0.5); else tmp = s / -x; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-\frac{x}{s} \leq 2:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{s}{-x}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 2Initial program 99.7%
Taylor expanded in x around 0
Simplified50.6%
if 2 < (/.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-/.f3234.4
Simplified34.4%
Taylor expanded in x around inf
mul-1-negN/A
distribute-neg-frac2N/A
/-lowering-/.f32N/A
neg-lowering-neg.f3230.5
Simplified30.5%
Final simplification42.0%
(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.8%
Taylor expanded in x around 0
Simplified31.6%
herbie shell --seed 2024205
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))