
(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(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
(if (<= (- x) -5.00000011871114e-34)
(/ (* s 0.5) s)
(if (<= (- x) 39999999311872.0)
(/ 1.0 (/ (- 4.0 (* x (/ (/ x s) s))) (+ (/ x s) 2.0)))
(* s (/ -1.0 (* s (- (/ x s) 2.0)))))))
float code(float x, float s) {
float tmp;
if (-x <= -5.00000011871114e-34f) {
tmp = (s * 0.5f) / s;
} else if (-x <= 39999999311872.0f) {
tmp = 1.0f / ((4.0f - (x * ((x / s) / s))) / ((x / s) + 2.0f));
} else {
tmp = s * (-1.0f / (s * ((x / s) - 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 <= (-5.00000011871114e-34)) then
tmp = (s * 0.5e0) / s
else if (-x <= 39999999311872.0e0) then
tmp = 1.0e0 / ((4.0e0 - (x * ((x / s) / s))) / ((x / s) + 2.0e0))
else
tmp = s * ((-1.0e0) / (s * ((x / s) - 2.0e0)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(-5.00000011871114e-34)) tmp = Float32(Float32(s * Float32(0.5)) / s); elseif (Float32(-x) <= Float32(39999999311872.0)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(4.0) - Float32(x * Float32(Float32(x / s) / s))) / Float32(Float32(x / s) + Float32(2.0)))); else tmp = Float32(s * Float32(Float32(-1.0) / Float32(s * Float32(Float32(x / s) - Float32(2.0))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-x <= single(-5.00000011871114e-34)) tmp = (s * single(0.5)) / s; elseif (-x <= single(39999999311872.0)) tmp = single(1.0) / ((single(4.0) - (x * ((x / s) / s))) / ((x / s) + single(2.0))); else tmp = s * (single(-1.0) / (s * ((x / s) - single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq -5.00000011871114 \cdot 10^{-34}:\\
\;\;\;\;\frac{s \cdot 0.5}{s}\\
\mathbf{elif}\;-x \leq 39999999311872:\\
\;\;\;\;\frac{1}{\frac{4 - x \cdot \frac{\frac{x}{s}}{s}}{\frac{x}{s} + 2}}\\
\mathbf{else}:\\
\;\;\;\;s \cdot \frac{-1}{s \cdot \left(\frac{x}{s} - 2\right)}\\
\end{array}
\end{array}
if (neg.f32 x) < -5.00000012e-34Initial program 100.0%
Taylor expanded in x around 0 19.8%
associate-*r/19.8%
Simplified19.8%
Taylor expanded in s around 0 19.8%
Taylor expanded in x around 0 34.9%
*-commutative34.9%
Simplified34.9%
if -5.00000012e-34 < (neg.f32 x) < 3.99999993e13Initial program 99.8%
Taylor expanded in x around 0 45.9%
neg-mul-145.9%
unsub-neg45.9%
Simplified45.9%
sub-neg45.9%
flip-+61.2%
metadata-eval61.2%
distribute-neg-frac261.2%
distribute-neg-frac261.2%
distribute-neg-frac261.2%
Applied egg-rr61.2%
clear-num61.2%
frac-times64.2%
*-un-lft-identity64.2%
add-sqr-sqrt-0.0%
sqrt-unprod66.7%
sqr-neg66.7%
sqrt-unprod63.8%
add-sqr-sqrt63.8%
add-sqr-sqrt-0.0%
sqrt-unprod67.0%
sqr-neg67.0%
sqrt-unprod64.2%
add-sqr-sqrt64.2%
Applied egg-rr64.2%
*-un-lft-identity64.2%
times-frac61.2%
clear-num61.2%
frac-times61.6%
sqr-neg61.6%
frac-times61.2%
associate-*l/61.2%
*-un-lft-identity61.2%
times-frac70.2%
add-sqr-sqrt-0.0%
sqrt-unprod66.7%
sqr-neg66.7%
sqrt-unprod69.9%
add-sqr-sqrt69.9%
add-sqr-sqrt-0.0%
sqrt-unprod67.0%
sqr-neg67.0%
sqrt-unprod70.2%
add-sqr-sqrt70.2%
Applied egg-rr70.2%
if 3.99999993e13 < (neg.f32 x) Initial program 100.0%
Taylor expanded in x around 0 76.9%
neg-mul-176.9%
unsub-neg76.9%
Simplified76.9%
Taylor expanded in s around 0 76.9%
*-commutative76.9%
Simplified76.9%
associate-/r/70.2%
Applied egg-rr70.2%
Taylor expanded in s around inf 76.9%
neg-mul-176.9%
sub-neg76.9%
Simplified76.9%
Final simplification54.0%
(FPCore (x s)
:precision binary32
(if (<= (- x) -5.00000011871114e-34)
(/ (* s 0.5) s)
(if (<= (- x) 39999999311872.0)
(/ -1.0 (/ (- (/ x (* s (/ s x))) 4.0) (+ (/ x s) 2.0)))
(* s (/ -1.0 (* s (- (/ x s) 2.0)))))))
float code(float x, float s) {
float tmp;
if (-x <= -5.00000011871114e-34f) {
tmp = (s * 0.5f) / s;
} else if (-x <= 39999999311872.0f) {
tmp = -1.0f / (((x / (s * (s / x))) - 4.0f) / ((x / s) + 2.0f));
} else {
tmp = s * (-1.0f / (s * ((x / s) - 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 <= (-5.00000011871114e-34)) then
tmp = (s * 0.5e0) / s
else if (-x <= 39999999311872.0e0) then
tmp = (-1.0e0) / (((x / (s * (s / x))) - 4.0e0) / ((x / s) + 2.0e0))
else
tmp = s * ((-1.0e0) / (s * ((x / s) - 2.0e0)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(-5.00000011871114e-34)) tmp = Float32(Float32(s * Float32(0.5)) / s); elseif (Float32(-x) <= Float32(39999999311872.0)) tmp = Float32(Float32(-1.0) / Float32(Float32(Float32(x / Float32(s * Float32(s / x))) - Float32(4.0)) / Float32(Float32(x / s) + Float32(2.0)))); else tmp = Float32(s * Float32(Float32(-1.0) / Float32(s * Float32(Float32(x / s) - Float32(2.0))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-x <= single(-5.00000011871114e-34)) tmp = (s * single(0.5)) / s; elseif (-x <= single(39999999311872.0)) tmp = single(-1.0) / (((x / (s * (s / x))) - single(4.0)) / ((x / s) + single(2.0))); else tmp = s * (single(-1.0) / (s * ((x / s) - single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq -5.00000011871114 \cdot 10^{-34}:\\
\;\;\;\;\frac{s \cdot 0.5}{s}\\
\mathbf{elif}\;-x \leq 39999999311872:\\
\;\;\;\;\frac{-1}{\frac{\frac{x}{s \cdot \frac{s}{x}} - 4}{\frac{x}{s} + 2}}\\
\mathbf{else}:\\
\;\;\;\;s \cdot \frac{-1}{s \cdot \left(\frac{x}{s} - 2\right)}\\
\end{array}
\end{array}
if (neg.f32 x) < -5.00000012e-34Initial program 100.0%
Taylor expanded in x around 0 19.8%
associate-*r/19.8%
Simplified19.8%
Taylor expanded in s around 0 19.8%
Taylor expanded in x around 0 34.9%
*-commutative34.9%
Simplified34.9%
if -5.00000012e-34 < (neg.f32 x) < 3.99999993e13Initial program 99.8%
Taylor expanded in x around 0 45.9%
neg-mul-145.9%
unsub-neg45.9%
Simplified45.9%
sub-neg45.9%
flip-+61.2%
metadata-eval61.2%
distribute-neg-frac261.2%
distribute-neg-frac261.2%
distribute-neg-frac261.2%
Applied egg-rr61.2%
clear-num61.2%
frac-times64.2%
*-un-lft-identity64.2%
add-sqr-sqrt-0.0%
sqrt-unprod66.7%
sqr-neg66.7%
sqrt-unprod63.8%
add-sqr-sqrt63.8%
add-sqr-sqrt-0.0%
sqrt-unprod67.0%
sqr-neg67.0%
sqrt-unprod64.2%
add-sqr-sqrt64.2%
Applied egg-rr64.2%
Taylor expanded in x around 0 64.2%
if 3.99999993e13 < (neg.f32 x) Initial program 100.0%
Taylor expanded in x around 0 76.9%
neg-mul-176.9%
unsub-neg76.9%
Simplified76.9%
Taylor expanded in s around 0 76.9%
*-commutative76.9%
Simplified76.9%
associate-/r/70.2%
Applied egg-rr70.2%
Taylor expanded in s around inf 76.9%
neg-mul-176.9%
sub-neg76.9%
Simplified76.9%
Final simplification51.9%
(FPCore (x s)
:precision binary32
(if (<= (- x) 2.9999999880125916e-12)
(/ (* s 0.5) s)
(if (<= (- x) 39999999311872.0)
(/ -1.0 (/ (- (* (/ x s) (/ x s)) 4.0) (/ x s)))
(* s (/ -1.0 (* s (- (/ x s) 2.0)))))))
float code(float x, float s) {
float tmp;
if (-x <= 2.9999999880125916e-12f) {
tmp = (s * 0.5f) / s;
} else if (-x <= 39999999311872.0f) {
tmp = -1.0f / ((((x / s) * (x / s)) - 4.0f) / (x / s));
} else {
tmp = s * (-1.0f / (s * ((x / s) - 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 <= 2.9999999880125916e-12) then
tmp = (s * 0.5e0) / s
else if (-x <= 39999999311872.0e0) then
tmp = (-1.0e0) / ((((x / s) * (x / s)) - 4.0e0) / (x / s))
else
tmp = s * ((-1.0e0) / (s * ((x / s) - 2.0e0)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(2.9999999880125916e-12)) tmp = Float32(Float32(s * Float32(0.5)) / s); elseif (Float32(-x) <= Float32(39999999311872.0)) tmp = Float32(Float32(-1.0) / Float32(Float32(Float32(Float32(x / s) * Float32(x / s)) - Float32(4.0)) / Float32(x / s))); else tmp = Float32(s * Float32(Float32(-1.0) / Float32(s * Float32(Float32(x / s) - Float32(2.0))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-x <= single(2.9999999880125916e-12)) tmp = (s * single(0.5)) / s; elseif (-x <= single(39999999311872.0)) tmp = single(-1.0) / ((((x / s) * (x / s)) - single(4.0)) / (x / s)); else tmp = s * (single(-1.0) / (s * ((x / s) - single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq 2.9999999880125916 \cdot 10^{-12}:\\
\;\;\;\;\frac{s \cdot 0.5}{s}\\
\mathbf{elif}\;-x \leq 39999999311872:\\
\;\;\;\;\frac{-1}{\frac{\frac{x}{s} \cdot \frac{x}{s} - 4}{\frac{x}{s}}}\\
\mathbf{else}:\\
\;\;\;\;s \cdot \frac{-1}{s \cdot \left(\frac{x}{s} - 2\right)}\\
\end{array}
\end{array}
if (neg.f32 x) < 2.99999999e-12Initial program 99.9%
Taylor expanded in x around 0 34.0%
associate-*r/34.0%
Simplified34.0%
Taylor expanded in s around 0 33.9%
Taylor expanded in x around 0 43.4%
*-commutative43.4%
Simplified43.4%
if 2.99999999e-12 < (neg.f32 x) < 3.99999993e13Initial program 99.8%
Taylor expanded in x around 0 14.6%
neg-mul-114.6%
unsub-neg14.6%
Simplified14.6%
sub-neg14.6%
flip-+49.2%
metadata-eval49.2%
distribute-neg-frac249.2%
distribute-neg-frac249.2%
distribute-neg-frac249.2%
Applied egg-rr49.2%
Taylor expanded in x around inf 47.5%
if 3.99999993e13 < (neg.f32 x) Initial program 100.0%
Taylor expanded in x around 0 76.9%
neg-mul-176.9%
unsub-neg76.9%
Simplified76.9%
Taylor expanded in s around 0 76.9%
*-commutative76.9%
Simplified76.9%
associate-/r/70.2%
Applied egg-rr70.2%
Taylor expanded in s around inf 76.9%
neg-mul-176.9%
sub-neg76.9%
Simplified76.9%
Final simplification49.2%
(FPCore (x s)
:precision binary32
(if (<= (- x) 2.9999999880125916e-12)
(/ (* s 0.5) s)
(if (<= (- x) 39999999311872.0)
(/ 1.0 (/ (- 4.0 (/ x (* s (/ s x)))) (/ x s)))
(* s (/ -1.0 (* s (- (/ x s) 2.0)))))))
float code(float x, float s) {
float tmp;
if (-x <= 2.9999999880125916e-12f) {
tmp = (s * 0.5f) / s;
} else if (-x <= 39999999311872.0f) {
tmp = 1.0f / ((4.0f - (x / (s * (s / x)))) / (x / s));
} else {
tmp = s * (-1.0f / (s * ((x / s) - 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 <= 2.9999999880125916e-12) then
tmp = (s * 0.5e0) / s
else if (-x <= 39999999311872.0e0) then
tmp = 1.0e0 / ((4.0e0 - (x / (s * (s / x)))) / (x / s))
else
tmp = s * ((-1.0e0) / (s * ((x / s) - 2.0e0)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(2.9999999880125916e-12)) tmp = Float32(Float32(s * Float32(0.5)) / s); elseif (Float32(-x) <= Float32(39999999311872.0)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(4.0) - Float32(x / Float32(s * Float32(s / x)))) / Float32(x / s))); else tmp = Float32(s * Float32(Float32(-1.0) / Float32(s * Float32(Float32(x / s) - Float32(2.0))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-x <= single(2.9999999880125916e-12)) tmp = (s * single(0.5)) / s; elseif (-x <= single(39999999311872.0)) tmp = single(1.0) / ((single(4.0) - (x / (s * (s / x)))) / (x / s)); else tmp = s * (single(-1.0) / (s * ((x / s) - single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq 2.9999999880125916 \cdot 10^{-12}:\\
\;\;\;\;\frac{s \cdot 0.5}{s}\\
\mathbf{elif}\;-x \leq 39999999311872:\\
\;\;\;\;\frac{1}{\frac{4 - \frac{x}{s \cdot \frac{s}{x}}}{\frac{x}{s}}}\\
\mathbf{else}:\\
\;\;\;\;s \cdot \frac{-1}{s \cdot \left(\frac{x}{s} - 2\right)}\\
\end{array}
\end{array}
if (neg.f32 x) < 2.99999999e-12Initial program 99.9%
Taylor expanded in x around 0 34.0%
associate-*r/34.0%
Simplified34.0%
Taylor expanded in s around 0 33.9%
Taylor expanded in x around 0 43.4%
*-commutative43.4%
Simplified43.4%
if 2.99999999e-12 < (neg.f32 x) < 3.99999993e13Initial program 99.8%
Taylor expanded in x around 0 14.6%
neg-mul-114.6%
unsub-neg14.6%
Simplified14.6%
sub-neg14.6%
flip-+49.2%
metadata-eval49.2%
distribute-neg-frac249.2%
distribute-neg-frac249.2%
distribute-neg-frac249.2%
Applied egg-rr49.2%
clear-num49.2%
frac-times49.2%
*-un-lft-identity49.2%
add-sqr-sqrt-0.0%
sqrt-unprod53.6%
sqr-neg53.6%
sqrt-unprod48.4%
add-sqr-sqrt48.4%
add-sqr-sqrt-0.0%
sqrt-unprod54.4%
sqr-neg54.4%
sqrt-unprod49.2%
add-sqr-sqrt49.2%
Applied egg-rr49.2%
Taylor expanded in x around inf 47.5%
if 3.99999993e13 < (neg.f32 x) Initial program 100.0%
Taylor expanded in x around 0 76.9%
neg-mul-176.9%
unsub-neg76.9%
Simplified76.9%
Taylor expanded in s around 0 76.9%
*-commutative76.9%
Simplified76.9%
associate-/r/70.2%
Applied egg-rr70.2%
Taylor expanded in s around inf 76.9%
neg-mul-176.9%
sub-neg76.9%
Simplified76.9%
Final simplification49.2%
(FPCore (x s) :precision binary32 (if (<= (- x) -5.00000011871114e-34) (/ (* s 0.5) s) (/ 1.0 (+ 2.0 (* x (/ -1.0 s))))))
float code(float x, float s) {
float tmp;
if (-x <= -5.00000011871114e-34f) {
tmp = (s * 0.5f) / s;
} else {
tmp = 1.0f / (2.0f + (x * (-1.0f / 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.00000011871114e-34)) then
tmp = (s * 0.5e0) / s
else
tmp = 1.0e0 / (2.0e0 + (x * ((-1.0e0) / s)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(-5.00000011871114e-34)) tmp = Float32(Float32(s * Float32(0.5)) / s); else tmp = Float32(Float32(1.0) / Float32(Float32(2.0) + Float32(x * Float32(Float32(-1.0) / s)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-x <= single(-5.00000011871114e-34)) tmp = (s * single(0.5)) / s; else tmp = single(1.0) / (single(2.0) + (x * (single(-1.0) / s))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq -5.00000011871114 \cdot 10^{-34}:\\
\;\;\;\;\frac{s \cdot 0.5}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 + x \cdot \frac{-1}{s}}\\
\end{array}
\end{array}
if (neg.f32 x) < -5.00000012e-34Initial program 100.0%
Taylor expanded in x around 0 19.8%
associate-*r/19.8%
Simplified19.8%
Taylor expanded in s around 0 19.8%
Taylor expanded in x around 0 34.9%
*-commutative34.9%
Simplified34.9%
if -5.00000012e-34 < (neg.f32 x) Initial program 99.8%
Taylor expanded in x around 0 55.3%
neg-mul-155.3%
unsub-neg55.3%
Simplified55.3%
clear-num55.3%
associate-/r/55.3%
Applied egg-rr55.3%
Final simplification45.4%
(FPCore (x s) :precision binary32 (if (<= (- x) -5.00000011871114e-34) (/ (* s 0.5) s) (/ 1.0 (- 2.0 (/ x s)))))
float code(float x, float s) {
float tmp;
if (-x <= -5.00000011871114e-34f) {
tmp = (s * 0.5f) / s;
} 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.00000011871114e-34)) then
tmp = (s * 0.5e0) / s
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.00000011871114e-34)) tmp = Float32(Float32(s * Float32(0.5)) / s); 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.00000011871114e-34)) tmp = (s * single(0.5)) / s; 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.00000011871114 \cdot 10^{-34}:\\
\;\;\;\;\frac{s \cdot 0.5}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
\end{array}
\end{array}
if (neg.f32 x) < -5.00000012e-34Initial program 100.0%
Taylor expanded in x around 0 19.8%
associate-*r/19.8%
Simplified19.8%
Taylor expanded in s around 0 19.8%
Taylor expanded in x around 0 34.9%
*-commutative34.9%
Simplified34.9%
if -5.00000012e-34 < (neg.f32 x) Initial program 99.8%
Taylor expanded in x around 0 55.3%
neg-mul-155.3%
unsub-neg55.3%
Simplified55.3%
(FPCore (x s) :precision binary32 (if (<= (- x) 2.9999999880125916e-12) (/ (* s 0.5) s) (/ -1.0 (/ x s))))
float code(float x, float s) {
float tmp;
if (-x <= 2.9999999880125916e-12f) {
tmp = (s * 0.5f) / s;
} 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 <= 2.9999999880125916e-12) then
tmp = (s * 0.5e0) / s
else
tmp = (-1.0e0) / (x / s)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(2.9999999880125916e-12)) tmp = Float32(Float32(s * Float32(0.5)) / s); 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 <= single(2.9999999880125916e-12)) tmp = (s * single(0.5)) / s; else tmp = single(-1.0) / (x / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq 2.9999999880125916 \cdot 10^{-12}:\\
\;\;\;\;\frac{s \cdot 0.5}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{x}{s}}\\
\end{array}
\end{array}
if (neg.f32 x) < 2.99999999e-12Initial program 99.9%
Taylor expanded in x around 0 34.0%
associate-*r/34.0%
Simplified34.0%
Taylor expanded in s around 0 33.9%
Taylor expanded in x around 0 43.4%
*-commutative43.4%
Simplified43.4%
if 2.99999999e-12 < (neg.f32 x) Initial program 99.9%
Taylor expanded in x around 0 47.8%
neg-mul-147.8%
unsub-neg47.8%
Simplified47.8%
Taylor expanded in x around inf 47.3%
mul-1-neg47.3%
distribute-frac-neg247.3%
Simplified47.3%
Final simplification44.5%
(FPCore (x s) :precision binary32 (if (<= (- x) 0.00019999999494757503) (/ (* s 0.5) s) (/ 1.0 (/ x s))))
float code(float x, float s) {
float tmp;
if (-x <= 0.00019999999494757503f) {
tmp = (s * 0.5f) / s;
} 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 <= 0.00019999999494757503e0) then
tmp = (s * 0.5e0) / s
else
tmp = 1.0e0 / (x / s)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(0.00019999999494757503)) tmp = Float32(Float32(s * Float32(0.5)) / s); 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 <= single(0.00019999999494757503)) tmp = (s * single(0.5)) / s; else tmp = single(1.0) / (x / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq 0.00019999999494757503:\\
\;\;\;\;\frac{s \cdot 0.5}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x}{s}}\\
\end{array}
\end{array}
if (neg.f32 x) < 1.99999995e-4Initial program 99.9%
Taylor expanded in x around 0 32.4%
associate-*r/32.4%
Simplified32.4%
Taylor expanded in s around 0 32.3%
Taylor expanded in x around 0 41.2%
*-commutative41.2%
Simplified41.2%
if 1.99999995e-4 < (neg.f32 x) Initial program 100.0%
Taylor expanded in x around 0 54.9%
neg-mul-154.9%
unsub-neg54.9%
Simplified54.9%
Taylor expanded in x around inf 50.1%
associate-*r/50.1%
neg-mul-150.1%
Simplified50.1%
clear-num54.9%
inv-pow54.9%
add-sqr-sqrt-0.0%
sqrt-unprod64.3%
sqr-neg64.3%
sqrt-unprod54.9%
add-sqr-sqrt54.9%
Applied egg-rr54.9%
unpow-154.9%
Simplified54.9%
(FPCore (x s) :precision binary32 (if (<= x -0.0005000000237487257) (/ 1.0 (/ x s)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -0.0005000000237487257f) {
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 <= (-0.0005000000237487257e0)) 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(-0.0005000000237487257)) 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(-0.0005000000237487257)) 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 -0.0005000000237487257:\\
\;\;\;\;\frac{1}{\frac{x}{s}}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -5.00000024e-4Initial program 100.0%
Taylor expanded in x around 0 54.9%
neg-mul-154.9%
unsub-neg54.9%
Simplified54.9%
Taylor expanded in x around inf 50.1%
associate-*r/50.1%
neg-mul-150.1%
Simplified50.1%
clear-num54.9%
inv-pow54.9%
add-sqr-sqrt-0.0%
sqrt-unprod64.3%
sqr-neg64.3%
sqrt-unprod54.9%
add-sqr-sqrt54.9%
Applied egg-rr54.9%
unpow-154.9%
Simplified54.9%
if -5.00000024e-4 < x Initial program 99.9%
Taylor expanded in x around 0 41.2%
(FPCore (x s) :precision binary32 (if (<= x -2.9999999880125916e-12) (* s (/ -1.0 x)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -2.9999999880125916e-12f) {
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.9999999880125916e-12)) 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.9999999880125916e-12)) 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.9999999880125916e-12)) 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.9999999880125916 \cdot 10^{-12}:\\
\;\;\;\;s \cdot \frac{-1}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -2.99999999e-12Initial program 99.9%
Taylor expanded in x around 0 47.8%
neg-mul-147.8%
unsub-neg47.8%
Simplified47.8%
Taylor expanded in s around 0 47.8%
*-commutative47.8%
Simplified47.8%
associate-/r/43.9%
Applied egg-rr43.9%
Taylor expanded in s around 0 43.3%
if -2.99999999e-12 < x Initial program 99.9%
Taylor expanded in x around 0 43.4%
Final simplification43.4%
(FPCore (x s) :precision binary32 (if (<= x -2.9999999880125916e-12) (/ s (- x)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -2.9999999880125916e-12f) {
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.9999999880125916e-12)) 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.9999999880125916e-12)) 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(-2.9999999880125916e-12)) tmp = s / -x; else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.9999999880125916 \cdot 10^{-12}:\\
\;\;\;\;\frac{s}{-x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -2.99999999e-12Initial program 99.9%
Taylor expanded in x around 0 47.8%
neg-mul-147.8%
unsub-neg47.8%
Simplified47.8%
Taylor expanded in x around inf 43.3%
associate-*r/43.3%
neg-mul-143.3%
Simplified43.3%
if -2.99999999e-12 < x Initial program 99.9%
Taylor expanded in x around 0 43.4%
Final simplification43.4%
(FPCore (x s) :precision binary32 (if (<= x -0.0005000000237487257) (/ s x) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -0.0005000000237487257f) {
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 <= (-0.0005000000237487257e0)) 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(-0.0005000000237487257)) 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(-0.0005000000237487257)) tmp = s / x; else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0005000000237487257:\\
\;\;\;\;\frac{s}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -5.00000024e-4Initial program 100.0%
Taylor expanded in x around 0 54.9%
neg-mul-154.9%
unsub-neg54.9%
Simplified54.9%
Taylor expanded in x around inf 50.1%
associate-*r/50.1%
neg-mul-150.1%
Simplified50.1%
add-sqr-sqrt-0.0%
sqrt-unprod61.3%
sqr-neg61.3%
sqrt-unprod50.1%
add-sqr-sqrt50.1%
*-un-lft-identity50.1%
Applied egg-rr50.1%
*-lft-identity50.1%
Simplified50.1%
if -5.00000024e-4 < x Initial program 99.9%
Taylor expanded in x around 0 41.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.9%
Taylor expanded in x around 0 32.8%
herbie shell --seed 2024151
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))