
(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 (/ 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.9%
Final simplification99.9%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) 0.0020000000949949026) 0.5 (/ 1.0 (+ (* 0.5 (* x (* x (* (/ 1.0 s) (/ 1.0 s))))) (- 2.0 (/ x s))))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= 0.0020000000949949026f) {
tmp = 0.5f;
} else {
tmp = 1.0f / ((0.5f * (x * (x * ((1.0f / s) * (1.0f / s))))) + (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) <= 0.0020000000949949026e0) then
tmp = 0.5e0
else
tmp = 1.0e0 / ((0.5e0 * (x * (x * ((1.0e0 / s) * (1.0e0 / s))))) + (2.0e0 - (x / s)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(-x) / s) <= Float32(0.0020000000949949026)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(Float32(Float32(0.5) * Float32(x * Float32(x * Float32(Float32(Float32(1.0) / s) * Float32(Float32(1.0) / s))))) + 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(0.0020000000949949026)) tmp = single(0.5); else tmp = single(1.0) / ((single(0.5) * (x * (x * ((single(1.0) / s) * (single(1.0) / s))))) + (single(2.0) - (x / s))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq 0.0020000000949949026:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{0.5 \cdot \left(x \cdot \left(x \cdot \left(\frac{1}{s} \cdot \frac{1}{s}\right)\right)\right) + \left(2 - \frac{x}{s}\right)}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 0.00200000009Initial program 99.9%
Taylor expanded in x around 0 51.7%
if 0.00200000009 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0 74.9%
+-commutative74.9%
associate-+l+74.9%
unpow274.9%
unpow274.9%
times-frac67.6%
+-commutative67.6%
mul-1-neg67.6%
unsub-neg67.6%
Simplified67.6%
clear-num63.3%
frac-times66.7%
*-un-lft-identity66.7%
Applied egg-rr71.0%
*-un-lft-identity66.7%
frac-times63.3%
clear-num63.3%
div-inv63.3%
div-inv63.3%
swap-sqr72.3%
Applied egg-rr75.8%
associate-*l*80.9%
Simplified80.9%
Final simplification63.1%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) 0.10000000149011612) 0.5 (/ 1.0 (- (* 0.5 (* x (* x (/ (/ 1.0 s) s)))) (/ x s)))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= 0.10000000149011612f) {
tmp = 0.5f;
} else {
tmp = 1.0f / ((0.5f * (x * (x * ((1.0f / 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 ((-x / s) <= 0.10000000149011612e0) then
tmp = 0.5e0
else
tmp = 1.0e0 / ((0.5e0 * (x * (x * ((1.0e0 / s) / s)))) - (x / s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(-x) / s) <= Float32(0.10000000149011612)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(Float32(Float32(0.5) * Float32(x * Float32(x * Float32(Float32(Float32(1.0) / s) / s)))) - Float32(x / s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(0.10000000149011612)) tmp = single(0.5); else tmp = single(1.0) / ((single(0.5) * (x * (x * ((single(1.0) / s) / s)))) - (x / s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq 0.10000000149011612:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{0.5 \cdot \left(x \cdot \left(x \cdot \frac{\frac{1}{s}}{s}\right)\right) - \frac{x}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 0.100000001Initial program 99.9%
Taylor expanded in x around 0 51.5%
if 0.100000001 < (/.f32 (neg.f32 x) s) Initial program 99.9%
Taylor expanded in x around 0 75.0%
+-commutative75.0%
associate-+l+75.0%
unpow275.0%
unpow275.0%
times-frac66.2%
+-commutative66.2%
mul-1-neg66.2%
unsub-neg66.2%
Simplified66.2%
Taylor expanded in x around inf 66.1%
neg-mul-132.8%
distribute-neg-frac32.8%
Simplified66.1%
clear-num66.1%
frac-times69.7%
*-un-lft-identity69.7%
Applied egg-rr69.7%
*-un-lft-identity69.7%
frac-times66.1%
clear-num66.1%
div-inv66.1%
div-inv66.1%
swap-sqr75.9%
Applied egg-rr75.9%
associate-*l*81.2%
associate-*r/81.2%
*-rgt-identity81.2%
Simplified81.2%
Final simplification62.4%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) 2.0) 0.5 (/ 1.0 (* (/ x (* s s)) (/ x 2.0)))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= 2.0f) {
tmp = 0.5f;
} else {
tmp = 1.0f / ((x / (s * s)) * (x / 2.0f));
}
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 * s)) * (x / 2.0e0))
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(Float32(x / Float32(s * s)) * Float32(x / Float32(2.0)))); 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 * s)) * (x / single(2.0))); 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 \cdot s} \cdot \frac{x}{2}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 2Initial program 99.9%
Taylor expanded in x around 0 51.4%
if 2 < (/.f32 (neg.f32 x) s) Initial program 99.9%
Taylor expanded in x around 0 75.4%
+-commutative75.4%
associate-+l+75.4%
unpow275.4%
unpow275.4%
times-frac66.5%
+-commutative66.5%
mul-1-neg66.5%
unsub-neg66.5%
Simplified66.5%
Taylor expanded in x around inf 74.3%
unpow274.3%
unpow274.3%
times-frac64.8%
Simplified64.8%
associate-*r*64.8%
metadata-eval64.8%
times-frac64.8%
*-commutative64.8%
*-un-lft-identity64.8%
times-frac74.3%
*-commutative74.3%
clear-num75.4%
associate-*r*75.4%
times-frac80.8%
Applied egg-rr80.8%
Final simplification62.1%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) 2.0) 0.5 (* 2.0 (* (/ s x) (/ s x)))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= 2.0f) {
tmp = 0.5f;
} else {
tmp = 2.0f * ((s / x) * (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 = 2.0e0 * ((s / x) * (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(Float32(2.0) * Float32(Float32(s / x) * Float32(s / 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 = single(2.0) * ((s / x) * (s / x)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq 2:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\frac{s}{x} \cdot \frac{s}{x}\right)\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 2Initial program 99.9%
Taylor expanded in x around 0 51.4%
if 2 < (/.f32 (neg.f32 x) s) Initial program 99.9%
Taylor expanded in x around 0 75.4%
+-commutative75.4%
associate-+l+75.4%
unpow275.4%
unpow275.4%
times-frac66.5%
+-commutative66.5%
mul-1-neg66.5%
unsub-neg66.5%
Simplified66.5%
Taylor expanded in x around inf 74.3%
unpow274.3%
unpow274.3%
times-frac64.8%
Simplified64.8%
Final simplification56.3%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) 40000000.0) 0.5 (* (* s s) (/ (/ 2.0 x) x))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= 40000000.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) <= 40000000.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(40000000.0)) tmp = Float32(0.5); else tmp = Float32(Float32(s * s) * Float32(Float32(Float32(2.0) / x) / x)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(40000000.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 40000000:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\left(s \cdot s\right) \cdot \frac{\frac{2}{x}}{x}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 4e7Initial program 99.8%
Taylor expanded in x around 0 48.4%
if 4e7 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in x around 0 84.6%
+-commutative84.6%
associate-+l+84.6%
unpow284.6%
unpow284.6%
times-frac75.1%
+-commutative75.1%
mul-1-neg75.1%
unsub-neg75.1%
Simplified75.1%
Taylor expanded in x around inf 83.3%
associate-*r/83.3%
unpow283.3%
unpow283.3%
Simplified83.3%
Taylor expanded in s around 0 83.3%
unpow283.3%
associate-*r/83.3%
*-commutative83.3%
associate-*r/83.3%
unpow283.3%
associate-/r*83.3%
Simplified83.3%
Final simplification59.4%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) 2.0) 0.5 (* (/ (* s s) x) (/ 2.0 x))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= 2.0f) {
tmp = 0.5f;
} else {
tmp = ((s * s) / x) * (2.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 * s) / x) * (2.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(Float32(Float32(s * s) / x) * Float32(Float32(2.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 * s) / x) * (single(2.0) / 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 \cdot s}{x} \cdot \frac{2}{x}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 2Initial program 99.9%
Taylor expanded in x around 0 51.4%
if 2 < (/.f32 (neg.f32 x) s) Initial program 99.9%
Taylor expanded in x around 0 75.4%
+-commutative75.4%
associate-+l+75.4%
unpow275.4%
unpow275.4%
times-frac66.5%
+-commutative66.5%
mul-1-neg66.5%
unsub-neg66.5%
Simplified66.5%
Taylor expanded in x around inf 74.3%
associate-*r/74.3%
unpow274.3%
unpow274.3%
Simplified74.3%
*-commutative74.3%
times-frac79.7%
Applied egg-rr79.7%
Final simplification61.7%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) 2.0) 0.5 (/ (/ (* 2.0 (* s s)) x) x)))
float code(float x, float s) {
float tmp;
if ((-x / s) <= 2.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 ((-x / s) <= 2.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(-x) / s) <= Float32(2.0)) tmp = Float32(0.5); else tmp = Float32(Float32(Float32(Float32(2.0) * Float32(s * s)) / x) / 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 = ((single(2.0) * (s * s)) / x) / x; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq 2:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{2 \cdot \left(s \cdot s\right)}{x}}{x}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 2Initial program 99.9%
Taylor expanded in x around 0 51.4%
if 2 < (/.f32 (neg.f32 x) s) Initial program 99.9%
Taylor expanded in x around 0 75.4%
+-commutative75.4%
associate-+l+75.4%
unpow275.4%
unpow275.4%
times-frac66.5%
+-commutative66.5%
mul-1-neg66.5%
unsub-neg66.5%
Simplified66.5%
Taylor expanded in x around inf 74.3%
unpow274.3%
unpow274.3%
times-frac64.8%
Simplified64.8%
associate-*r*64.8%
metadata-eval64.8%
times-frac64.8%
*-commutative64.8%
*-un-lft-identity64.8%
times-frac74.3%
*-commutative74.3%
associate-/r*79.7%
associate-*r*79.7%
Applied egg-rr79.7%
Final simplification61.7%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) -5.0) 0.5 (/ 1.0 (- 2.0 (/ x s)))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= -5.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) <= (-5.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(-5.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(-5.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 -5:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -5Initial program 100.0%
Taylor expanded in x around 0 28.1%
if -5 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0 57.7%
mul-1-neg57.7%
unsub-neg57.7%
Simplified57.7%
Final simplification46.2%
(FPCore (x s) :precision binary32 (let* ((t_0 (/ (- x) s))) (if (<= t_0 2.0) 0.5 (/ 1.0 t_0))))
float code(float x, float s) {
float t_0 = -x / s;
float tmp;
if (t_0 <= 2.0f) {
tmp = 0.5f;
} else {
tmp = 1.0f / t_0;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: tmp
t_0 = -x / s
if (t_0 <= 2.0e0) then
tmp = 0.5e0
else
tmp = 1.0e0 / t_0
end if
code = tmp
end function
function code(x, s) t_0 = Float32(Float32(-x) / s) tmp = Float32(0.0) if (t_0 <= Float32(2.0)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / t_0); end return tmp end
function tmp_2 = code(x, s) t_0 = -x / s; tmp = single(0.0); if (t_0 <= single(2.0)) tmp = single(0.5); else tmp = single(1.0) / t_0; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-x}{s}\\
\mathbf{if}\;t_0 \leq 2:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 2Initial program 99.9%
Taylor expanded in x around 0 51.4%
if 2 < (/.f32 (neg.f32 x) s) Initial program 99.9%
Taylor expanded in x around 0 32.9%
mul-1-neg32.9%
unsub-neg32.9%
Simplified32.9%
Taylor expanded in x around inf 32.9%
neg-mul-132.9%
distribute-neg-frac32.9%
Simplified32.9%
Final simplification44.7%
(FPCore (x s) :precision binary32 (if (<= x -2.0000000233721948e-7) (* s (/ -1.0 x)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -2.0000000233721948e-7f) {
tmp = s * (-1.0f / 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 <= (-2.0000000233721948e-7)) then
tmp = s * ((-1.0e0) / x)
else
tmp = 0.5e0
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-2.0000000233721948e-7)) tmp = Float32(s * Float32(Float32(-1.0) / x)); else tmp = Float32(0.5); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-2.0000000233721948e-7)) tmp = s * (single(-1.0) / x); else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.0000000233721948 \cdot 10^{-7}:\\
\;\;\;\;s \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -2.00000002e-7Initial program 100.0%
Taylor expanded in x around 0 40.3%
mul-1-neg40.3%
unsub-neg40.3%
Simplified40.3%
Taylor expanded in x around inf 36.7%
mul-1-neg36.7%
Simplified36.7%
add-sqr-sqrt-0.0%
sqrt-prod45.2%
sqr-neg45.2%
sqrt-unprod36.5%
add-sqr-sqrt36.5%
clear-num39.5%
associate-/r/36.5%
add-sqr-sqrt36.5%
sqrt-unprod45.2%
sqr-neg45.2%
sqrt-prod-0.0%
add-sqr-sqrt36.7%
Applied egg-rr36.7%
if -2.00000002e-7 < x Initial program 99.8%
Taylor expanded in x around 0 46.3%
Final simplification43.6%
(FPCore (x s) :precision binary32 (if (<= x -2.0000000233721948e-7) (/ (- s) x) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -2.0000000233721948e-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 <= (-2.0000000233721948e-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(-2.0000000233721948e-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(-2.0000000233721948e-7)) tmp = -s / x; else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.0000000233721948 \cdot 10^{-7}:\\
\;\;\;\;\frac{-s}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -2.00000002e-7Initial program 100.0%
Taylor expanded in x around 0 40.3%
mul-1-neg40.3%
unsub-neg40.3%
Simplified40.3%
Taylor expanded in x around inf 36.7%
mul-1-neg36.7%
Simplified36.7%
if -2.00000002e-7 < x Initial program 99.8%
Taylor expanded in x around 0 46.3%
Final simplification43.6%
(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.9%
Taylor expanded in x around 0 35.1%
Final simplification35.1%
herbie shell --seed 2023279
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))