
(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 14 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))))))
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 (<= (exp (- (/ x s))) 1.9999999494757503e-5) 0.5 (/ 1.0 (- 2.0 (/ x s)))))
float code(float x, float s) {
float tmp;
if (expf(-(x / s)) <= 1.9999999494757503e-5f) {
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 (exp(-(x / s)) <= 1.9999999494757503e-5) 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 (exp(Float32(-Float32(x / s))) <= Float32(1.9999999494757503e-5)) 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 (exp(-(x / s)) <= single(1.9999999494757503e-5)) 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}\;e^{-\frac{x}{s}} \leq 1.9999999494757503 \cdot 10^{-5}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
\end{array}
\end{array}
if (exp.f32 (/.f32 (neg.f32 x) s)) < 1.99999995e-5Initial program 100.0%
Taylor expanded in x around 0
Simplified28.1%
if 1.99999995e-5 < (exp.f32 (/.f32 (neg.f32 x) s)) Initial program 99.7%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f3261.0
Simplified61.0%
Final simplification48.8%
(FPCore (x s) :precision binary32 (if (<= (exp (- (/ x s))) 2.0) 0.5 (/ -1.0 (/ x s))))
float code(float x, float s) {
float tmp;
if (expf(-(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 (exp(-(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 (exp(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 (exp(-(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}\;e^{-\frac{x}{s}} \leq 2:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{x}{s}}\\
\end{array}
\end{array}
if (exp.f32 (/.f32 (neg.f32 x) s)) < 2Initial program 99.8%
Taylor expanded in x around 0
Simplified51.1%
if 2 < (exp.f32 (/.f32 (neg.f32 x) s)) Initial program 99.7%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f3242.4
Simplified42.4%
Taylor expanded in x around inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f32N/A
mul-1-negN/A
lower-neg.f3239.2
Simplified39.2%
lift-neg.f32N/A
clear-numN/A
metadata-evalN/A
lift-neg.f32N/A
distribute-frac-negN/A
lift-/.f32N/A
frac-2negN/A
lower-/.f3242.4
Applied egg-rr42.4%
Final simplification47.5%
(FPCore (x s) :precision binary32 (if (<= (exp (- (/ x s))) 2.0) 0.5 (/ (- s) x)))
float code(float x, float s) {
float tmp;
if (expf(-(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 (exp(-(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 (exp(Float32(-Float32(x / s))) <= Float32(2.0)) tmp = Float32(0.5); else tmp = Float32(Float32(-s) / x); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (exp(-(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}\;e^{-\frac{x}{s}} \leq 2:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{-s}{x}\\
\end{array}
\end{array}
if (exp.f32 (/.f32 (neg.f32 x) s)) < 2Initial program 99.8%
Taylor expanded in x around 0
Simplified51.1%
if 2 < (exp.f32 (/.f32 (neg.f32 x) s)) Initial program 99.7%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f3242.4
Simplified42.4%
Taylor expanded in x around inf
mul-1-negN/A
distribute-neg-frac2N/A
mul-1-negN/A
lower-/.f32N/A
mul-1-negN/A
lower-neg.f3239.2
Simplified39.2%
Final simplification46.2%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) 0.20000000298023224) 0.5 (/ 1.0 (fma x (* (* x -0.16666666666666666) (/ x (* s (* s s)))) 2.0))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 0.20000000298023224f) {
tmp = 0.5f;
} else {
tmp = 1.0f / fmaf(x, ((x * -0.16666666666666666f) * (x / (s * (s * s)))), 2.0f);
}
return tmp;
}
function code(x, s) tmp = Float32(0.0) if (Float32(-Float32(x / s)) <= Float32(0.20000000298023224)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / fma(x, Float32(Float32(x * Float32(-0.16666666666666666)) * Float32(x / Float32(s * Float32(s * s)))), Float32(2.0))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-\frac{x}{s} \leq 0.20000000298023224:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(x, \left(x \cdot -0.16666666666666666\right) \cdot \frac{x}{s \cdot \left(s \cdot s\right)}, 2\right)}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 0.200000003Initial program 99.8%
Taylor expanded in x around 0
Simplified51.1%
if 0.200000003 < (/.f32 (neg.f32 x) s) Initial program 99.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f32N/A
Simplified88.5%
Taylor expanded in x around inf
associate-*r/N/A
lower-/.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
cube-multN/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3288.0
Simplified88.0%
associate-*r*N/A
lift-*.f32N/A
lift-*.f32N/A
associate-/l*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-/.f3291.9
Applied egg-rr91.9%
Final simplification68.0%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) 200.0) 0.5 (/ 1.0 (* x (* (* x x) (/ -0.16666666666666666 (* s (* s s))))))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 200.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) <= 200.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(200.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(200.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 200:\\
\;\;\;\;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) < 200Initial program 99.7%
Taylor expanded in x around 0
Simplified49.8%
if 200 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f32N/A
Simplified91.2%
Taylor expanded in x around inf
cube-multN/A
unpow2N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
sub-negN/A
lower-+.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
Simplified92.7%
Taylor expanded in x around inf
lower-/.f32N/A
cube-multN/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3292.7
Simplified92.7%
Final simplification66.8%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) 0.20000000298023224) 0.5 (/ 1.0 (* x (/ (* x 0.5) (* s s))))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 0.20000000298023224f) {
tmp = 0.5f;
} else {
tmp = 1.0f / (x * ((x * 0.5f) / (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) <= 0.20000000298023224e0) then
tmp = 0.5e0
else
tmp = 1.0e0 / (x * ((x * 0.5e0) / (s * s)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-Float32(x / s)) <= Float32(0.20000000298023224)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(x * Float32(0.5)) / Float32(s * s)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-(x / s) <= single(0.20000000298023224)) tmp = single(0.5); else tmp = single(1.0) / (x * ((x * single(0.5)) / (s * s))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-\frac{x}{s} \leq 0.20000000298023224:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \frac{x \cdot 0.5}{s \cdot s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 0.200000003Initial program 99.8%
Taylor expanded in x around 0
Simplified51.1%
if 0.200000003 < (/.f32 (neg.f32 x) s) Initial program 99.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f32N/A
Simplified88.5%
Taylor expanded in x around inf
cube-multN/A
unpow2N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
sub-negN/A
lower-+.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
Simplified88.8%
Taylor expanded in x around 0
associate-*r/N/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f3282.5
Simplified82.5%
Final simplification64.1%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) 2900.0) 0.5 (/ (* s (* (* s s) -6.0)) (* x (* x x)))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 2900.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) <= 2900.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(2900.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(2900.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 2900:\\
\;\;\;\;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) < 2900Initial program 99.7%
Taylor expanded in x around 0
Simplified48.7%
if 2900 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f32N/A
Simplified90.8%
Taylor expanded in x around inf
associate-*r/N/A
lower-/.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
cube-multN/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3294.6
Simplified94.6%
Taylor expanded in x around inf
associate-*r/N/A
lower-/.f32N/A
*-commutativeN/A
cube-multN/A
unpow2N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
cube-multN/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3288.4
Simplified88.4%
Final simplification63.8%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) 2900.0) 0.5 (* (* s (* s s)) (/ -6.0 (* x (* x x))))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 2900.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) <= 2900.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(2900.0)) tmp = Float32(0.5); else tmp = Float32(Float32(s * Float32(s * s)) * Float32(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(2900.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 2900:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\left(s \cdot \left(s \cdot s\right)\right) \cdot \frac{-6}{x \cdot \left(x \cdot x\right)}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 2900Initial program 99.7%
Taylor expanded in x around 0
Simplified48.7%
if 2900 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f32N/A
Simplified90.8%
Taylor expanded in x around inf
cube-multN/A
unpow2N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
sub-negN/A
lower-+.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
Simplified95.5%
Taylor expanded in x around inf
associate-*r/N/A
*-commutativeN/A
associate-/l*N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
associate-*r/N/A
lower-*.f32N/A
cube-multN/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f32N/A
cube-multN/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3285.3
Simplified85.3%
Final simplification62.6%
(FPCore (x s) :precision binary32 (if (<= (- x) 5.0000000900125474e-36) 0.5 (/ 1.0 (fma x (/ (fma x 0.5 (- s)) (* s s)) 2.0))))
float code(float x, float s) {
float tmp;
if (-x <= 5.0000000900125474e-36f) {
tmp = 0.5f;
} else {
tmp = 1.0f / fmaf(x, (fmaf(x, 0.5f, -s) / (s * s)), 2.0f);
}
return tmp;
}
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(5.0000000900125474e-36)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / fma(x, Float32(fma(x, Float32(0.5), Float32(-s)) / Float32(s * s)), Float32(2.0))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq 5.0000000900125474 \cdot 10^{-36}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(x, \frac{\mathsf{fma}\left(x, 0.5, -s\right)}{s \cdot s}, 2\right)}\\
\end{array}
\end{array}
if (neg.f32 x) < 5.00000009e-36Initial program 99.9%
Taylor expanded in x around 0
Simplified43.8%
if 5.00000009e-36 < (neg.f32 x) Initial program 99.7%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f32N/A
Simplified89.2%
Taylor expanded in x around 0
Simplified84.3%
Taylor expanded in s around 0
lower-/.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
mul-1-negN/A
lower-neg.f32N/A
unpow2N/A
lower-*.f3284.3
Simplified84.3%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) 200.0) 0.5 (/ (* s (* s 2.0)) (* x x))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 200.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) <= 200.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(200.0)) tmp = Float32(0.5); else tmp = Float32(Float32(s * Float32(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(200.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 200:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{s \cdot \left(s \cdot 2\right)}{x \cdot x}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 200Initial program 99.7%
Taylor expanded in x around 0
Simplified49.8%
if 200 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f32N/A
Simplified91.2%
Taylor expanded in x around 0
Simplified84.9%
Taylor expanded in x around inf
associate-*r/N/A
lower-/.f32N/A
unpow2N/A
associate-*r*N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f3279.7
Simplified79.7%
Final simplification61.6%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) 200.0) 0.5 (/ (* (* s s) 2.0) (* x x))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 200.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) <= 200.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(200.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(200.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 200:\\
\;\;\;\;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) < 200Initial program 99.7%
Taylor expanded in x around 0
Simplified49.8%
if 200 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in x around 0
+-commutativeN/A
lower-fma.f32N/A
Simplified91.2%
Taylor expanded in x around inf
cube-multN/A
unpow2N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
sub-negN/A
lower-+.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
Simplified92.7%
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lift-/.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lift-/.f32N/A
lift-+.f32N/A
associate-*r*N/A
lift-+.f32N/A
lift-/.f32N/A
lift-/.f32N/A
frac-addN/A
Applied egg-rr40.9%
Taylor expanded in x around 0
associate-*r/N/A
lower-/.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3279.7
Simplified79.7%
Final simplification61.6%
(FPCore (x s) :precision binary32 (if (<= (- (/ x s)) 2900.0) 0.5 (* s (/ (* s -2.0) (* x x)))))
float code(float x, float s) {
float tmp;
if (-(x / s) <= 2900.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) <= 2900.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(2900.0)) tmp = Float32(0.5); else tmp = Float32(s * Float32(Float32(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(2900.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 2900:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;s \cdot \frac{s \cdot -2}{x \cdot x}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 2900Initial program 99.7%
Taylor expanded in x around 0
Simplified48.7%
if 2900 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in x around 0
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f3245.4
Simplified45.4%
Taylor expanded in s around 0
lower-*.f32N/A
sub-negN/A
lower-fma.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f3242.0
Simplified42.0%
Taylor expanded in s around inf
associate-*r/N/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f3273.3
Simplified73.3%
Final simplification58.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
Simplified32.7%
herbie shell --seed 2024208
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))