
(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 10 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(x / Float32(-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
(let* ((t_0 (* x (/ 2.0 x))))
(if (<= (- x) 2.0000000390829628e-24)
0.5
(if (<= (- x) 6.000000212225132e-7)
(/ 1.0 (* x (* (- (* s 2.0) x) (* (/ 1.0 x) (/ 1.0 s)))))
(if (<= (- x) 19999999655936.0)
(/ 1.0 (/ (- (* t_0 t_0) (* (/ x s) (/ x s))) (- t_0 (/ x s))))
(* x (/ 1.0 (* x (- 2.0 (/ x s))))))))))
float code(float x, float s) {
float t_0 = x * (2.0f / x);
float tmp;
if (-x <= 2.0000000390829628e-24f) {
tmp = 0.5f;
} else if (-x <= 6.000000212225132e-7f) {
tmp = 1.0f / (x * (((s * 2.0f) - x) * ((1.0f / x) * (1.0f / s))));
} else if (-x <= 19999999655936.0f) {
tmp = 1.0f / (((t_0 * t_0) - ((x / s) * (x / s))) / (t_0 - (x / s)));
} else {
tmp = x * (1.0f / (x * (2.0f - (x / s))));
}
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 * (2.0e0 / x)
if (-x <= 2.0000000390829628e-24) then
tmp = 0.5e0
else if (-x <= 6.000000212225132e-7) then
tmp = 1.0e0 / (x * (((s * 2.0e0) - x) * ((1.0e0 / x) * (1.0e0 / s))))
else if (-x <= 19999999655936.0e0) then
tmp = 1.0e0 / (((t_0 * t_0) - ((x / s) * (x / s))) / (t_0 - (x / s)))
else
tmp = x * (1.0e0 / (x * (2.0e0 - (x / s))))
end if
code = tmp
end function
function code(x, s) t_0 = Float32(x * Float32(Float32(2.0) / x)) tmp = Float32(0.0) if (Float32(-x) <= Float32(2.0000000390829628e-24)) tmp = Float32(0.5); elseif (Float32(-x) <= Float32(6.000000212225132e-7)) tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(Float32(s * Float32(2.0)) - x) * Float32(Float32(Float32(1.0) / x) * Float32(Float32(1.0) / s))))); elseif (Float32(-x) <= Float32(19999999655936.0)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(t_0 * t_0) - Float32(Float32(x / s) * Float32(x / s))) / Float32(t_0 - Float32(x / s)))); else tmp = Float32(x * Float32(Float32(1.0) / Float32(x * Float32(Float32(2.0) - Float32(x / s))))); end return tmp end
function tmp_2 = code(x, s) t_0 = x * (single(2.0) / x); tmp = single(0.0); if (-x <= single(2.0000000390829628e-24)) tmp = single(0.5); elseif (-x <= single(6.000000212225132e-7)) tmp = single(1.0) / (x * (((s * single(2.0)) - x) * ((single(1.0) / x) * (single(1.0) / s)))); elseif (-x <= single(19999999655936.0)) tmp = single(1.0) / (((t_0 * t_0) - ((x / s) * (x / s))) / (t_0 - (x / s))); else tmp = x * (single(1.0) / (x * (single(2.0) - (x / s)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{2}{x}\\
\mathbf{if}\;-x \leq 2.0000000390829628 \cdot 10^{-24}:\\
\;\;\;\;0.5\\
\mathbf{elif}\;-x \leq 6.000000212225132 \cdot 10^{-7}:\\
\;\;\;\;\frac{1}{x \cdot \left(\left(s \cdot 2 - x\right) \cdot \left(\frac{1}{x} \cdot \frac{1}{s}\right)\right)}\\
\mathbf{elif}\;-x \leq 19999999655936:\\
\;\;\;\;\frac{1}{\frac{t\_0 \cdot t\_0 - \frac{x}{s} \cdot \frac{x}{s}}{t\_0 - \frac{x}{s}}}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{1}{x \cdot \left(2 - \frac{x}{s}\right)}\\
\end{array}
\end{array}
if (neg.f32 x) < 2.00000004e-24Initial program 99.9%
Taylor expanded in x around 0 50.7%
if 2.00000004e-24 < (neg.f32 x) < 6.0000002e-7Initial program 99.1%
Taylor expanded in x around 0 35.5%
neg-mul-135.5%
unsub-neg35.5%
Simplified35.5%
Taylor expanded in x around inf 35.5%
sub-neg35.5%
associate-*r/35.5%
metadata-eval35.5%
distribute-neg-frac35.5%
metadata-eval35.5%
Simplified35.5%
frac-add60.1%
associate-/r*35.5%
*-commutative35.5%
neg-mul-135.5%
fma-define35.5%
fma-neg35.5%
Applied egg-rr35.5%
div-inv35.5%
div-inv35.5%
associate-*l*69.1%
*-commutative69.1%
Applied egg-rr69.1%
if 6.0000002e-7 < (neg.f32 x) < 1.99999997e13Initial program 100.0%
Taylor expanded in x around 0 13.8%
neg-mul-113.8%
unsub-neg13.8%
Simplified13.8%
Taylor expanded in x around inf 13.8%
sub-neg13.8%
associate-*r/13.8%
metadata-eval13.8%
distribute-neg-frac13.8%
metadata-eval13.8%
Simplified13.8%
distribute-lft-in13.8%
frac-2neg13.8%
metadata-eval13.8%
div-inv13.8%
flip-+52.6%
Applied egg-rr52.6%
if 1.99999997e13 < (neg.f32 x) Initial program 100.0%
Taylor expanded in x around 0 68.9%
neg-mul-168.9%
unsub-neg68.9%
Simplified68.9%
Taylor expanded in x around inf 68.9%
sub-neg68.9%
associate-*r/68.9%
metadata-eval68.9%
distribute-neg-frac68.9%
metadata-eval68.9%
Simplified68.9%
Taylor expanded in x around 0 68.9%
mul-1-neg68.9%
sub-neg68.9%
Simplified68.9%
associate-*r/97.8%
associate-/r/97.8%
Applied egg-rr97.8%
Final simplification60.6%
(FPCore (x s)
:precision binary32
(if (<= (- x) 2.0000000390829628e-24)
0.5
(if (<= (- x) 0.0044999998062849045)
(/ 1.0 (* x (* (- (* s 2.0) x) (* (/ 1.0 x) (/ 1.0 s)))))
(* x (/ 1.0 (* x (- 2.0 (/ x s))))))))
float code(float x, float s) {
float tmp;
if (-x <= 2.0000000390829628e-24f) {
tmp = 0.5f;
} else if (-x <= 0.0044999998062849045f) {
tmp = 1.0f / (x * (((s * 2.0f) - x) * ((1.0f / x) * (1.0f / s))));
} else {
tmp = x * (1.0f / (x * (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 <= 2.0000000390829628e-24) then
tmp = 0.5e0
else if (-x <= 0.0044999998062849045e0) then
tmp = 1.0e0 / (x * (((s * 2.0e0) - x) * ((1.0e0 / x) * (1.0e0 / s))))
else
tmp = x * (1.0e0 / (x * (2.0e0 - (x / s))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(2.0000000390829628e-24)) tmp = Float32(0.5); elseif (Float32(-x) <= Float32(0.0044999998062849045)) tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(Float32(s * Float32(2.0)) - x) * Float32(Float32(Float32(1.0) / x) * Float32(Float32(1.0) / s))))); else tmp = Float32(x * Float32(Float32(1.0) / Float32(x * Float32(Float32(2.0) - Float32(x / s))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-x <= single(2.0000000390829628e-24)) tmp = single(0.5); elseif (-x <= single(0.0044999998062849045)) tmp = single(1.0) / (x * (((s * single(2.0)) - x) * ((single(1.0) / x) * (single(1.0) / s)))); else tmp = x * (single(1.0) / (x * (single(2.0) - (x / s)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq 2.0000000390829628 \cdot 10^{-24}:\\
\;\;\;\;0.5\\
\mathbf{elif}\;-x \leq 0.0044999998062849045:\\
\;\;\;\;\frac{1}{x \cdot \left(\left(s \cdot 2 - x\right) \cdot \left(\frac{1}{x} \cdot \frac{1}{s}\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{1}{x \cdot \left(2 - \frac{x}{s}\right)}\\
\end{array}
\end{array}
if (neg.f32 x) < 2.00000004e-24Initial program 99.9%
Taylor expanded in x around 0 50.7%
if 2.00000004e-24 < (neg.f32 x) < 0.00449999981Initial program 99.3%
Taylor expanded in x around 0 31.7%
neg-mul-131.7%
unsub-neg31.7%
Simplified31.7%
Taylor expanded in x around inf 31.7%
sub-neg31.7%
associate-*r/31.7%
metadata-eval31.7%
distribute-neg-frac31.7%
metadata-eval31.7%
Simplified31.7%
frac-add52.7%
associate-/r*31.7%
*-commutative31.7%
neg-mul-131.7%
fma-define31.7%
fma-neg31.7%
Applied egg-rr31.7%
div-inv31.7%
div-inv31.7%
associate-*l*62.9%
*-commutative62.9%
Applied egg-rr62.9%
if 0.00449999981 < (neg.f32 x) Initial program 100.0%
Taylor expanded in x around 0 45.9%
neg-mul-145.9%
unsub-neg45.9%
Simplified45.9%
Taylor expanded in x around inf 45.9%
sub-neg45.9%
associate-*r/45.9%
metadata-eval45.9%
distribute-neg-frac45.9%
metadata-eval45.9%
Simplified45.9%
Taylor expanded in x around 0 45.9%
mul-1-neg45.9%
sub-neg45.9%
Simplified45.9%
associate-*r/68.4%
associate-/r/68.4%
Applied egg-rr68.4%
Final simplification57.3%
(FPCore (x s)
:precision binary32
(if (<= (- x) 2.0000000390829628e-24)
0.5
(if (<= (- x) 0.0044999998062849045)
(/ 1.0 (* x (* (- (* s 2.0) x) (/ (/ 1.0 x) s))))
(* x (/ 1.0 (* x (- 2.0 (/ x s))))))))
float code(float x, float s) {
float tmp;
if (-x <= 2.0000000390829628e-24f) {
tmp = 0.5f;
} else if (-x <= 0.0044999998062849045f) {
tmp = 1.0f / (x * (((s * 2.0f) - x) * ((1.0f / x) / s)));
} else {
tmp = x * (1.0f / (x * (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 <= 2.0000000390829628e-24) then
tmp = 0.5e0
else if (-x <= 0.0044999998062849045e0) then
tmp = 1.0e0 / (x * (((s * 2.0e0) - x) * ((1.0e0 / x) / s)))
else
tmp = x * (1.0e0 / (x * (2.0e0 - (x / s))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(2.0000000390829628e-24)) tmp = Float32(0.5); elseif (Float32(-x) <= Float32(0.0044999998062849045)) tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(Float32(s * Float32(2.0)) - x) * Float32(Float32(Float32(1.0) / x) / s)))); else tmp = Float32(x * Float32(Float32(1.0) / Float32(x * Float32(Float32(2.0) - Float32(x / s))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-x <= single(2.0000000390829628e-24)) tmp = single(0.5); elseif (-x <= single(0.0044999998062849045)) tmp = single(1.0) / (x * (((s * single(2.0)) - x) * ((single(1.0) / x) / s))); else tmp = x * (single(1.0) / (x * (single(2.0) - (x / s)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq 2.0000000390829628 \cdot 10^{-24}:\\
\;\;\;\;0.5\\
\mathbf{elif}\;-x \leq 0.0044999998062849045:\\
\;\;\;\;\frac{1}{x \cdot \left(\left(s \cdot 2 - x\right) \cdot \frac{\frac{1}{x}}{s}\right)}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{1}{x \cdot \left(2 - \frac{x}{s}\right)}\\
\end{array}
\end{array}
if (neg.f32 x) < 2.00000004e-24Initial program 99.9%
Taylor expanded in x around 0 50.7%
if 2.00000004e-24 < (neg.f32 x) < 0.00449999981Initial program 99.3%
Taylor expanded in x around 0 31.7%
neg-mul-131.7%
unsub-neg31.7%
Simplified31.7%
Taylor expanded in x around inf 31.7%
sub-neg31.7%
associate-*r/31.7%
metadata-eval31.7%
distribute-neg-frac31.7%
metadata-eval31.7%
Simplified31.7%
frac-add52.7%
associate-/r*31.7%
*-commutative31.7%
neg-mul-131.7%
fma-define31.7%
fma-neg31.7%
Applied egg-rr31.7%
div-inv31.7%
associate-/l*62.9%
*-commutative62.9%
Applied egg-rr62.9%
if 0.00449999981 < (neg.f32 x) Initial program 100.0%
Taylor expanded in x around 0 45.9%
neg-mul-145.9%
unsub-neg45.9%
Simplified45.9%
Taylor expanded in x around inf 45.9%
sub-neg45.9%
associate-*r/45.9%
metadata-eval45.9%
distribute-neg-frac45.9%
metadata-eval45.9%
Simplified45.9%
Taylor expanded in x around 0 45.9%
mul-1-neg45.9%
sub-neg45.9%
Simplified45.9%
associate-*r/68.4%
associate-/r/68.4%
Applied egg-rr68.4%
Final simplification57.3%
(FPCore (x s)
:precision binary32
(if (<= (- x) 2.0000000390829628e-24)
0.5
(if (<= (- x) 0.03999999910593033)
(/ 1.0 (* x (* (- (* s 2.0) x) (/ 1.0 (* x s)))))
(* x (/ 1.0 (* x (- 2.0 (/ x s))))))))
float code(float x, float s) {
float tmp;
if (-x <= 2.0000000390829628e-24f) {
tmp = 0.5f;
} else if (-x <= 0.03999999910593033f) {
tmp = 1.0f / (x * (((s * 2.0f) - x) * (1.0f / (x * s))));
} else {
tmp = x * (1.0f / (x * (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 <= 2.0000000390829628e-24) then
tmp = 0.5e0
else if (-x <= 0.03999999910593033e0) then
tmp = 1.0e0 / (x * (((s * 2.0e0) - x) * (1.0e0 / (x * s))))
else
tmp = x * (1.0e0 / (x * (2.0e0 - (x / s))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(2.0000000390829628e-24)) tmp = Float32(0.5); elseif (Float32(-x) <= Float32(0.03999999910593033)) tmp = Float32(Float32(1.0) / Float32(x * Float32(Float32(Float32(s * Float32(2.0)) - x) * Float32(Float32(1.0) / Float32(x * s))))); else tmp = Float32(x * Float32(Float32(1.0) / Float32(x * Float32(Float32(2.0) - Float32(x / s))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-x <= single(2.0000000390829628e-24)) tmp = single(0.5); elseif (-x <= single(0.03999999910593033)) tmp = single(1.0) / (x * (((s * single(2.0)) - x) * (single(1.0) / (x * s)))); else tmp = x * (single(1.0) / (x * (single(2.0) - (x / s)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq 2.0000000390829628 \cdot 10^{-24}:\\
\;\;\;\;0.5\\
\mathbf{elif}\;-x \leq 0.03999999910593033:\\
\;\;\;\;\frac{1}{x \cdot \left(\left(s \cdot 2 - x\right) \cdot \frac{1}{x \cdot s}\right)}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{1}{x \cdot \left(2 - \frac{x}{s}\right)}\\
\end{array}
\end{array}
if (neg.f32 x) < 2.00000004e-24Initial program 99.9%
Taylor expanded in x around 0 50.7%
if 2.00000004e-24 < (neg.f32 x) < 0.0399999991Initial program 99.3%
Taylor expanded in x around 0 29.8%
neg-mul-129.8%
unsub-neg29.8%
Simplified29.8%
Taylor expanded in x around inf 29.8%
sub-neg29.8%
associate-*r/29.8%
metadata-eval29.8%
distribute-neg-frac29.8%
metadata-eval29.8%
Simplified29.8%
frac-add49.2%
div-inv58.4%
*-commutative58.4%
neg-mul-158.4%
fma-define58.4%
fma-neg58.4%
Applied egg-rr58.4%
if 0.0399999991 < (neg.f32 x) Initial program 100.0%
Taylor expanded in x around 0 47.5%
neg-mul-147.5%
unsub-neg47.5%
Simplified47.5%
Taylor expanded in x around inf 47.5%
sub-neg47.5%
associate-*r/47.5%
metadata-eval47.5%
distribute-neg-frac47.5%
metadata-eval47.5%
Simplified47.5%
Taylor expanded in x around 0 47.5%
mul-1-neg47.5%
sub-neg47.5%
Simplified47.5%
associate-*r/71.0%
associate-/r/71.0%
Applied egg-rr71.0%
Final simplification57.2%
(FPCore (x s) :precision binary32 (if (<= (- x) -5.000000097707407e-26) 0.5 (* x (/ 1.0 (* x (- 2.0 (/ x s)))))))
float code(float x, float s) {
float tmp;
if (-x <= -5.000000097707407e-26f) {
tmp = 0.5f;
} else {
tmp = x * (1.0f / (x * (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 <= (-5.000000097707407e-26)) then
tmp = 0.5e0
else
tmp = x * (1.0e0 / (x * (2.0e0 - (x / s))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(-5.000000097707407e-26)) tmp = Float32(0.5); else tmp = Float32(x * Float32(Float32(1.0) / Float32(x * Float32(Float32(2.0) - Float32(x / s))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-x <= single(-5.000000097707407e-26)) tmp = single(0.5); else tmp = x * (single(1.0) / (x * (single(2.0) - (x / s)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq -5.000000097707407 \cdot 10^{-26}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{1}{x \cdot \left(2 - \frac{x}{s}\right)}\\
\end{array}
\end{array}
if (neg.f32 x) < -5.0000001e-26Initial program 99.9%
Taylor expanded in x around 0 35.1%
if -5.0000001e-26 < (neg.f32 x) Initial program 99.8%
Taylor expanded in x around 0 56.7%
neg-mul-156.7%
unsub-neg56.7%
Simplified56.7%
Taylor expanded in x around inf 56.5%
sub-neg56.5%
associate-*r/56.5%
metadata-eval56.5%
distribute-neg-frac56.5%
metadata-eval56.5%
Simplified56.5%
Taylor expanded in x around 0 56.5%
mul-1-neg56.5%
sub-neg56.5%
Simplified56.5%
associate-*r/67.2%
associate-/r/67.1%
Applied egg-rr67.1%
Final simplification54.0%
(FPCore (x s) :precision binary32 (if (<= (- x) -5.000000097707407e-26) 0.5 (/ 1.0 (- 2.0 (/ x s)))))
float code(float x, float s) {
float tmp;
if (-x <= -5.000000097707407e-26f) {
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 <= (-5.000000097707407e-26)) 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(-x) <= Float32(-5.000000097707407e-26)) 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 <= single(-5.000000097707407e-26)) 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}\;-x \leq -5.000000097707407 \cdot 10^{-26}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
\end{array}
\end{array}
if (neg.f32 x) < -5.0000001e-26Initial program 99.9%
Taylor expanded in x around 0 35.1%
if -5.0000001e-26 < (neg.f32 x) Initial program 99.8%
Taylor expanded in x around 0 56.7%
neg-mul-156.7%
unsub-neg56.7%
Simplified56.7%
(FPCore (x s) :precision binary32 (if (<= x -4.999999987376214e-7) (/ 1.0 (/ x s)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -4.999999987376214e-7f) {
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.999999987376214e-7)) 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.999999987376214e-7)) 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.999999987376214e-7)) 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.999999987376214 \cdot 10^{-7}:\\
\;\;\;\;\frac{1}{\frac{x}{s}}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -4.99999999e-7Initial program 100.0%
Taylor expanded in x around 0 43.1%
neg-mul-143.1%
unsub-neg43.1%
Simplified43.1%
Taylor expanded in x around inf 41.5%
associate-*r/41.5%
neg-mul-141.5%
Simplified41.5%
clear-num43.1%
inv-pow43.1%
add-sqr-sqrt-0.0%
sqrt-unprod54.1%
sqr-neg54.1%
sqrt-unprod43.1%
add-sqr-sqrt43.1%
Applied egg-rr43.1%
unpow-143.1%
Simplified43.1%
if -4.99999999e-7 < x Initial program 99.8%
Taylor expanded in x around 0 47.9%
(FPCore (x s) :precision binary32 (if (<= x -4.999999987376214e-7) (/ s x) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -4.999999987376214e-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.999999987376214e-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.999999987376214e-7)) tmp = 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.999999987376214e-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.999999987376214 \cdot 10^{-7}:\\
\;\;\;\;\frac{s}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -4.99999999e-7Initial program 100.0%
Taylor expanded in x around 0 43.1%
neg-mul-143.1%
unsub-neg43.1%
Simplified43.1%
Taylor expanded in x around inf 41.5%
associate-*r/41.5%
neg-mul-141.5%
Simplified41.5%
add-sqr-sqrt-0.0%
sqrt-unprod53.2%
sqr-neg53.2%
sqrt-unprod41.5%
add-sqr-sqrt41.5%
*-un-lft-identity41.5%
Applied egg-rr41.5%
*-lft-identity41.5%
Simplified41.5%
if -4.99999999e-7 < x Initial program 99.8%
Taylor expanded in x around 0 47.9%
(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.4%
herbie shell --seed 2024141
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))