
(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 (/ 1.0 (* (/ s x) -1.5))) (pow (cbrt (exp -1.0)) (/ x s))))))
float code(float x, float s) {
return 1.0f / (1.0f + (expf((1.0f / ((s / x) * -1.5f))) * powf(cbrtf(expf(-1.0f)), (x / s))));
}
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(exp(Float32(Float32(1.0) / Float32(Float32(s / x) * Float32(-1.5)))) * (cbrt(exp(Float32(-1.0))) ^ Float32(x / s))))) end
\begin{array}{l}
\\
\frac{1}{1 + e^{\frac{1}{\frac{s}{x} \cdot -1.5}} \cdot {\left(\sqrt[3]{e^{-1}}\right)}^{\left(\frac{x}{s}\right)}}
\end{array}
Initial program 99.8%
distribute-frac-neg99.8%
exp-neg99.7%
add-sqr-sqrt45.7%
sqrt-unprod54.1%
sqr-neg54.1%
sqrt-unprod9.9%
add-sqr-sqrt22.7%
add-cube-cbrt22.7%
pow322.7%
pow-flip22.7%
add-sqr-sqrt9.9%
sqrt-unprod54.1%
sqr-neg54.1%
sqrt-unprod45.7%
add-sqr-sqrt99.7%
metadata-eval99.7%
Applied egg-rr99.7%
pow1/399.7%
pow-pow99.7%
metadata-eval99.7%
pow-exp99.8%
*-commutative99.8%
pow-exp99.7%
add-cube-cbrt99.6%
unpow-prod-down99.6%
cbrt-unprod99.7%
prod-exp99.7%
metadata-eval99.7%
Applied egg-rr99.7%
pow1/399.7%
pow-exp99.7%
metadata-eval99.7%
exp-prod99.8%
associate-*r/99.8%
Applied egg-rr99.8%
clear-num99.7%
inv-pow99.7%
Applied egg-rr99.7%
unpow-199.7%
*-rgt-identity99.7%
*-commutative99.7%
times-frac99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x s)
:precision binary32
(/
1.0
(+
1.0
(*
(exp (/ (* x -0.6666666666666666) s))
(exp (* (/ x s) -0.3333333333333333))))))
float code(float x, float s) {
return 1.0f / (1.0f + (expf(((x * -0.6666666666666666f) / s)) * expf(((x / s) * -0.3333333333333333f))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (1.0e0 + (exp(((x * (-0.6666666666666666e0)) / s)) * exp(((x / s) * (-0.3333333333333333e0)))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(exp(Float32(Float32(x * Float32(-0.6666666666666666)) / s)) * exp(Float32(Float32(x / s) * Float32(-0.3333333333333333)))))) end
function tmp = code(x, s) tmp = single(1.0) / (single(1.0) + (exp(((x * single(-0.6666666666666666)) / s)) * exp(((x / s) * single(-0.3333333333333333))))); end
\begin{array}{l}
\\
\frac{1}{1 + e^{\frac{x \cdot -0.6666666666666666}{s}} \cdot e^{\frac{x}{s} \cdot -0.3333333333333333}}
\end{array}
Initial program 99.8%
distribute-frac-neg99.8%
exp-neg99.7%
add-sqr-sqrt45.7%
sqrt-unprod54.1%
sqr-neg54.1%
sqrt-unprod9.9%
add-sqr-sqrt22.7%
add-cube-cbrt22.7%
pow322.7%
pow-flip22.7%
add-sqr-sqrt9.9%
sqrt-unprod54.1%
sqr-neg54.1%
sqrt-unprod45.7%
add-sqr-sqrt99.7%
metadata-eval99.7%
Applied egg-rr99.7%
pow1/399.7%
pow-pow99.7%
metadata-eval99.7%
pow-exp99.8%
*-commutative99.8%
pow-exp99.7%
add-cube-cbrt99.6%
unpow-prod-down99.6%
cbrt-unprod99.7%
prod-exp99.7%
metadata-eval99.7%
Applied egg-rr99.7%
pow1/399.7%
pow-exp99.7%
metadata-eval99.7%
exp-prod99.8%
associate-*r/99.8%
Applied egg-rr99.8%
pow1/399.8%
pow-exp99.7%
metadata-eval99.7%
exp-prod99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(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
(let* ((t_0 (/ s (* x -0.3333333333333333))) (t_1 (/ (- x) s)))
(if (<= t_1 0.20000000298023224)
(/ 1.0 (+ 1.0 (/ 1.0 (+ 1.0 (/ x s)))))
(if (<= t_1 200000000753664.0)
(/
1.0
(+
1.0
(-
1.0
(*
x
(/
(- (* s -0.3333333333333333) (* s 0.6666666666666666))
(* s (- s)))))))
(if (<= t_1 9.999999616903162e+35)
(/ 1.0 (/ (- 4.0 (* (/ x s) (/ x s))) (+ (/ x s) 2.0)))
(/
1.0
(+
1.0
(+ 1.0 (/ (+ s (* (* x -0.6666666666666666) t_0)) (* s t_0))))))))))
float code(float x, float s) {
float t_0 = s / (x * -0.3333333333333333f);
float t_1 = -x / s;
float tmp;
if (t_1 <= 0.20000000298023224f) {
tmp = 1.0f / (1.0f + (1.0f / (1.0f + (x / s))));
} else if (t_1 <= 200000000753664.0f) {
tmp = 1.0f / (1.0f + (1.0f - (x * (((s * -0.3333333333333333f) - (s * 0.6666666666666666f)) / (s * -s)))));
} else if (t_1 <= 9.999999616903162e+35f) {
tmp = 1.0f / ((4.0f - ((x / s) * (x / s))) / ((x / s) + 2.0f));
} else {
tmp = 1.0f / (1.0f + (1.0f + ((s + ((x * -0.6666666666666666f) * t_0)) / (s * 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) :: t_1
real(4) :: tmp
t_0 = s / (x * (-0.3333333333333333e0))
t_1 = -x / s
if (t_1 <= 0.20000000298023224e0) then
tmp = 1.0e0 / (1.0e0 + (1.0e0 / (1.0e0 + (x / s))))
else if (t_1 <= 200000000753664.0e0) then
tmp = 1.0e0 / (1.0e0 + (1.0e0 - (x * (((s * (-0.3333333333333333e0)) - (s * 0.6666666666666666e0)) / (s * -s)))))
else if (t_1 <= 9.999999616903162e+35) then
tmp = 1.0e0 / ((4.0e0 - ((x / s) * (x / s))) / ((x / s) + 2.0e0))
else
tmp = 1.0e0 / (1.0e0 + (1.0e0 + ((s + ((x * (-0.6666666666666666e0)) * t_0)) / (s * t_0))))
end if
code = tmp
end function
function code(x, s) t_0 = Float32(s / Float32(x * Float32(-0.3333333333333333))) t_1 = Float32(Float32(-x) / s) tmp = Float32(0.0) if (t_1 <= Float32(0.20000000298023224)) tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(x / s))))); elseif (t_1 <= Float32(200000000753664.0)) tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) - Float32(x * Float32(Float32(Float32(s * Float32(-0.3333333333333333)) - Float32(s * Float32(0.6666666666666666))) / Float32(s * Float32(-s))))))); elseif (t_1 <= Float32(9.999999616903162e+35)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(4.0) - Float32(Float32(x / s) * Float32(x / s))) / Float32(Float32(x / s) + Float32(2.0)))); else tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) + Float32(Float32(s + Float32(Float32(x * Float32(-0.6666666666666666)) * t_0)) / Float32(s * t_0))))); end return tmp end
function tmp_2 = code(x, s) t_0 = s / (x * single(-0.3333333333333333)); t_1 = -x / s; tmp = single(0.0); if (t_1 <= single(0.20000000298023224)) tmp = single(1.0) / (single(1.0) + (single(1.0) / (single(1.0) + (x / s)))); elseif (t_1 <= single(200000000753664.0)) tmp = single(1.0) / (single(1.0) + (single(1.0) - (x * (((s * single(-0.3333333333333333)) - (s * single(0.6666666666666666))) / (s * -s))))); elseif (t_1 <= single(9.999999616903162e+35)) tmp = single(1.0) / ((single(4.0) - ((x / s) * (x / s))) / ((x / s) + single(2.0))); else tmp = single(1.0) / (single(1.0) + (single(1.0) + ((s + ((x * single(-0.6666666666666666)) * t_0)) / (s * t_0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{s}{x \cdot -0.3333333333333333}\\
t_1 := \frac{-x}{s}\\
\mathbf{if}\;t_1 \leq 0.20000000298023224:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + \frac{x}{s}}}\\
\mathbf{elif}\;t_1 \leq 200000000753664:\\
\;\;\;\;\frac{1}{1 + \left(1 - x \cdot \frac{s \cdot -0.3333333333333333 - s \cdot 0.6666666666666666}{s \cdot \left(-s\right)}\right)}\\
\mathbf{elif}\;t_1 \leq 9.999999616903162 \cdot 10^{+35}:\\
\;\;\;\;\frac{1}{\frac{4 - \frac{x}{s} \cdot \frac{x}{s}}{\frac{x}{s} + 2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + \left(1 + \frac{s + \left(x \cdot -0.6666666666666666\right) \cdot t_0}{s \cdot t_0}\right)}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 0.200000003Initial program 100.0%
distribute-frac-neg100.0%
exp-neg99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 97.2%
if 0.200000003 < (/.f32 (neg.f32 x) s) < 2.00000001e14Initial program 98.7%
distribute-frac-neg98.7%
exp-neg98.7%
add-sqr-sqrt-0.0%
sqrt-unprod7.2%
sqr-neg7.2%
sqrt-unprod7.2%
add-sqr-sqrt7.2%
add-cube-cbrt7.2%
pow37.2%
pow-flip7.2%
add-sqr-sqrt7.2%
sqrt-unprod7.2%
sqr-neg7.2%
sqrt-unprod-0.0%
add-sqr-sqrt98.8%
metadata-eval98.8%
Applied egg-rr98.8%
Taylor expanded in s around inf 8.3%
+-commutative8.3%
*-commutative8.3%
fma-def8.3%
associate-*r/8.3%
Applied egg-rr8.3%
Simplified8.3%
frac-2neg8.3%
frac-add42.2%
metadata-eval42.2%
Applied egg-rr42.2%
if 2.00000001e14 < (/.f32 (neg.f32 x) s) < 9.99999962e35Initial program 100.0%
Taylor expanded in x around 0 12.5%
mul-1-neg12.5%
unsub-neg12.5%
Simplified12.5%
sub-neg12.5%
flip-+88.0%
metadata-eval88.0%
distribute-neg-frac88.0%
distribute-neg-frac88.0%
distribute-neg-frac88.0%
Applied egg-rr88.0%
if 9.99999962e35 < (/.f32 (neg.f32 x) s) Initial program 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
add-sqr-sqrt-0.0%
sqrt-unprod6.3%
sqr-neg6.3%
sqrt-unprod6.3%
add-sqr-sqrt6.3%
add-cube-cbrt6.3%
pow36.3%
pow-flip6.3%
add-sqr-sqrt6.3%
sqrt-unprod6.3%
sqr-neg6.3%
sqrt-unprod-0.0%
add-sqr-sqrt100.0%
metadata-eval100.0%
Applied egg-rr100.0%
Taylor expanded in s around inf 92.7%
associate-*r/92.7%
clear-num92.7%
Applied egg-rr92.7%
associate-/r*92.7%
Simplified92.7%
+-commutative92.7%
associate-*r/92.7%
frac-add100.0%
*-un-lft-identity100.0%
associate-/l/100.0%
associate-/l/100.0%
Applied egg-rr100.0%
Final simplification86.8%
(FPCore (x s)
:precision binary32
(let* ((t_0 (/ (- x) s)))
(if (<= t_0 0.20000000298023224)
(/ 1.0 (+ 1.0 (/ 1.0 (+ 1.0 (/ x s)))))
(if (<= t_0 499999992153374700.0)
(/
1.0
(+
1.0
(+
1.0
(*
x
(/ (+ s (* -0.6666666666666666 (* s -3.0))) (* s (* s -3.0)))))))
(if (<= t_0 INFINITY)
(/ 1.0 (/ (- 4.0 (* (/ x s) (/ x s))) (+ (/ x s) 2.0)))
(/ 1.0 t_0))))))
float code(float x, float s) {
float t_0 = -x / s;
float tmp;
if (t_0 <= 0.20000000298023224f) {
tmp = 1.0f / (1.0f + (1.0f / (1.0f + (x / s))));
} else if (t_0 <= 499999992153374700.0f) {
tmp = 1.0f / (1.0f + (1.0f + (x * ((s + (-0.6666666666666666f * (s * -3.0f))) / (s * (s * -3.0f))))));
} else if (t_0 <= ((float) INFINITY)) {
tmp = 1.0f / ((4.0f - ((x / s) * (x / s))) / ((x / s) + 2.0f));
} else {
tmp = 1.0f / t_0;
}
return tmp;
}
function code(x, s) t_0 = Float32(Float32(-x) / s) tmp = Float32(0.0) if (t_0 <= Float32(0.20000000298023224)) tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(x / s))))); elseif (t_0 <= Float32(499999992153374700.0)) tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) + Float32(x * Float32(Float32(s + Float32(Float32(-0.6666666666666666) * Float32(s * Float32(-3.0)))) / Float32(s * Float32(s * Float32(-3.0)))))))); elseif (t_0 <= Float32(Inf)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(4.0) - Float32(Float32(x / s) * Float32(x / s))) / Float32(Float32(x / s) + Float32(2.0)))); 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(0.20000000298023224)) tmp = single(1.0) / (single(1.0) + (single(1.0) / (single(1.0) + (x / s)))); elseif (t_0 <= single(499999992153374700.0)) tmp = single(1.0) / (single(1.0) + (single(1.0) + (x * ((s + (single(-0.6666666666666666) * (s * single(-3.0)))) / (s * (s * single(-3.0))))))); elseif (t_0 <= single(Inf)) tmp = single(1.0) / ((single(4.0) - ((x / s) * (x / s))) / ((x / s) + single(2.0))); 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 0.20000000298023224:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + \frac{x}{s}}}\\
\mathbf{elif}\;t_0 \leq 499999992153374700:\\
\;\;\;\;\frac{1}{1 + \left(1 + x \cdot \frac{s + -0.6666666666666666 \cdot \left(s \cdot -3\right)}{s \cdot \left(s \cdot -3\right)}\right)}\\
\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;\frac{1}{\frac{4 - \frac{x}{s} \cdot \frac{x}{s}}{\frac{x}{s} + 2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 0.200000003Initial program 100.0%
distribute-frac-neg100.0%
exp-neg99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 97.2%
if 0.200000003 < (/.f32 (neg.f32 x) s) < 4.99999992e17Initial program 98.8%
distribute-frac-neg98.8%
exp-neg98.8%
add-sqr-sqrt-0.0%
sqrt-unprod7.1%
sqr-neg7.1%
sqrt-unprod7.1%
add-sqr-sqrt7.1%
add-cube-cbrt7.1%
pow37.1%
pow-flip7.1%
add-sqr-sqrt7.1%
sqrt-unprod7.1%
sqr-neg7.1%
sqrt-unprod-0.0%
add-sqr-sqrt98.9%
metadata-eval98.9%
Applied egg-rr98.9%
Taylor expanded in s around inf 8.4%
+-commutative8.4%
*-commutative8.4%
fma-def8.4%
associate-*r/8.4%
Applied egg-rr8.4%
Simplified8.4%
+-commutative8.4%
clear-num8.4%
frac-add39.4%
*-un-lft-identity39.4%
div-inv39.4%
metadata-eval39.4%
div-inv39.4%
metadata-eval39.4%
Applied egg-rr39.4%
if 4.99999992e17 < (/.f32 (neg.f32 x) s) < +inf.0Initial program 100.0%
Taylor expanded in x around 0 55.1%
mul-1-neg55.1%
unsub-neg55.1%
Simplified55.1%
sub-neg55.1%
flip-+51.5%
metadata-eval51.5%
distribute-neg-frac51.5%
distribute-neg-frac51.5%
distribute-neg-frac51.5%
Applied egg-rr51.5%
if +inf.0 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0 37.4%
mul-1-neg37.4%
unsub-neg37.4%
Simplified37.4%
Taylor expanded in x around inf 19.8%
mul-1-neg19.8%
distribute-frac-neg19.8%
Simplified19.8%
Final simplification73.5%
(FPCore (x s)
:precision binary32
(let* ((t_0 (/ (- x) s)))
(if (<= t_0 0.20000000298023224)
(/ 1.0 (+ 1.0 (/ 1.0 (+ 1.0 (/ x s)))))
(if (<= t_0 200000000753664.0)
(/
1.0
(+
1.0
(-
1.0
(*
x
(/
(- (* s -0.3333333333333333) (* s 0.6666666666666666))
(* s (- s)))))))
(if (<= t_0 INFINITY)
(/ 1.0 (/ (- 4.0 (* (/ x s) (/ x s))) (+ (/ x s) 2.0)))
(/ 1.0 t_0))))))
float code(float x, float s) {
float t_0 = -x / s;
float tmp;
if (t_0 <= 0.20000000298023224f) {
tmp = 1.0f / (1.0f + (1.0f / (1.0f + (x / s))));
} else if (t_0 <= 200000000753664.0f) {
tmp = 1.0f / (1.0f + (1.0f - (x * (((s * -0.3333333333333333f) - (s * 0.6666666666666666f)) / (s * -s)))));
} else if (t_0 <= ((float) INFINITY)) {
tmp = 1.0f / ((4.0f - ((x / s) * (x / s))) / ((x / s) + 2.0f));
} else {
tmp = 1.0f / t_0;
}
return tmp;
}
function code(x, s) t_0 = Float32(Float32(-x) / s) tmp = Float32(0.0) if (t_0 <= Float32(0.20000000298023224)) tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(x / s))))); elseif (t_0 <= Float32(200000000753664.0)) tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) - Float32(x * Float32(Float32(Float32(s * Float32(-0.3333333333333333)) - Float32(s * Float32(0.6666666666666666))) / Float32(s * Float32(-s))))))); elseif (t_0 <= Float32(Inf)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(4.0) - Float32(Float32(x / s) * Float32(x / s))) / Float32(Float32(x / s) + Float32(2.0)))); 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(0.20000000298023224)) tmp = single(1.0) / (single(1.0) + (single(1.0) / (single(1.0) + (x / s)))); elseif (t_0 <= single(200000000753664.0)) tmp = single(1.0) / (single(1.0) + (single(1.0) - (x * (((s * single(-0.3333333333333333)) - (s * single(0.6666666666666666))) / (s * -s))))); elseif (t_0 <= single(Inf)) tmp = single(1.0) / ((single(4.0) - ((x / s) * (x / s))) / ((x / s) + single(2.0))); 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 0.20000000298023224:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + \frac{x}{s}}}\\
\mathbf{elif}\;t_0 \leq 200000000753664:\\
\;\;\;\;\frac{1}{1 + \left(1 - x \cdot \frac{s \cdot -0.3333333333333333 - s \cdot 0.6666666666666666}{s \cdot \left(-s\right)}\right)}\\
\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;\frac{1}{\frac{4 - \frac{x}{s} \cdot \frac{x}{s}}{\frac{x}{s} + 2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 0.200000003Initial program 100.0%
distribute-frac-neg100.0%
exp-neg99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 97.2%
if 0.200000003 < (/.f32 (neg.f32 x) s) < 2.00000001e14Initial program 98.7%
distribute-frac-neg98.7%
exp-neg98.7%
add-sqr-sqrt-0.0%
sqrt-unprod7.2%
sqr-neg7.2%
sqrt-unprod7.2%
add-sqr-sqrt7.2%
add-cube-cbrt7.2%
pow37.2%
pow-flip7.2%
add-sqr-sqrt7.2%
sqrt-unprod7.2%
sqr-neg7.2%
sqrt-unprod-0.0%
add-sqr-sqrt98.8%
metadata-eval98.8%
Applied egg-rr98.8%
Taylor expanded in s around inf 8.3%
+-commutative8.3%
*-commutative8.3%
fma-def8.3%
associate-*r/8.3%
Applied egg-rr8.3%
Simplified8.3%
frac-2neg8.3%
frac-add42.2%
metadata-eval42.2%
Applied egg-rr42.2%
if 2.00000001e14 < (/.f32 (neg.f32 x) s) < +inf.0Initial program 100.0%
Taylor expanded in x around 0 52.6%
mul-1-neg52.6%
unsub-neg52.6%
Simplified52.6%
sub-neg52.6%
flip-+49.3%
metadata-eval49.3%
distribute-neg-frac49.3%
distribute-neg-frac49.3%
distribute-neg-frac49.3%
Applied egg-rr49.3%
if +inf.0 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0 37.4%
mul-1-neg37.4%
unsub-neg37.4%
Simplified37.4%
Taylor expanded in x around inf 19.8%
mul-1-neg19.8%
distribute-frac-neg19.8%
Simplified19.8%
Final simplification73.5%
(FPCore (x s)
:precision binary32
(let* ((t_0 (/ (- x) s)))
(if (<= t_0 -0.019999999552965164)
(/ 1.0 (+ 1.0 (/ 1.0 (+ 1.0 (/ x s)))))
(if (<= t_0 INFINITY)
(/ 1.0 (/ (- 4.0 (* (/ x s) (/ x s))) (+ (/ x s) 2.0)))
(/ 1.0 t_0)))))
float code(float x, float s) {
float t_0 = -x / s;
float tmp;
if (t_0 <= -0.019999999552965164f) {
tmp = 1.0f / (1.0f + (1.0f / (1.0f + (x / s))));
} else if (t_0 <= ((float) INFINITY)) {
tmp = 1.0f / ((4.0f - ((x / s) * (x / s))) / ((x / s) + 2.0f));
} else {
tmp = 1.0f / t_0;
}
return tmp;
}
function code(x, s) t_0 = Float32(Float32(-x) / s) tmp = Float32(0.0) if (t_0 <= Float32(-0.019999999552965164)) tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(x / s))))); elseif (t_0 <= Float32(Inf)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(4.0) - Float32(Float32(x / s) * Float32(x / s))) / Float32(Float32(x / s) + Float32(2.0)))); 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(-0.019999999552965164)) tmp = single(1.0) / (single(1.0) + (single(1.0) / (single(1.0) + (x / s)))); elseif (t_0 <= single(Inf)) tmp = single(1.0) / ((single(4.0) - ((x / s) * (x / s))) / ((x / s) + single(2.0))); 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 -0.019999999552965164:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + \frac{x}{s}}}\\
\mathbf{elif}\;t_0 \leq \infty:\\
\;\;\;\;\frac{1}{\frac{4 - \frac{x}{s} \cdot \frac{x}{s}}{\frac{x}{s} + 2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -0.0199999996Initial program 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 97.0%
if -0.0199999996 < (/.f32 (neg.f32 x) s) < +inf.0Initial program 99.6%
Taylor expanded in x around 0 53.9%
mul-1-neg53.9%
unsub-neg53.9%
Simplified53.9%
sub-neg53.9%
flip-+52.4%
metadata-eval52.4%
distribute-neg-frac52.4%
distribute-neg-frac52.4%
distribute-neg-frac52.4%
Applied egg-rr52.4%
if +inf.0 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0 37.4%
mul-1-neg37.4%
unsub-neg37.4%
Simplified37.4%
Taylor expanded in x around inf 19.8%
mul-1-neg19.8%
distribute-frac-neg19.8%
Simplified19.8%
Final simplification67.7%
(FPCore (x s)
:precision binary32
(if (<= (/ (- x) s) -0.019999999552965164)
(/ 1.0 (+ 1.0 (/ 1.0 (+ 1.0 (/ x s)))))
(/
1.0
(+
1.0
(+ 1.0 (* x (+ (/ -0.6666666666666666 s) (/ -0.3333333333333333 s))))))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= -0.019999999552965164f) {
tmp = 1.0f / (1.0f + (1.0f / (1.0f + (x / s))));
} else {
tmp = 1.0f / (1.0f + (1.0f + (x * ((-0.6666666666666666f / s) + (-0.3333333333333333f / 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.019999999552965164e0)) then
tmp = 1.0e0 / (1.0e0 + (1.0e0 / (1.0e0 + (x / s))))
else
tmp = 1.0e0 / (1.0e0 + (1.0e0 + (x * (((-0.6666666666666666e0) / s) + ((-0.3333333333333333e0) / s)))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(-x) / s) <= Float32(-0.019999999552965164)) tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(x / s))))); else tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) + Float32(x * Float32(Float32(Float32(-0.6666666666666666) / s) + Float32(Float32(-0.3333333333333333) / s)))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(-0.019999999552965164)) tmp = single(1.0) / (single(1.0) + (single(1.0) / (single(1.0) + (x / s)))); else tmp = single(1.0) / (single(1.0) + (single(1.0) + (x * ((single(-0.6666666666666666) / s) + (single(-0.3333333333333333) / s))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq -0.019999999552965164:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + \frac{x}{s}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + \left(1 + x \cdot \left(\frac{-0.6666666666666666}{s} + \frac{-0.3333333333333333}{s}\right)\right)}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -0.0199999996Initial program 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 97.0%
if -0.0199999996 < (/.f32 (neg.f32 x) s) Initial program 99.6%
distribute-frac-neg99.6%
exp-neg99.6%
add-sqr-sqrt17.2%
sqrt-unprod31.6%
sqr-neg31.6%
sqrt-unprod15.1%
add-sqr-sqrt31.1%
add-cube-cbrt31.1%
pow331.1%
pow-flip31.1%
add-sqr-sqrt15.1%
sqrt-unprod31.7%
sqr-neg31.7%
sqrt-unprod17.2%
add-sqr-sqrt99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in s around inf 54.0%
+-commutative54.0%
*-commutative54.0%
fma-def54.0%
associate-*r/54.0%
Applied egg-rr54.0%
Simplified54.0%
Final simplification68.7%
(FPCore (x s)
:precision binary32
(let* ((t_0 (/ (- x) s)))
(if (<= t_0 -200.0)
(- 1.0 (/ s x))
(if (<= t_0 1.0) (+ 0.5 (/ (* x 0.25) s)) (/ 1.0 t_0)))))
float code(float x, float s) {
float t_0 = -x / s;
float tmp;
if (t_0 <= -200.0f) {
tmp = 1.0f - (s / x);
} else if (t_0 <= 1.0f) {
tmp = 0.5f + ((x * 0.25f) / s);
} 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 <= (-200.0e0)) then
tmp = 1.0e0 - (s / x)
else if (t_0 <= 1.0e0) then
tmp = 0.5e0 + ((x * 0.25e0) / s)
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(-200.0)) tmp = Float32(Float32(1.0) - Float32(s / x)); elseif (t_0 <= Float32(1.0)) tmp = Float32(Float32(0.5) + Float32(Float32(x * Float32(0.25)) / s)); 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(-200.0)) tmp = single(1.0) - (s / x); elseif (t_0 <= single(1.0)) tmp = single(0.5) + ((x * single(0.25)) / s); 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 -200:\\
\;\;\;\;1 - \frac{s}{x}\\
\mathbf{elif}\;t_0 \leq 1:\\
\;\;\;\;0.5 + \frac{x \cdot 0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -200Initial program 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 97.3%
Taylor expanded in x around inf 97.2%
mul-1-neg97.2%
unsub-neg97.2%
Simplified97.2%
if -200 < (/.f32 (neg.f32 x) s) < 1Initial program 99.9%
Taylor expanded in x around 0 98.0%
associate-*r/98.0%
Simplified98.0%
if 1 < (/.f32 (neg.f32 x) s) Initial program 99.5%
Taylor expanded in x around 0 36.4%
mul-1-neg36.4%
unsub-neg36.4%
Simplified36.4%
Taylor expanded in x around inf 36.4%
mul-1-neg36.4%
distribute-frac-neg36.4%
Simplified36.4%
Final simplification69.1%
(FPCore (x s)
:precision binary32
(let* ((t_0 (/ (- x) s)))
(if (<= t_0 -200.0)
(/ 1.0 (+ 1.0 (/ s x)))
(if (<= t_0 1.0) (+ 0.5 (/ (* x 0.25) s)) (/ 1.0 t_0)))))
float code(float x, float s) {
float t_0 = -x / s;
float tmp;
if (t_0 <= -200.0f) {
tmp = 1.0f / (1.0f + (s / x));
} else if (t_0 <= 1.0f) {
tmp = 0.5f + ((x * 0.25f) / s);
} 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 <= (-200.0e0)) then
tmp = 1.0e0 / (1.0e0 + (s / x))
else if (t_0 <= 1.0e0) then
tmp = 0.5e0 + ((x * 0.25e0) / s)
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(-200.0)) tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(s / x))); elseif (t_0 <= Float32(1.0)) tmp = Float32(Float32(0.5) + Float32(Float32(x * Float32(0.25)) / s)); 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(-200.0)) tmp = single(1.0) / (single(1.0) + (s / x)); elseif (t_0 <= single(1.0)) tmp = single(0.5) + ((x * single(0.25)) / s); 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 -200:\\
\;\;\;\;\frac{1}{1 + \frac{s}{x}}\\
\mathbf{elif}\;t_0 \leq 1:\\
\;\;\;\;0.5 + \frac{x \cdot 0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -200Initial program 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 97.3%
Taylor expanded in x around inf 97.3%
if -200 < (/.f32 (neg.f32 x) s) < 1Initial program 99.9%
Taylor expanded in x around 0 98.0%
associate-*r/98.0%
Simplified98.0%
if 1 < (/.f32 (neg.f32 x) s) Initial program 99.5%
Taylor expanded in x around 0 36.4%
mul-1-neg36.4%
unsub-neg36.4%
Simplified36.4%
Taylor expanded in x around inf 36.4%
mul-1-neg36.4%
distribute-frac-neg36.4%
Simplified36.4%
Final simplification69.1%
(FPCore (x s) :precision binary32 (let* ((t_0 (/ (- x) s))) (if (<= t_0 -200.0) (- 1.0 (/ s x)) (if (<= t_0 1.0) 0.5 (/ 1.0 t_0)))))
float code(float x, float s) {
float t_0 = -x / s;
float tmp;
if (t_0 <= -200.0f) {
tmp = 1.0f - (s / x);
} else if (t_0 <= 1.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 <= (-200.0e0)) then
tmp = 1.0e0 - (s / x)
else if (t_0 <= 1.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(-200.0)) tmp = Float32(Float32(1.0) - Float32(s / x)); elseif (t_0 <= Float32(1.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(-200.0)) tmp = single(1.0) - (s / x); elseif (t_0 <= single(1.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 -200:\\
\;\;\;\;1 - \frac{s}{x}\\
\mathbf{elif}\;t_0 \leq 1:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t_0}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -200Initial program 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 97.3%
Taylor expanded in x around inf 97.2%
mul-1-neg97.2%
unsub-neg97.2%
Simplified97.2%
if -200 < (/.f32 (neg.f32 x) s) < 1Initial program 99.9%
Taylor expanded in x around 0 91.0%
if 1 < (/.f32 (neg.f32 x) s) Initial program 99.5%
Taylor expanded in x around 0 36.4%
mul-1-neg36.4%
unsub-neg36.4%
Simplified36.4%
Taylor expanded in x around inf 36.4%
mul-1-neg36.4%
distribute-frac-neg36.4%
Simplified36.4%
Final simplification67.7%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) -200.0) (/ 1.0 (+ 1.0 (/ s x))) (/ 1.0 (+ 1.0 (+ 1.0 (* x (/ -1.0 s)))))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= -200.0f) {
tmp = 1.0f / (1.0f + (s / x));
} else {
tmp = 1.0f / (1.0f + (1.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 / s) <= (-200.0e0)) then
tmp = 1.0e0 / (1.0e0 + (s / x))
else
tmp = 1.0e0 / (1.0e0 + (1.0e0 + (x * ((-1.0e0) / 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(Float32(1.0) / Float32(Float32(1.0) + Float32(s / x))); else tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) + Float32(x * Float32(Float32(-1.0) / s))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(-200.0)) tmp = single(1.0) / (single(1.0) + (s / x)); else tmp = single(1.0) / (single(1.0) + (single(1.0) + (x * (single(-1.0) / s)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq -200:\\
\;\;\;\;\frac{1}{1 + \frac{s}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + \left(1 + x \cdot \frac{-1}{s}\right)}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -200Initial program 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 97.3%
Taylor expanded in x around inf 97.3%
if -200 < (/.f32 (neg.f32 x) s) Initial program 99.6%
distribute-frac-neg99.6%
exp-neg99.6%
add-sqr-sqrt17.7%
sqrt-unprod31.7%
sqr-neg31.7%
sqrt-unprod15.0%
add-sqr-sqrt31.2%
add-cube-cbrt31.2%
pow331.2%
pow-flip31.2%
add-sqr-sqrt15.0%
sqrt-unprod31.8%
sqr-neg31.8%
sqrt-unprod17.7%
add-sqr-sqrt99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in s around inf 54.0%
+-commutative54.0%
*-commutative54.0%
fma-def54.0%
associate-*r/54.0%
Applied egg-rr54.0%
Simplified54.0%
Taylor expanded in s around 0 54.0%
Final simplification68.7%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) -0.019999999552965164) (/ 1.0 (+ 1.0 (/ 1.0 (+ 1.0 (/ x s))))) (/ 1.0 (+ 1.0 (+ 1.0 (* x (/ -1.0 s)))))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= -0.019999999552965164f) {
tmp = 1.0f / (1.0f + (1.0f / (1.0f + (x / s))));
} else {
tmp = 1.0f / (1.0f + (1.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 / s) <= (-0.019999999552965164e0)) then
tmp = 1.0e0 / (1.0e0 + (1.0e0 / (1.0e0 + (x / s))))
else
tmp = 1.0e0 / (1.0e0 + (1.0e0 + (x * ((-1.0e0) / s))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(Float32(-x) / s) <= Float32(-0.019999999552965164)) tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(x / s))))); else tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(Float32(1.0) + Float32(x * Float32(Float32(-1.0) / s))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(-0.019999999552965164)) tmp = single(1.0) / (single(1.0) + (single(1.0) / (single(1.0) + (x / s)))); else tmp = single(1.0) / (single(1.0) + (single(1.0) + (x * (single(-1.0) / s)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{-x}{s} \leq -0.019999999552965164:\\
\;\;\;\;\frac{1}{1 + \frac{1}{1 + \frac{x}{s}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{1 + \left(1 + x \cdot \frac{-1}{s}\right)}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -0.0199999996Initial program 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 97.0%
if -0.0199999996 < (/.f32 (neg.f32 x) s) Initial program 99.6%
distribute-frac-neg99.6%
exp-neg99.6%
add-sqr-sqrt17.2%
sqrt-unprod31.6%
sqr-neg31.6%
sqrt-unprod15.1%
add-sqr-sqrt31.1%
add-cube-cbrt31.1%
pow331.1%
pow-flip31.1%
add-sqr-sqrt15.1%
sqrt-unprod31.7%
sqr-neg31.7%
sqrt-unprod17.2%
add-sqr-sqrt99.6%
metadata-eval99.6%
Applied egg-rr99.6%
Taylor expanded in s around inf 54.0%
+-commutative54.0%
*-commutative54.0%
fma-def54.0%
associate-*r/54.0%
Applied egg-rr54.0%
Simplified54.0%
Taylor expanded in s around 0 54.0%
Final simplification68.7%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) -200.0) (/ 1.0 (+ 1.0 (/ s x))) (/ 1.0 (- 2.0 (/ x s)))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= -200.0f) {
tmp = 1.0f / (1.0f + (s / x));
} 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) <= (-200.0e0)) then
tmp = 1.0e0 / (1.0e0 + (s / x))
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(-200.0)) tmp = Float32(Float32(1.0) / Float32(Float32(1.0) + Float32(s / x))); 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(-200.0)) tmp = single(1.0) / (single(1.0) + (s / x)); 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 -200:\\
\;\;\;\;\frac{1}{1 + \frac{s}{x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -200Initial program 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 97.3%
Taylor expanded in x around inf 97.3%
if -200 < (/.f32 (neg.f32 x) s) Initial program 99.6%
Taylor expanded in x around 0 54.0%
mul-1-neg54.0%
unsub-neg54.0%
Simplified54.0%
Final simplification68.7%
(FPCore (x s) :precision binary32 (if (<= x -0.0015999999595806003) (/ (- s) x) (if (<= x 2.00000009162741e-18) 0.5 (- 1.0 (/ s x)))))
float code(float x, float s) {
float tmp;
if (x <= -0.0015999999595806003f) {
tmp = -s / x;
} else if (x <= 2.00000009162741e-18f) {
tmp = 0.5f;
} else {
tmp = 1.0f - (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 <= (-0.0015999999595806003e0)) then
tmp = -s / x
else if (x <= 2.00000009162741e-18) then
tmp = 0.5e0
else
tmp = 1.0e0 - (s / x)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-0.0015999999595806003)) tmp = Float32(Float32(-s) / x); elseif (x <= Float32(2.00000009162741e-18)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) - Float32(s / x)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-0.0015999999595806003)) tmp = -s / x; elseif (x <= single(2.00000009162741e-18)) tmp = single(0.5); else tmp = single(1.0) - (s / x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0015999999595806003:\\
\;\;\;\;\frac{-s}{x}\\
\mathbf{elif}\;x \leq 2.00000009162741 \cdot 10^{-18}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;1 - \frac{s}{x}\\
\end{array}
\end{array}
if x < -0.00159999996Initial program 99.9%
Taylor expanded in x around 0 51.1%
mul-1-neg51.1%
unsub-neg51.1%
Simplified51.1%
Taylor expanded in x around inf 45.8%
associate-*r/45.8%
neg-mul-145.8%
Simplified45.8%
if -0.00159999996 < x < 2.00000009e-18Initial program 99.4%
Taylor expanded in x around 0 49.7%
if 2.00000009e-18 < x Initial program 100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 98.1%
Taylor expanded in x around inf 92.7%
mul-1-neg92.7%
unsub-neg92.7%
Simplified92.7%
Final simplification63.1%
(FPCore (x s) :precision binary32 (if (<= x -0.0015999999595806003) (/ (- s) x) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -0.0015999999595806003f) {
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.0015999999595806003e0)) 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.0015999999595806003)) 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(-0.0015999999595806003)) tmp = -s / x; else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0015999999595806003:\\
\;\;\;\;\frac{-s}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -0.00159999996Initial program 99.9%
Taylor expanded in x around 0 51.1%
mul-1-neg51.1%
unsub-neg51.1%
Simplified51.1%
Taylor expanded in x around inf 45.8%
associate-*r/45.8%
neg-mul-145.8%
Simplified45.8%
if -0.00159999996 < x Initial program 99.7%
Taylor expanded in x around 0 40.8%
Final simplification42.3%
(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 30.4%
Final simplification30.4%
herbie shell --seed 2023318
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))