
(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 (exp (- (log1p (exp (/ (- x) s))))))
float code(float x, float s) {
return expf(-log1pf(expf((-x / s))));
}
function code(x, s) return exp(Float32(-log1p(exp(Float32(Float32(-x) / s))))) end
\begin{array}{l}
\\
e^{-\mathsf{log1p}\left(e^{\frac{-x}{s}}\right)}
\end{array}
Initial program 99.9%
distribute-frac-neg99.9%
exp-neg99.9%
add-sqr-sqrt50.7%
sqrt-unprod63.9%
sqr-neg63.9%
sqrt-unprod14.8%
add-sqr-sqrt27.8%
pow127.8%
pow127.8%
add-cbrt-cube27.8%
pow1/327.8%
pow-flip27.8%
Applied egg-rr99.9%
sqr-pow99.9%
*-commutative99.9%
exp-prod99.8%
metadata-eval99.8%
*-commutative99.8%
exp-prod99.8%
metadata-eval99.8%
Simplified99.8%
pow299.8%
pow-pow99.8%
metadata-eval99.8%
Applied egg-rr99.8%
add-exp-log99.8%
log-rec99.8%
log1p-udef99.9%
add-exp-log99.9%
pow-pow100.0%
metadata-eval100.0%
log-pow100.0%
add-log-exp100.0%
neg-mul-1100.0%
distribute-neg-frac100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x s) :precision binary32 (/ 1.0 (+ (exp (/ (- x) s)) 1.0)))
float code(float x, float s) {
return 1.0f / (expf((-x / s)) + 1.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (exp((-x / s)) + 1.0e0)
end function
function code(x, s) return Float32(Float32(1.0) / Float32(exp(Float32(Float32(-x) / s)) + Float32(1.0))) end
function tmp = code(x, s) tmp = single(1.0) / (exp((-x / s)) + single(1.0)); end
\begin{array}{l}
\\
\frac{1}{e^{\frac{-x}{s}} + 1}
\end{array}
Initial program 99.9%
Final simplification99.9%
(FPCore (x s) :precision binary32 (if (<= (- x) 9.999999796611898e-32) 0.5 (/ 1.0 (+ (- 2.0 (/ x s)) (* x (* 0.5 (/ x (* s s))))))))
float code(float x, float s) {
float tmp;
if (-x <= 9.999999796611898e-32f) {
tmp = 0.5f;
} else {
tmp = 1.0f / ((2.0f - (x / s)) + (x * (0.5f * (x / (s * s)))));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (-x <= 9.999999796611898e-32) then
tmp = 0.5e0
else
tmp = 1.0e0 / ((2.0e0 - (x / s)) + (x * (0.5e0 * (x / (s * s)))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-x) <= Float32(9.999999796611898e-32)) tmp = Float32(0.5); else tmp = Float32(Float32(1.0) / Float32(Float32(Float32(2.0) - Float32(x / s)) + Float32(x * Float32(Float32(0.5) * Float32(x / Float32(s * s)))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-x <= single(9.999999796611898e-32)) tmp = single(0.5); else tmp = single(1.0) / ((single(2.0) - (x / s)) + (x * (single(0.5) * (x / (s * s))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;-x \leq 9.999999796611898 \cdot 10^{-32}:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(2 - \frac{x}{s}\right) + x \cdot \left(0.5 \cdot \frac{x}{s \cdot s}\right)}\\
\end{array}
\end{array}
if (neg.f32 x) < 9.9999998e-32Initial program 99.9%
Taylor expanded in x around 0 47.1%
if 9.9999998e-32 < (neg.f32 x) Initial program 99.8%
distribute-frac-neg99.8%
exp-neg99.8%
add-sqr-sqrt-0.0%
sqrt-unprod23.1%
sqr-neg23.1%
sqrt-unprod23.1%
add-sqr-sqrt23.1%
pow123.1%
pow123.1%
add-cbrt-cube23.1%
pow1/323.1%
pow-flip23.1%
Applied egg-rr99.8%
sqr-pow99.8%
*-commutative99.8%
exp-prod99.8%
metadata-eval99.8%
*-commutative99.8%
exp-prod99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in s around inf 59.3%
+-commutative59.3%
neg-mul-159.3%
sub-neg59.3%
mul-1-neg59.3%
unsub-neg59.3%
distribute-rgt-out83.9%
metadata-eval83.9%
unpow283.9%
times-frac75.9%
unpow275.9%
associate-*r/76.0%
Simplified76.0%
*-commutative76.0%
clear-num76.0%
associate-*r/75.9%
frac-times83.9%
*-un-lft-identity83.9%
div-inv83.9%
metadata-eval83.9%
Applied egg-rr83.9%
sub-neg83.9%
associate-/l*88.3%
distribute-neg-frac88.3%
*-commutative88.3%
associate-*r*88.3%
metadata-eval88.3%
distribute-rgt-neg-in88.3%
distribute-neg-frac88.3%
frac-2neg88.3%
div-inv88.3%
clear-num88.3%
*-un-lft-identity88.3%
*-commutative88.3%
times-frac88.3%
metadata-eval88.3%
Applied egg-rr88.3%
Final simplification65.4%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) 2000.0) 0.5 (* 2.0 (* s (/ s (* x x))))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= 2000.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) <= 2000.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(2000.0)) tmp = Float32(0.5); else tmp = Float32(Float32(2.0) * Float32(s * Float32(s / Float32(x * x)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(2000.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 2000:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(s \cdot \frac{s}{x \cdot x}\right)\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 2e3Initial program 99.8%
Taylor expanded in x around 0 51.7%
if 2e3 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in x around 0 85.0%
mul-1-neg85.0%
unsub-neg85.0%
unpow285.0%
unpow285.0%
times-frac73.8%
Simplified73.8%
Taylor expanded in x around inf 83.2%
unpow283.2%
unpow283.2%
Simplified83.2%
associate-/l*69.4%
associate-/r/69.4%
Applied egg-rr69.4%
Final simplification57.7%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) 2000.0) 0.5 (* 2.0 (/ (* s s) (* x x)))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= 2000.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) <= 2000.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(2000.0)) tmp = Float32(0.5); else tmp = Float32(Float32(2.0) * Float32(Float32(s * s) / Float32(x * x))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((-x / s) <= single(2000.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 2000:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \frac{s \cdot s}{x \cdot x}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < 2e3Initial program 99.8%
Taylor expanded in x around 0 51.7%
if 2e3 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in x around 0 85.0%
mul-1-neg85.0%
unsub-neg85.0%
unpow285.0%
unpow285.0%
times-frac73.8%
Simplified73.8%
Taylor expanded in x around inf 83.2%
unpow283.2%
unpow283.2%
Simplified83.2%
Final simplification62.3%
(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.8%
Taylor expanded in x around 0 52.3%
if 2 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in x around 0 83.0%
mul-1-neg83.0%
unsub-neg83.0%
unpow283.0%
unpow283.0%
times-frac72.3%
Simplified72.3%
Taylor expanded in x around inf 81.3%
unpow281.3%
unpow281.3%
Simplified81.3%
associate-*r/81.3%
associate-/r*87.0%
*-commutative87.0%
Applied egg-rr87.0%
associate-/l/81.3%
times-frac87.0%
Applied egg-rr87.0%
Final simplification64.2%
(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.8%
Taylor expanded in x around 0 52.3%
if 2 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in x around 0 83.0%
mul-1-neg83.0%
unsub-neg83.0%
unpow283.0%
unpow283.0%
times-frac72.3%
Simplified72.3%
Taylor expanded in x around inf 81.3%
unpow281.3%
unpow281.3%
Simplified81.3%
associate-*r/81.3%
associate-/r*87.0%
*-commutative87.0%
Applied egg-rr87.0%
Final simplification64.2%
(FPCore (x s) :precision binary32 (if (<= (/ (- x) s) -1.0) 0.5 (/ 1.0 (- 2.0 (/ x s)))))
float code(float x, float s) {
float tmp;
if ((-x / s) <= -1.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) <= (-1.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(-1.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(-1.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 -1:\\
\;\;\;\;0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2 - \frac{x}{s}}\\
\end{array}
\end{array}
if (/.f32 (neg.f32 x) s) < -1Initial program 100.0%
Taylor expanded in x around 0 28.1%
if -1 < (/.f32 (neg.f32 x) s) Initial program 99.8%
Taylor expanded in x around 0 63.9%
mul-1-neg63.9%
unsub-neg63.9%
Simplified63.9%
Final simplification50.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.8%
Taylor expanded in x around 0 52.3%
if 2 < (/.f32 (neg.f32 x) s) Initial program 100.0%
Taylor expanded in x around 0 42.1%
mul-1-neg42.1%
unsub-neg42.1%
Simplified42.1%
Taylor expanded in x around inf 42.1%
neg-mul-142.1%
distribute-neg-frac42.1%
Simplified42.1%
Final simplification48.8%
(FPCore (x s) :precision binary32 (if (<= x -1.0) (* s (/ 1.0 x)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.0f) {
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 <= (-1.0e0)) 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(-1.0)) 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(-1.0)) 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 -1:\\
\;\;\;\;s \cdot \frac{1}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1Initial program 100.0%
Taylor expanded in x around 0 59.6%
mul-1-neg59.6%
unsub-neg59.6%
Simplified59.6%
Taylor expanded in x around inf 59.6%
neg-mul-159.6%
distribute-neg-frac59.6%
Simplified59.6%
associate-/r/52.4%
add-sqr-sqrt52.4%
sqrt-unprod63.4%
sqr-neg63.4%
sqrt-prod-0.0%
add-sqr-sqrt52.4%
Applied egg-rr52.4%
if -1 < x Initial program 99.8%
Taylor expanded in x around 0 45.3%
Final simplification46.9%
(FPCore (x s) :precision binary32 (if (<= x -1.0) (/ 1.0 (/ x s)) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.0f) {
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 <= (-1.0e0)) 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(-1.0)) 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(-1.0)) 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 -1:\\
\;\;\;\;\frac{1}{\frac{x}{s}}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1Initial program 100.0%
Taylor expanded in x around 0 59.6%
mul-1-neg59.6%
unsub-neg59.6%
Simplified59.6%
Taylor expanded in x around inf 59.6%
neg-mul-159.6%
distribute-neg-frac59.6%
Simplified59.6%
clear-num59.6%
inv-pow59.6%
/-rgt-identity59.6%
add-sqr-sqrt59.6%
sqrt-unprod66.9%
sqr-neg66.9%
sqrt-prod-0.0%
add-sqr-sqrt59.6%
Applied egg-rr59.6%
unpow-159.6%
Simplified59.6%
if -1 < x Initial program 99.8%
Taylor expanded in x around 0 45.3%
Final simplification48.6%
(FPCore (x s) :precision binary32 (if (<= x -1.0) (/ s x) 0.5))
float code(float x, float s) {
float tmp;
if (x <= -1.0f) {
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 <= (-1.0e0)) 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(-1.0)) 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(-1.0)) tmp = s / x; else tmp = single(0.5); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1:\\
\;\;\;\;\frac{s}{x}\\
\mathbf{else}:\\
\;\;\;\;0.5\\
\end{array}
\end{array}
if x < -1Initial program 100.0%
Taylor expanded in x around 0 59.6%
mul-1-neg59.6%
unsub-neg59.6%
Simplified59.6%
Taylor expanded in x around inf 59.6%
neg-mul-159.6%
distribute-neg-frac59.6%
Simplified59.6%
expm1-log1p-u59.6%
expm1-udef98.4%
clear-num98.4%
add-sqr-sqrt98.4%
add-sqr-sqrt98.4%
sqrt-prod98.4%
sqrt-unprod98.4%
sqr-neg98.4%
sqrt-div98.4%
times-frac98.4%
sqrt-prod34.5%
add-sqr-sqrt98.4%
Applied egg-rr98.4%
expm1-def52.4%
expm1-log1p52.4%
Simplified52.4%
if -1 < x Initial program 99.8%
Taylor expanded in x around 0 45.3%
Final simplification46.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 36.5%
Final simplification36.5%
herbie shell --seed 2023230
(FPCore (x s)
:name "Logistic function"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ 1.0 (+ 1.0 (exp (/ (- x) s)))))