
(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
(/
1.0
(+
1.0
(/
(exp (* (/ x s) -0.3333333333333333))
(exp (/ 0.6666666666666666 (/ s x)))))))
float code(float x, float s) {
return 1.0f / (1.0f + (expf(((x / s) * -0.3333333333333333f)) / expf((0.6666666666666666f / (s / x)))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (1.0e0 + (exp(((x / s) * (-0.3333333333333333e0))) / exp((0.6666666666666666e0 / (s / x)))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(exp(Float32(Float32(x / s) * Float32(-0.3333333333333333))) / exp(Float32(Float32(0.6666666666666666) / Float32(s / x)))))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + (exp(((x / s) * single(-0.3333333333333333))) / exp((single(0.6666666666666666) / (s / x))))); end
\begin{array}{l}
\\
\frac{1}{1 + \frac{e^{\frac{x}{s} \cdot -0.3333333333333333}}{e^{\frac{0.6666666666666666}{\frac{s}{x}}}}}
\end{array}
Initial program 99.8%
*-lft-identityN/A
exp-prodN/A
pow-lowering-pow.f32N/A
exp-1-eN/A
E-lowering-E.f32N/A
distribute-frac-negN/A
neg-sub0N/A
--lowering--.f32N/A
/-lowering-/.f3299.7%
Applied egg-rr99.7%
add-cube-cbrtN/A
unpow-prod-downN/A
*-lowering-*.f32N/A
Applied egg-rr99.8%
associate-*l/N/A
div-invN/A
/-lowering-/.f32N/A
rec-expN/A
exp-lowering-exp.f32N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
metadata-evalN/A
exp-lowering-exp.f32N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f32N/A
/-lowering-/.f3299.8%
Applied egg-rr99.8%
(FPCore (x s) :precision binary32 (/ 1.0 (+ 1.0 (exp (- 0.0 (/ x s))))))
float code(float x, float s) {
return 1.0f / (1.0f + expf((0.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((0.0e0 - (x / s))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(Float32(0.0) - Float32(x / s))))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + exp((single(0.0) - (x / s)))); end
\begin{array}{l}
\\
\frac{1}{1 + e^{0 - \frac{x}{s}}}
\end{array}
Initial program 99.8%
Final simplification99.8%
(FPCore (x s)
:precision binary32
(if (<= x -1.9999999593223797e-31)
(/
1.0
(+
2.0
(*
x
(+
(* x (+ (/ (* x (/ -0.16666666666666666 (* s s))) s) (/ 0.5 (* s s))))
(/ -1.0 s)))))
0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.9999999593223797e-31f) {
tmp = 1.0f / (2.0f + (x * ((x * (((x * (-0.16666666666666666f / (s * s))) / s) + (0.5f / (s * s)))) + (-1.0f / s))));
} 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 <= (-1.9999999593223797e-31)) then
tmp = 1.0e0 / (2.0e0 + (x * ((x * (((x * ((-0.16666666666666666e0) / (s * s))) / s) + (0.5e0 / (s * s)))) + ((-1.0e0) / s))))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-1.9999999593223797e-31)) tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(x * Float32(Float32(x * Float32(Float32(Float32(x * Float32(Float32(-0.16666666666666666) / Float32(s * s))) / s) + Float32(Float32(0.5) / Float32(s * s)))) + Float32(Float32(-1.0) / s))))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-1.9999999593223797e-31)) tmp = single(1.0) / (single(2.0) + (x * ((x * (((x * (single(-0.16666666666666666) / (s * s))) / s) + (single(0.5) / (s * s)))) + (single(-1.0) / s)))); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9999999593223797 \cdot 10^{-31}:\\
\;\;\;\;\frac{1}{2 + x \cdot \left(x \cdot \left(\frac{x \cdot \frac{-0.16666666666666666}{s \cdot s}}{s} + \frac{0.5}{s \cdot s}\right) + \frac{-1}{s}\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.99999996e-31Initial program 99.6%
Taylor expanded in x around 0
Simplified86.8%
times-fracN/A
associate-*l/N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f3288.6%
Applied egg-rr88.6%
if -1.99999996e-31 < x Initial program 99.9%
Taylor expanded in x around 0
Simplified48.1%
(FPCore (x s)
:precision binary32
(if (<= x -1.9999999593223797e-31)
(/
1.0
(+
2.0
(*
x
(+
(/ -1.0 s)
(* x (/ (+ 0.5 (/ (* x -0.16666666666666666) s)) (* s s)))))))
0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.9999999593223797e-31f) {
tmp = 1.0f / (2.0f + (x * ((-1.0f / s) + (x * ((0.5f + ((x * -0.16666666666666666f) / s)) / (s * s))))));
} 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 <= (-1.9999999593223797e-31)) then
tmp = 1.0e0 / (2.0e0 + (x * (((-1.0e0) / s) + (x * ((0.5e0 + ((x * (-0.16666666666666666e0)) / s)) / (s * s))))))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-1.9999999593223797e-31)) tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(x * Float32(Float32(Float32(-1.0) / s) + Float32(x * Float32(Float32(Float32(0.5) + Float32(Float32(x * Float32(-0.16666666666666666)) / s)) / Float32(s * s))))))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-1.9999999593223797e-31)) tmp = single(1.0) / (single(2.0) + (x * ((single(-1.0) / s) + (x * ((single(0.5) + ((x * single(-0.16666666666666666)) / s)) / (s * s)))))); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9999999593223797 \cdot 10^{-31}:\\
\;\;\;\;\frac{1}{2 + x \cdot \left(\frac{-1}{s} + x \cdot \frac{0.5 + \frac{x \cdot -0.16666666666666666}{s}}{s \cdot s}\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.99999996e-31Initial program 99.6%
Taylor expanded in x around 0
Simplified86.8%
Taylor expanded in s around inf
/-lowering-/.f32N/A
+-lowering-+.f32N/A
associate-*r/N/A
/-lowering-/.f32N/A
*-commutativeN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3288.6%
Simplified88.6%
if -1.99999996e-31 < x Initial program 99.9%
Taylor expanded in x around 0
Simplified48.1%
Final simplification66.0%
(FPCore (x s)
:precision binary32
(if (<= x -1.9999999593223797e-31)
(/
1.0
(+
2.0
(* x (+ (/ -1.0 s) (* x (/ (* x -0.16666666666666666) (* s (* s s))))))))
0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.9999999593223797e-31f) {
tmp = 1.0f / (2.0f + (x * ((-1.0f / s) + (x * ((x * -0.16666666666666666f) / (s * (s * s)))))));
} 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 <= (-1.9999999593223797e-31)) then
tmp = 1.0e0 / (2.0e0 + (x * (((-1.0e0) / s) + (x * ((x * (-0.16666666666666666e0)) / (s * (s * s)))))))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-1.9999999593223797e-31)) tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(x * Float32(Float32(Float32(-1.0) / s) + Float32(x * Float32(Float32(x * Float32(-0.16666666666666666)) / Float32(s * Float32(s * s)))))))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-1.9999999593223797e-31)) tmp = single(1.0) / (single(2.0) + (x * ((single(-1.0) / s) + (x * ((x * single(-0.16666666666666666)) / (s * (s * s))))))); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9999999593223797 \cdot 10^{-31}:\\
\;\;\;\;\frac{1}{2 + x \cdot \left(\frac{-1}{s} + x \cdot \frac{x \cdot -0.16666666666666666}{s \cdot \left(s \cdot s\right)}\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.99999996e-31Initial program 99.6%
Taylor expanded in x around 0
Simplified86.8%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f32N/A
*-commutativeN/A
*-lowering-*.f32N/A
cube-multN/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3286.2%
Simplified86.2%
if -1.99999996e-31 < x Initial program 99.9%
Taylor expanded in x around 0
Simplified48.1%
Final simplification64.9%
(FPCore (x s) :precision binary32 (if (<= x -4.99999991225835e-15) (/ 1.0 (+ 2.0 (* x (/ (* -0.16666666666666666 (* x x)) (* s (* s s)))))) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -4.99999991225835e-15f) {
tmp = 1.0f / (2.0f + (x * ((-0.16666666666666666f * (x * x)) / (s * (s * s)))));
} 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.99999991225835e-15)) then
tmp = 1.0e0 / (2.0e0 + (x * (((-0.16666666666666666e0) * (x * x)) / (s * (s * s)))))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-4.99999991225835e-15)) tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(x * Float32(Float32(Float32(-0.16666666666666666) * Float32(x * x)) / Float32(s * Float32(s * s)))))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-4.99999991225835e-15)) tmp = single(1.0) / (single(2.0) + (x * ((single(-0.16666666666666666) * (x * x)) / (s * (s * s))))); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.99999991225835 \cdot 10^{-15}:\\
\;\;\;\;\frac{1}{2 + x \cdot \frac{-0.16666666666666666 \cdot \left(x \cdot x\right)}{s \cdot \left(s \cdot s\right)}}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -4.99999991e-15Initial program 99.7%
Taylor expanded in x around 0
Simplified88.6%
Taylor expanded in x around inf
associate-*r/N/A
/-lowering-/.f32N/A
*-commutativeN/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f32N/A
cube-multN/A
unpow2N/A
*-lowering-*.f32N/A
unpow2N/A
*-lowering-*.f3286.3%
Simplified86.3%
if -4.99999991e-15 < x Initial program 99.8%
Taylor expanded in x around 0
Simplified49.9%
Final simplification63.5%
(FPCore (x s) :precision binary32 (if (<= x -1.9999999593223797e-31) (/ 1.0 (+ 2.0 (* x (+ (/ -1.0 s) (* x (/ 0.5 (* s s))))))) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.9999999593223797e-31f) {
tmp = 1.0f / (2.0f + (x * ((-1.0f / s) + (x * (0.5f / (s * s))))));
} 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 <= (-1.9999999593223797e-31)) then
tmp = 1.0e0 / (2.0e0 + (x * (((-1.0e0) / s) + (x * (0.5e0 / (s * s))))))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-1.9999999593223797e-31)) tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(x * Float32(Float32(Float32(-1.0) / s) + Float32(x * Float32(Float32(0.5) / Float32(s * s))))))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-1.9999999593223797e-31)) tmp = single(1.0) / (single(2.0) + (x * ((single(-1.0) / s) + (x * (single(0.5) / (s * s)))))); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9999999593223797 \cdot 10^{-31}:\\
\;\;\;\;\frac{1}{2 + x \cdot \left(\frac{-1}{s} + x \cdot \frac{0.5}{s \cdot s}\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.99999996e-31Initial program 99.6%
Taylor expanded in x around 0
Simplified86.8%
Taylor expanded in x around 0
/-lowering-/.f32N/A
unpow2N/A
*-lowering-*.f3280.0%
Simplified80.0%
if -1.99999996e-31 < x Initial program 99.9%
Taylor expanded in x around 0
Simplified48.1%
Final simplification62.2%
(FPCore (x s) :precision binary32 (if (<= x -1.99999996490334e-13) (/ 1.0 (/ (* -0.16666666666666666 (* x (* x x))) (* s (* s s)))) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.99999996490334e-13f) {
tmp = 1.0f / ((-0.16666666666666666f * (x * (x * x))) / (s * (s * s)));
} 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 <= (-1.99999996490334e-13)) then
tmp = 1.0e0 / (((-0.16666666666666666e0) * (x * (x * x))) / (s * (s * s)))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-1.99999996490334e-13)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(-0.16666666666666666) * Float32(x * Float32(x * x))) / Float32(s * Float32(s * s)))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-1.99999996490334e-13)) tmp = single(1.0) / ((single(-0.16666666666666666) * (x * (x * x))) / (s * (s * s))); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\
\;\;\;\;\frac{1}{\frac{-0.16666666666666666 \cdot \left(x \cdot \left(x \cdot x\right)\right)}{s \cdot \left(s \cdot s\right)}}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.99999996e-13Initial program 99.8%
Taylor expanded in x around 0
Simplified88.1%
Taylor expanded in x around inf
associate-*r/N/A
*-rgt-identityN/A
metadata-evalN/A
log-EN/A
cube-multN/A
unpow2N/A
associate-/r*N/A
associate-*r/N/A
/-lowering-/.f32N/A
Simplified82.3%
/-lowering-/.f32N/A
associate-*r/N/A
associate-/l/N/A
pow3N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
*-lowering-*.f32N/A
*-lowering-*.f32N/A
pow3N/A
*-lowering-*.f32N/A
*-lowering-*.f3284.2%
Applied egg-rr84.2%
if -1.99999996e-13 < x Initial program 99.8%
Taylor expanded in x around 0
Simplified50.1%
Final simplification62.1%
(FPCore (x s) :precision binary32 (if (<= x -1.99999996490334e-13) (/ -6.0 (/ (* x (* x x)) (* s (* s s)))) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.99999996490334e-13f) {
tmp = -6.0f / ((x * (x * x)) / (s * (s * s)));
} 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 <= (-1.99999996490334e-13)) then
tmp = (-6.0e0) / ((x * (x * x)) / (s * (s * s)))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-1.99999996490334e-13)) tmp = Float32(Float32(-6.0) / Float32(Float32(x * Float32(x * x)) / Float32(s * Float32(s * s)))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-1.99999996490334e-13)) tmp = single(-6.0) / ((x * (x * x)) / (s * (s * s))); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\
\;\;\;\;\frac{-6}{\frac{x \cdot \left(x \cdot x\right)}{s \cdot \left(s \cdot s\right)}}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.99999996e-13Initial program 99.8%
Taylor expanded in x around 0
Simplified88.1%
Taylor expanded in x around inf
associate-*r/N/A
*-rgt-identityN/A
metadata-evalN/A
log-EN/A
cube-multN/A
unpow2N/A
associate-/r*N/A
associate-*r/N/A
/-lowering-/.f32N/A
Simplified82.3%
associate-/l*N/A
associate-/r*N/A
metadata-evalN/A
metadata-evalN/A
/-lowering-/.f32N/A
metadata-evalN/A
associate-/l/N/A
pow3N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
*-lowering-*.f32N/A
pow3N/A
*-lowering-*.f32N/A
*-lowering-*.f3284.2%
Applied egg-rr84.2%
if -1.99999996e-13 < x Initial program 99.8%
Taylor expanded in x around 0
Simplified50.1%
Final simplification62.1%
(FPCore (x s) :precision binary32 (if (<= x -1.99999996490334e-13) (* (/ s (/ (* x (* x x)) s)) (/ s -0.16666666666666666)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.99999996490334e-13f) {
tmp = (s / ((x * (x * x)) / s)) * (s / -0.16666666666666666f);
} 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 <= (-1.99999996490334e-13)) then
tmp = (s / ((x * (x * x)) / s)) * (s / (-0.16666666666666666e0))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-1.99999996490334e-13)) tmp = Float32(Float32(s / Float32(Float32(x * Float32(x * x)) / s)) * Float32(s / Float32(-0.16666666666666666))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-1.99999996490334e-13)) tmp = (s / ((x * (x * x)) / s)) * (s / single(-0.16666666666666666)); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\
\;\;\;\;\frac{s}{\frac{x \cdot \left(x \cdot x\right)}{s}} \cdot \frac{s}{-0.16666666666666666}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.99999996e-13Initial program 99.8%
Taylor expanded in x around 0
Simplified88.1%
Taylor expanded in x around inf
associate-*r/N/A
*-rgt-identityN/A
metadata-evalN/A
log-EN/A
cube-multN/A
unpow2N/A
associate-/r*N/A
associate-*r/N/A
/-lowering-/.f32N/A
Simplified82.3%
clear-numN/A
*-commutativeN/A
times-fracN/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
*-lowering-*.f32N/A
/-lowering-/.f3279.8%
Applied egg-rr79.8%
if -1.99999996e-13 < x Initial program 99.8%
Taylor expanded in x around 0
Simplified50.1%
(FPCore (x s) :precision binary32 (if (<= x -1.99999996490334e-13) (* (/ s -0.16666666666666666) (/ s (* (/ x s) (* x x)))) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.99999996490334e-13f) {
tmp = (s / -0.16666666666666666f) * (s / ((x / s) * (x * 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 <= (-1.99999996490334e-13)) then
tmp = (s / (-0.16666666666666666e0)) * (s / ((x / s) * (x * x)))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-1.99999996490334e-13)) tmp = Float32(Float32(s / Float32(-0.16666666666666666)) * Float32(s / Float32(Float32(x / s) * Float32(x * x)))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-1.99999996490334e-13)) tmp = (s / single(-0.16666666666666666)) * (s / ((x / s) * (x * x))); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\
\;\;\;\;\frac{s}{-0.16666666666666666} \cdot \frac{s}{\frac{x}{s} \cdot \left(x \cdot x\right)}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.99999996e-13Initial program 99.8%
Taylor expanded in x around 0
Simplified88.1%
Taylor expanded in x around inf
associate-*r/N/A
*-rgt-identityN/A
metadata-evalN/A
log-EN/A
cube-multN/A
unpow2N/A
associate-/r*N/A
associate-*r/N/A
/-lowering-/.f32N/A
Simplified82.3%
clear-numN/A
*-commutativeN/A
times-fracN/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
*-lowering-*.f32N/A
/-lowering-/.f3279.8%
Applied egg-rr79.8%
associate-*r*N/A
associate-/l*N/A
*-lowering-*.f32N/A
*-lowering-*.f32N/A
/-lowering-/.f3279.8%
Applied egg-rr79.8%
if -1.99999996e-13 < x Initial program 99.8%
Taylor expanded in x around 0
Simplified50.1%
Final simplification60.6%
(FPCore (x s) :precision binary32 (if (<= x -1.99999996490334e-13) (* s (/ s (/ -0.16666666666666666 (/ s (* x (* x x)))))) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.99999996490334e-13f) {
tmp = s * (s / (-0.16666666666666666f / (s / (x * (x * 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 <= (-1.99999996490334e-13)) then
tmp = s * (s / ((-0.16666666666666666e0) / (s / (x * (x * x)))))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-1.99999996490334e-13)) tmp = Float32(s * Float32(s / Float32(Float32(-0.16666666666666666) / Float32(s / Float32(x * Float32(x * x)))))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-1.99999996490334e-13)) tmp = s * (s / (single(-0.16666666666666666) / (s / (x * (x * x))))); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\
\;\;\;\;s \cdot \frac{s}{\frac{-0.16666666666666666}{\frac{s}{x \cdot \left(x \cdot x\right)}}}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.99999996e-13Initial program 99.8%
Taylor expanded in x around 0
Simplified88.1%
Taylor expanded in x around inf
associate-*r/N/A
*-rgt-identityN/A
metadata-evalN/A
log-EN/A
cube-multN/A
unpow2N/A
associate-/r*N/A
associate-*r/N/A
/-lowering-/.f32N/A
Simplified82.3%
clear-numN/A
associate-/l*N/A
*-lowering-*.f32N/A
/-lowering-/.f32N/A
clear-numN/A
un-div-invN/A
/-lowering-/.f32N/A
/-lowering-/.f32N/A
*-lowering-*.f32N/A
*-lowering-*.f3279.8%
Applied egg-rr79.8%
if -1.99999996e-13 < x Initial program 99.8%
Taylor expanded in x around 0
Simplified50.1%
(FPCore (x s) :precision binary32 (if (<= x -1.99999996490334e-13) (/ (/ (* s (- s)) s) x) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.99999996490334e-13f) {
tmp = ((s * -s) / 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 <= (-1.99999996490334e-13)) then
tmp = ((s * -s) / s) / x
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-1.99999996490334e-13)) tmp = Float32(Float32(Float32(s * Float32(-s)) / s) / x); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-1.99999996490334e-13)) tmp = ((s * -s) / s) / x; else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.99999996490334 \cdot 10^{-13}:\\
\;\;\;\;\frac{\frac{s \cdot \left(-s\right)}{s}}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.99999996e-13Initial program 99.8%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f3248.9%
Simplified48.9%
Taylor expanded in x around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f32N/A
/-lowering-/.f3243.1%
Simplified43.1%
sub0-negN/A
distribute-neg-fracN/A
/-lowering-/.f32N/A
neg-lowering-neg.f3243.1%
Applied egg-rr43.1%
neg-sub0N/A
flip--N/A
metadata-evalN/A
neg-sub0N/A
/-lowering-/.f32N/A
neg-sub0N/A
--lowering--.f32N/A
*-lowering-*.f32N/A
+-lowering-+.f3258.9%
Applied egg-rr58.9%
if -1.99999996e-13 < x Initial program 99.8%
Taylor expanded in x around 0
Simplified50.1%
Final simplification53.2%
(FPCore (x s) :precision binary32 (if (<= x -1.9999999593223797e-31) (/ 1.0 (- 2.0 (/ x s))) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.9999999593223797e-31f) {
tmp = 1.0f / (2.0f - (x / s));
} 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 <= (-1.9999999593223797e-31)) then
tmp = 1.0e0 / (2.0e0 - (x / s))
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-1.9999999593223797e-31)) tmp = Float32(Float32(1.0) / Float32(Float32(2.0) - Float32(x / s))); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-1.9999999593223797e-31)) tmp = single(1.0) / (single(2.0) - (x / s)); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9999999593223797 \cdot 10^{-31}:\\
\;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1.99999996e-31Initial program 99.6%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f3252.2%
Simplified52.2%
if -1.99999996e-31 < x Initial program 99.9%
Taylor expanded in x around 0
Simplified48.1%
(FPCore (x s) :precision binary32 (if (<= x -4.999999969612645e-9) (/ -1.0 (/ x s)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -4.999999969612645e-9f) {
tmp = -1.0f / (x / s);
} 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.999999969612645e-9)) then
tmp = (-1.0e0) / (x / s)
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-4.999999969612645e-9)) tmp = Float32(Float32(-1.0) / Float32(x / s)); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-4.999999969612645e-9)) tmp = single(-1.0) / (x / s); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.999999969612645 \cdot 10^{-9}:\\
\;\;\;\;\frac{-1}{\frac{x}{s}}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -4.99999997e-9Initial program 99.8%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f3252.3%
Simplified52.3%
Taylor expanded in x around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f32N/A
/-lowering-/.f3248.2%
Simplified48.2%
sub0-negN/A
clear-numN/A
distribute-neg-fracN/A
metadata-evalN/A
/-lowering-/.f32N/A
/-lowering-/.f3252.3%
Applied egg-rr52.3%
if -4.99999997e-9 < x Initial program 99.7%
Taylor expanded in x around 0
Simplified48.2%
(FPCore (x s) :precision binary32 (if (<= x -4.999999969612645e-9) (/ s (- x)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -4.999999969612645e-9f) {
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.999999969612645e-9)) 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.999999969612645e-9)) tmp = Float32(s / Float32(-x)); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-4.999999969612645e-9)) tmp = s / -x; else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.999999969612645 \cdot 10^{-9}:\\
\;\;\;\;\frac{s}{-x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -4.99999997e-9Initial program 99.8%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
--lowering--.f32N/A
/-lowering-/.f3252.3%
Simplified52.3%
Taylor expanded in x around inf
mul-1-negN/A
neg-sub0N/A
--lowering--.f32N/A
/-lowering-/.f3248.2%
Simplified48.2%
sub0-negN/A
distribute-neg-fracN/A
/-lowering-/.f32N/A
neg-lowering-neg.f3248.2%
Applied egg-rr48.2%
if -4.99999997e-9 < x Initial program 99.7%
Taylor expanded in x around 0
Simplified48.2%
Final simplification48.2%
(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
Simplified35.7%
herbie shell --seed 2024138
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))