
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (- (fabs x)) s))) (t_1 (+ 1.0 t_0))) (/ t_0 (* (* s t_1) t_1))))
float code(float x, float s) {
float t_0 = expf((-fabsf(x) / s));
float t_1 = 1.0f + t_0;
return t_0 / ((s * t_1) * t_1);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: t_1
t_0 = exp((-abs(x) / s))
t_1 = 1.0e0 + t_0
code = t_0 / ((s * t_1) * t_1)
end function
function code(x, s) t_0 = exp(Float32(Float32(-abs(x)) / s)) t_1 = Float32(Float32(1.0) + t_0) return Float32(t_0 / Float32(Float32(s * t_1) * t_1)) end
function tmp = code(x, s) t_0 = exp((-abs(x) / s)); t_1 = single(1.0) + t_0; tmp = t_0 / ((s * t_1) * t_1); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
t_1 := 1 + t_0\\
\frac{t_0}{\left(s \cdot t_1\right) \cdot t_1}
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (- (fabs x)) s))) (t_1 (+ 1.0 t_0))) (/ t_0 (* (* s t_1) t_1))))
float code(float x, float s) {
float t_0 = expf((-fabsf(x) / s));
float t_1 = 1.0f + t_0;
return t_0 / ((s * t_1) * t_1);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: t_1
t_0 = exp((-abs(x) / s))
t_1 = 1.0e0 + t_0
code = t_0 / ((s * t_1) * t_1)
end function
function code(x, s) t_0 = exp(Float32(Float32(-abs(x)) / s)) t_1 = Float32(Float32(1.0) + t_0) return Float32(t_0 / Float32(Float32(s * t_1) * t_1)) end
function tmp = code(x, s) t_0 = exp((-abs(x) / s)); t_1 = single(1.0) + t_0; tmp = t_0 / ((s * t_1) * t_1); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
t_1 := 1 + t_0\\
\frac{t_0}{\left(s \cdot t_1\right) \cdot t_1}
\end{array}
\end{array}
(FPCore (x s)
:precision binary32
(let* ((t_0 (exp (/ (fabs x) s))))
(/
(/ (exp (/ (- (fabs x)) s)) s)
(log (exp (+ (pow t_0 -2.0) (+ (/ 2.0 t_0) 1.0)))))))
float code(float x, float s) {
float t_0 = expf((fabsf(x) / s));
return (expf((-fabsf(x) / s)) / s) / logf(expf((powf(t_0, -2.0f) + ((2.0f / t_0) + 1.0f))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
t_0 = exp((abs(x) / s))
code = (exp((-abs(x) / s)) / s) / log(exp(((t_0 ** (-2.0e0)) + ((2.0e0 / t_0) + 1.0e0))))
end function
function code(x, s) t_0 = exp(Float32(abs(x) / s)) return Float32(Float32(exp(Float32(Float32(-abs(x)) / s)) / s) / log(exp(Float32((t_0 ^ Float32(-2.0)) + Float32(Float32(Float32(2.0) / t_0) + Float32(1.0)))))) end
function tmp = code(x, s) t_0 = exp((abs(x) / s)); tmp = (exp((-abs(x) / s)) / s) / log(exp(((t_0 ^ single(-2.0)) + ((single(2.0) / t_0) + single(1.0))))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left|x\right|}{s}}\\
\frac{\frac{e^{\frac{-\left|x\right|}{s}}}{s}}{\log \left(e^{{t_0}^{-2} + \left(\frac{2}{t_0} + 1\right)}\right)}
\end{array}
\end{array}
Initial program 99.6%
/-rgt-identity99.6%
associate-/l/99.6%
*-lft-identity99.6%
+-commutative99.6%
distribute-rgt-in99.7%
*-lft-identity99.7%
+-commutative99.7%
distribute-rgt-in99.7%
*-lft-identity99.7%
Simplified99.7%
Taylor expanded in s around 0 99.7%
associate-/r*99.8%
mul-1-neg99.8%
distribute-frac-neg99.8%
+-commutative99.8%
associate-+l+99.8%
Simplified99.8%
add-log-exp99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ (fabs x) s)))) (/ (/ (exp (/ (- (fabs x)) s)) s) (+ (pow t_0 -2.0) (+ (/ 2.0 t_0) 1.0)))))
float code(float x, float s) {
float t_0 = expf((fabsf(x) / s));
return (expf((-fabsf(x) / s)) / s) / (powf(t_0, -2.0f) + ((2.0f / t_0) + 1.0f));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
t_0 = exp((abs(x) / s))
code = (exp((-abs(x) / s)) / s) / ((t_0 ** (-2.0e0)) + ((2.0e0 / t_0) + 1.0e0))
end function
function code(x, s) t_0 = exp(Float32(abs(x) / s)) return Float32(Float32(exp(Float32(Float32(-abs(x)) / s)) / s) / Float32((t_0 ^ Float32(-2.0)) + Float32(Float32(Float32(2.0) / t_0) + Float32(1.0)))) end
function tmp = code(x, s) t_0 = exp((abs(x) / s)); tmp = (exp((-abs(x) / s)) / s) / ((t_0 ^ single(-2.0)) + ((single(2.0) / t_0) + single(1.0))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left|x\right|}{s}}\\
\frac{\frac{e^{\frac{-\left|x\right|}{s}}}{s}}{{t_0}^{-2} + \left(\frac{2}{t_0} + 1\right)}
\end{array}
\end{array}
Initial program 99.6%
/-rgt-identity99.6%
associate-/l/99.6%
*-lft-identity99.6%
+-commutative99.6%
distribute-rgt-in99.7%
*-lft-identity99.7%
+-commutative99.7%
distribute-rgt-in99.7%
*-lft-identity99.7%
Simplified99.7%
Taylor expanded in s around 0 99.7%
associate-/r*99.8%
mul-1-neg99.8%
distribute-frac-neg99.8%
+-commutative99.8%
associate-+l+99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x s) :precision binary32 (if (<= x -9.999999682655225e-21) (/ (/ 1.0 s) (+ (/ (* x x) (* s s)) 4.0)) (/ (/ 1.0 s) (+ (exp (/ x s)) 3.0))))
float code(float x, float s) {
float tmp;
if (x <= -9.999999682655225e-21f) {
tmp = (1.0f / s) / (((x * x) / (s * s)) + 4.0f);
} else {
tmp = (1.0f / s) / (expf((x / s)) + 3.0f);
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= (-9.999999682655225e-21)) then
tmp = (1.0e0 / s) / (((x * x) / (s * s)) + 4.0e0)
else
tmp = (1.0e0 / s) / (exp((x / s)) + 3.0e0)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-9.999999682655225e-21)) tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(Float32(x * x) / Float32(s * s)) + Float32(4.0))); else tmp = Float32(Float32(Float32(1.0) / s) / Float32(exp(Float32(x / s)) + Float32(3.0))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-9.999999682655225e-21)) tmp = (single(1.0) / s) / (((x * x) / (s * s)) + single(4.0)); else tmp = (single(1.0) / s) / (exp((x / s)) + single(3.0)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.999999682655225 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{s}}{\frac{x \cdot x}{s \cdot s} + 4}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{s}}{e^{\frac{x}{s}} + 3}\\
\end{array}
\end{array}
if x < -9.99999968e-21Initial program 99.9%
Simplified98.9%
Taylor expanded in s around inf 50.1%
associate-+r+50.1%
distribute-lft1-in50.1%
metadata-eval50.1%
mul0-lft85.1%
associate-+r+85.1%
unpow285.1%
sqr-abs85.1%
unpow285.1%
metadata-eval85.1%
Simplified85.1%
if -9.99999968e-21 < x Initial program 99.4%
Simplified99.1%
add-exp-log99.0%
associate-+r+99.1%
Applied egg-rr99.1%
Taylor expanded in s around inf 93.1%
add-exp-log93.1%
associate-+l+93.1%
add-sqr-sqrt74.7%
fabs-sqr74.7%
add-sqr-sqrt90.4%
metadata-eval90.4%
Applied egg-rr90.4%
Final simplification88.4%
(FPCore (x s) :precision binary32 (if (<= x -9.999999682655225e-21) (/ (/ 1.0 s) (+ (/ (* x x) (* s s)) 4.0)) (/ (/ 1.0 (+ (exp (/ x s)) 3.0)) s)))
float code(float x, float s) {
float tmp;
if (x <= -9.999999682655225e-21f) {
tmp = (1.0f / s) / (((x * x) / (s * s)) + 4.0f);
} else {
tmp = (1.0f / (expf((x / s)) + 3.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 <= (-9.999999682655225e-21)) then
tmp = (1.0e0 / s) / (((x * x) / (s * s)) + 4.0e0)
else
tmp = (1.0e0 / (exp((x / s)) + 3.0e0)) / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-9.999999682655225e-21)) tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(Float32(x * x) / Float32(s * s)) + Float32(4.0))); else tmp = Float32(Float32(Float32(1.0) / Float32(exp(Float32(x / s)) + Float32(3.0))) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-9.999999682655225e-21)) tmp = (single(1.0) / s) / (((x * x) / (s * s)) + single(4.0)); else tmp = (single(1.0) / (exp((x / s)) + single(3.0))) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.999999682655225 \cdot 10^{-21}:\\
\;\;\;\;\frac{\frac{1}{s}}{\frac{x \cdot x}{s \cdot s} + 4}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{e^{\frac{x}{s}} + 3}}{s}\\
\end{array}
\end{array}
if x < -9.99999968e-21Initial program 99.9%
Simplified98.9%
Taylor expanded in s around inf 50.1%
associate-+r+50.1%
distribute-lft1-in50.1%
metadata-eval50.1%
mul0-lft85.1%
associate-+r+85.1%
unpow285.1%
sqr-abs85.1%
unpow285.1%
metadata-eval85.1%
Simplified85.1%
if -9.99999968e-21 < x Initial program 99.4%
Simplified99.1%
Taylor expanded in s around inf 93.1%
div-inv93.1%
add-sqr-sqrt74.7%
fabs-sqr74.7%
add-sqr-sqrt90.4%
metadata-eval90.4%
Applied egg-rr90.4%
associate-*l/91.1%
*-un-lft-identity91.1%
Applied egg-rr91.1%
Final simplification88.8%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ 2.0 (* 2.0 (cosh (/ x s)))))))
float code(float x, float s) {
return 1.0f / (s * (2.0f + (2.0f * coshf((x / s)))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (s * (2.0e0 + (2.0e0 * cosh((x / s)))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * cosh(Float32(x / s)))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * cosh((x / s))))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(2 + 2 \cdot \cosh \left(\frac{x}{s}\right)\right)}
\end{array}
Initial program 99.6%
Simplified99.0%
Taylor expanded in s around 0 99.7%
+-commutative99.7%
+-commutative99.7%
+-commutative99.7%
mul-1-neg99.7%
distribute-frac-neg99.7%
Simplified99.7%
expm1-log1p-u99.7%
expm1-udef77.7%
Applied egg-rr77.7%
expm1-def99.7%
expm1-log1p99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x s) :precision binary32 (if (<= x 1.0000000272452012e-27) (/ (/ 1.0 s) (+ 4.0 (* (/ 1.0 s) (* x (/ x s))))) (/ (/ 1.0 s) (+ (/ (* x x) (* s s)) 4.0))))
float code(float x, float s) {
float tmp;
if (x <= 1.0000000272452012e-27f) {
tmp = (1.0f / s) / (4.0f + ((1.0f / s) * (x * (x / s))));
} else {
tmp = (1.0f / s) / (((x * x) / (s * s)) + 4.0f);
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 1.0000000272452012e-27) then
tmp = (1.0e0 / s) / (4.0e0 + ((1.0e0 / s) * (x * (x / s))))
else
tmp = (1.0e0 / s) / (((x * x) / (s * s)) + 4.0e0)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.0000000272452012e-27)) tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(Float32(Float32(1.0) / s) * Float32(x * Float32(x / s))))); else tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(Float32(x * x) / Float32(s * s)) + Float32(4.0))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.0000000272452012e-27)) tmp = (single(1.0) / s) / (single(4.0) + ((single(1.0) / s) * (x * (x / s)))); else tmp = (single(1.0) / s) / (((x * x) / (s * s)) + single(4.0)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.0000000272452012 \cdot 10^{-27}:\\
\;\;\;\;\frac{\frac{1}{s}}{4 + \frac{1}{s} \cdot \left(x \cdot \frac{x}{s}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{s}}{\frac{x \cdot x}{s \cdot s} + 4}\\
\end{array}
\end{array}
if x < 1.00000003e-27Initial program 99.6%
Simplified99.2%
Taylor expanded in s around inf 48.8%
associate-+r+48.8%
distribute-lft1-in48.8%
metadata-eval48.8%
mul0-lft71.8%
associate-+r+71.8%
unpow271.8%
sqr-abs71.8%
unpow271.8%
metadata-eval71.8%
Simplified71.8%
clear-num71.8%
inv-pow71.8%
Applied egg-rr71.8%
unpow-171.8%
unpow271.8%
associate-/l*78.2%
associate-/r/78.2%
unpow278.2%
associate-*r/79.2%
Simplified79.2%
if 1.00000003e-27 < x Initial program 99.6%
Simplified98.8%
Taylor expanded in s around inf 55.3%
associate-+r+55.3%
distribute-lft1-in55.3%
metadata-eval55.3%
mul0-lft77.4%
associate-+r+77.4%
unpow277.4%
sqr-abs77.4%
unpow277.4%
metadata-eval77.4%
Simplified77.4%
Final simplification78.5%
(FPCore (x s) :precision binary32 (if (<= x 1.0000000272452012e-27) (/ (/ 1.0 s) (+ 4.0 (/ 1.0 (* (/ s x) (/ s x))))) (/ (/ 1.0 s) (+ (/ (* x x) (* s s)) 4.0))))
float code(float x, float s) {
float tmp;
if (x <= 1.0000000272452012e-27f) {
tmp = (1.0f / s) / (4.0f + (1.0f / ((s / x) * (s / x))));
} else {
tmp = (1.0f / s) / (((x * x) / (s * s)) + 4.0f);
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 1.0000000272452012e-27) then
tmp = (1.0e0 / s) / (4.0e0 + (1.0e0 / ((s / x) * (s / x))))
else
tmp = (1.0e0 / s) / (((x * x) / (s * s)) + 4.0e0)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.0000000272452012e-27)) tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(Float32(1.0) / Float32(Float32(s / x) * Float32(s / x))))); else tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(Float32(x * x) / Float32(s * s)) + Float32(4.0))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.0000000272452012e-27)) tmp = (single(1.0) / s) / (single(4.0) + (single(1.0) / ((s / x) * (s / x)))); else tmp = (single(1.0) / s) / (((x * x) / (s * s)) + single(4.0)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.0000000272452012 \cdot 10^{-27}:\\
\;\;\;\;\frac{\frac{1}{s}}{4 + \frac{1}{\frac{s}{x} \cdot \frac{s}{x}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{s}}{\frac{x \cdot x}{s \cdot s} + 4}\\
\end{array}
\end{array}
if x < 1.00000003e-27Initial program 99.6%
Simplified99.2%
Taylor expanded in s around inf 48.8%
associate-+r+48.8%
distribute-lft1-in48.8%
metadata-eval48.8%
mul0-lft71.8%
associate-+r+71.8%
unpow271.8%
sqr-abs71.8%
unpow271.8%
metadata-eval71.8%
Simplified71.8%
clear-num71.8%
inv-pow71.8%
Applied egg-rr71.8%
unpow-171.8%
times-frac79.2%
Simplified79.2%
if 1.00000003e-27 < x Initial program 99.6%
Simplified98.8%
Taylor expanded in s around inf 55.3%
associate-+r+55.3%
distribute-lft1-in55.3%
metadata-eval55.3%
mul0-lft77.4%
associate-+r+77.4%
unpow277.4%
sqr-abs77.4%
unpow277.4%
metadata-eval77.4%
Simplified77.4%
Final simplification78.5%
(FPCore (x s) :precision binary32 (if (<= x 1.0000000272452012e-27) (/ (/ 1.0 s) (+ 4.0 (* (/ x s) (/ x s)))) (/ (/ 1.0 s) (+ (/ (* x x) (* s s)) 4.0))))
float code(float x, float s) {
float tmp;
if (x <= 1.0000000272452012e-27f) {
tmp = (1.0f / s) / (4.0f + ((x / s) * (x / s)));
} else {
tmp = (1.0f / s) / (((x * x) / (s * s)) + 4.0f);
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 1.0000000272452012e-27) then
tmp = (1.0e0 / s) / (4.0e0 + ((x / s) * (x / s)))
else
tmp = (1.0e0 / s) / (((x * x) / (s * s)) + 4.0e0)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.0000000272452012e-27)) tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(Float32(x / s) * Float32(x / s)))); else tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(Float32(x * x) / Float32(s * s)) + Float32(4.0))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.0000000272452012e-27)) tmp = (single(1.0) / s) / (single(4.0) + ((x / s) * (x / s))); else tmp = (single(1.0) / s) / (((x * x) / (s * s)) + single(4.0)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.0000000272452012 \cdot 10^{-27}:\\
\;\;\;\;\frac{\frac{1}{s}}{4 + \frac{x}{s} \cdot \frac{x}{s}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{s}}{\frac{x \cdot x}{s \cdot s} + 4}\\
\end{array}
\end{array}
if x < 1.00000003e-27Initial program 99.6%
Simplified99.2%
Taylor expanded in s around inf 48.8%
associate-+r+48.8%
distribute-lft1-in48.8%
metadata-eval48.8%
mul0-lft71.8%
associate-+r+71.8%
unpow271.8%
sqr-abs71.8%
unpow271.8%
metadata-eval71.8%
Simplified71.8%
times-frac79.2%
Applied egg-rr79.2%
if 1.00000003e-27 < x Initial program 99.6%
Simplified98.8%
Taylor expanded in s around inf 55.3%
associate-+r+55.3%
distribute-lft1-in55.3%
metadata-eval55.3%
mul0-lft77.4%
associate-+r+77.4%
unpow277.4%
sqr-abs77.4%
unpow277.4%
metadata-eval77.4%
Simplified77.4%
Final simplification78.5%
(FPCore (x s) :precision binary32 (/ (/ 1.0 s) (+ 4.0 (* (/ x s) (/ x s)))))
float code(float x, float s) {
return (1.0f / s) / (4.0f + ((x / s) * (x / s)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / s) / (4.0e0 + ((x / s) * (x / s)))
end function
function code(x, s) return Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(Float32(x / s) * Float32(x / s)))) end
function tmp = code(x, s) tmp = (single(1.0) / s) / (single(4.0) + ((x / s) * (x / s))); end
\begin{array}{l}
\\
\frac{\frac{1}{s}}{4 + \frac{x}{s} \cdot \frac{x}{s}}
\end{array}
Initial program 99.6%
Simplified99.0%
Taylor expanded in s around inf 51.4%
associate-+r+51.4%
distribute-lft1-in51.4%
metadata-eval51.4%
mul0-lft74.1%
associate-+r+74.1%
unpow274.1%
sqr-abs74.1%
unpow274.1%
metadata-eval74.1%
Simplified74.1%
times-frac74.8%
Applied egg-rr74.8%
Final simplification74.8%
(FPCore (x s) :precision binary32 (if (or (<= x -2.0000000233721948e-7) (not (<= x 1.9999999920083944e-12))) (/ 1.0 (* x (/ x s))) (/ 0.25 s)))
float code(float x, float s) {
float tmp;
if ((x <= -2.0000000233721948e-7f) || !(x <= 1.9999999920083944e-12f)) {
tmp = 1.0f / (x * (x / s));
} else {
tmp = 0.25f / 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.0000000233721948e-7)) .or. (.not. (x <= 1.9999999920083944e-12))) then
tmp = 1.0e0 / (x * (x / s))
else
tmp = 0.25e0 / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if ((x <= Float32(-2.0000000233721948e-7)) || !(x <= Float32(1.9999999920083944e-12))) tmp = Float32(Float32(1.0) / Float32(x * Float32(x / s))); else tmp = Float32(Float32(0.25) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((x <= single(-2.0000000233721948e-7)) || ~((x <= single(1.9999999920083944e-12)))) tmp = single(1.0) / (x * (x / s)); else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.0000000233721948 \cdot 10^{-7} \lor \neg \left(x \leq 1.9999999920083944 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{1}{x \cdot \frac{x}{s}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
\end{array}
if x < -2.00000002e-7 or 1.99999999e-12 < x Initial program 99.9%
Simplified98.6%
Taylor expanded in s around inf 41.1%
associate-+r+41.1%
distribute-lft1-in41.1%
metadata-eval41.1%
mul0-lft78.7%
associate-+r+78.7%
unpow278.7%
sqr-abs78.7%
unpow278.7%
metadata-eval78.7%
Simplified78.7%
Taylor expanded in s around 0 61.2%
unpow261.2%
Simplified61.2%
clear-num64.2%
inv-pow64.2%
Applied egg-rr64.2%
unpow-164.2%
associate-*r/64.2%
Simplified64.2%
if -2.00000002e-7 < x < 1.99999999e-12Initial program 99.1%
Simplified99.6%
Taylor expanded in s around inf 65.0%
Final simplification64.5%
(FPCore (x s) :precision binary32 (if (or (<= x -2.0000000233721948e-7) (not (<= x 1.9999999920083944e-12))) (/ 1.0 (/ x (/ s x))) (/ 0.25 s)))
float code(float x, float s) {
float tmp;
if ((x <= -2.0000000233721948e-7f) || !(x <= 1.9999999920083944e-12f)) {
tmp = 1.0f / (x / (s / x));
} else {
tmp = 0.25f / 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.0000000233721948e-7)) .or. (.not. (x <= 1.9999999920083944e-12))) then
tmp = 1.0e0 / (x / (s / x))
else
tmp = 0.25e0 / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if ((x <= Float32(-2.0000000233721948e-7)) || !(x <= Float32(1.9999999920083944e-12))) tmp = Float32(Float32(1.0) / Float32(x / Float32(s / x))); else tmp = Float32(Float32(0.25) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((x <= single(-2.0000000233721948e-7)) || ~((x <= single(1.9999999920083944e-12)))) tmp = single(1.0) / (x / (s / x)); else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.0000000233721948 \cdot 10^{-7} \lor \neg \left(x \leq 1.9999999920083944 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{1}{\frac{x}{\frac{s}{x}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
\end{array}
if x < -2.00000002e-7 or 1.99999999e-12 < x Initial program 99.9%
Simplified98.6%
Taylor expanded in s around inf 41.1%
associate-+r+41.1%
distribute-lft1-in41.1%
metadata-eval41.1%
mul0-lft78.7%
associate-+r+78.7%
unpow278.7%
sqr-abs78.7%
unpow278.7%
metadata-eval78.7%
Simplified78.7%
Taylor expanded in s around 0 61.2%
unpow261.2%
Simplified61.2%
clear-num64.2%
inv-pow64.2%
Applied egg-rr64.2%
unpow-164.2%
associate-/l*64.2%
Simplified64.2%
if -2.00000002e-7 < x < 1.99999999e-12Initial program 99.1%
Simplified99.6%
Taylor expanded in s around inf 65.0%
Final simplification64.5%
(FPCore (x s) :precision binary32 (if (or (<= x -2.0000000233721948e-7) (not (<= x 1.9999999920083944e-12))) (/ s (* x x)) (/ 0.25 s)))
float code(float x, float s) {
float tmp;
if ((x <= -2.0000000233721948e-7f) || !(x <= 1.9999999920083944e-12f)) {
tmp = s / (x * x);
} else {
tmp = 0.25f / 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.0000000233721948e-7)) .or. (.not. (x <= 1.9999999920083944e-12))) then
tmp = s / (x * x)
else
tmp = 0.25e0 / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if ((x <= Float32(-2.0000000233721948e-7)) || !(x <= Float32(1.9999999920083944e-12))) tmp = Float32(s / Float32(x * x)); else tmp = Float32(Float32(0.25) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((x <= single(-2.0000000233721948e-7)) || ~((x <= single(1.9999999920083944e-12)))) tmp = s / (x * x); else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.0000000233721948 \cdot 10^{-7} \lor \neg \left(x \leq 1.9999999920083944 \cdot 10^{-12}\right):\\
\;\;\;\;\frac{s}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
\end{array}
if x < -2.00000002e-7 or 1.99999999e-12 < x Initial program 99.9%
Simplified98.6%
Taylor expanded in s around inf 41.1%
associate-+r+41.1%
distribute-lft1-in41.1%
metadata-eval41.1%
mul0-lft78.7%
associate-+r+78.7%
unpow278.7%
sqr-abs78.7%
unpow278.7%
metadata-eval78.7%
Simplified78.7%
Taylor expanded in s around 0 61.2%
unpow261.2%
Simplified61.2%
if -2.00000002e-7 < x < 1.99999999e-12Initial program 99.1%
Simplified99.6%
Taylor expanded in s around inf 65.0%
Final simplification62.7%
(FPCore (x s) :precision binary32 (/ 0.25 s))
float code(float x, float s) {
return 0.25f / s;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.25e0 / s
end function
function code(x, s) return Float32(Float32(0.25) / s) end
function tmp = code(x, s) tmp = single(0.25) / s; end
\begin{array}{l}
\\
\frac{0.25}{s}
\end{array}
Initial program 99.6%
Simplified99.0%
Taylor expanded in s around inf 28.8%
Final simplification28.8%
herbie shell --seed 2023196
(FPCore (x s)
:name "Logistic distribution"
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(/ (exp (/ (- (fabs x)) s)) (* (* s (+ 1.0 (exp (/ (- (fabs x)) s)))) (+ 1.0 (exp (/ (- (fabs x)) s))))))