
(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 16 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 (/ 1.0 (* (+ 1.0 (exp (/ (fabs x) (- s)))) (fma s (exp (/ (fabs x) s)) s))))
float code(float x, float s) {
return 1.0f / ((1.0f + expf((fabsf(x) / -s))) * fmaf(s, expf((fabsf(x) / s)), s));
}
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + exp(Float32(abs(x) / Float32(-s)))) * fma(s, exp(Float32(abs(x) / s)), s))) end
\begin{array}{l}
\\
\frac{1}{\left(1 + e^{\frac{\left|x\right|}{-s}}\right) \cdot \mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}
\end{array}
Initial program 99.8%
*-lft-identity99.8%
associate-*r/99.8%
associate-/l*99.8%
distribute-frac-neg99.8%
exp-neg99.7%
associate-/r/99.8%
/-rgt-identity99.8%
associate-*l*99.8%
Simplified99.9%
Final simplification99.9%
(FPCore (x s) :precision binary32 (/ (/ 1.0 s) (+ (exp (/ (fabs x) s)) (+ (exp (/ (fabs x) (- s))) 2.0))))
float code(float x, float s) {
return (1.0f / s) / (expf((fabsf(x) / s)) + (expf((fabsf(x) / -s)) + 2.0f));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / s) / (exp((abs(x) / s)) + (exp((abs(x) / -s)) + 2.0e0))
end function
function code(x, s) return Float32(Float32(Float32(1.0) / s) / Float32(exp(Float32(abs(x) / s)) + Float32(exp(Float32(abs(x) / Float32(-s))) + Float32(2.0)))) end
function tmp = code(x, s) tmp = (single(1.0) / s) / (exp((abs(x) / s)) + (exp((abs(x) / -s)) + single(2.0))); end
\begin{array}{l}
\\
\frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(e^{\frac{\left|x\right|}{-s}} + 2\right)}
\end{array}
Initial program 99.8%
*-lft-identity99.8%
associate-*r/99.8%
associate-*l*99.8%
times-frac99.4%
associate-*r/99.4%
associate-/l*99.4%
distribute-frac-neg99.4%
exp-neg99.5%
Simplified99.5%
Final simplification99.5%
(FPCore (x s) :precision binary32 (/ (/ 1.0 s) (+ (exp (/ (fabs x) s)) (+ 2.0 (exp (/ x s))))))
float code(float x, float s) {
return (1.0f / s) / (expf((fabsf(x) / s)) + (2.0f + expf((x / s))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / s) / (exp((abs(x) / s)) + (2.0e0 + exp((x / s))))
end function
function code(x, s) return Float32(Float32(Float32(1.0) / s) / Float32(exp(Float32(abs(x) / s)) + Float32(Float32(2.0) + exp(Float32(x / s))))) end
function tmp = code(x, s) tmp = (single(1.0) / s) / (exp((abs(x) / s)) + (single(2.0) + exp((x / s)))); end
\begin{array}{l}
\\
\frac{\frac{1}{s}}{e^{\frac{\left|x\right|}{s}} + \left(2 + e^{\frac{x}{s}}\right)}
\end{array}
Initial program 99.8%
*-lft-identity99.8%
associate-*r/99.8%
associate-*l*99.8%
times-frac99.4%
associate-*r/99.4%
associate-/l*99.4%
distribute-frac-neg99.4%
exp-neg99.5%
Simplified99.5%
add-sqr-sqrt-0.0%
sqrt-unprod93.8%
sqr-neg93.8%
sqrt-unprod96.6%
add-sqr-sqrt96.6%
*-un-lft-identity96.6%
div-inv96.6%
exp-prod97.2%
add-sqr-sqrt97.2%
sqrt-unprod97.2%
sqr-neg97.2%
sqrt-unprod-0.0%
add-sqr-sqrt97.6%
exp-prod99.5%
div-inv99.5%
Applied egg-rr98.2%
*-lft-identity98.2%
Simplified98.2%
Final simplification98.2%
(FPCore (x s)
:precision binary32
(let* ((t_0 (* (* (/ x s) (/ x s)) -0.0625)))
(if (<= (fabs x) 4.999999943633011e-27)
(/ (/ (- 0.0625 (* t_0 t_0)) (- 0.25 t_0)) s)
(if (<= (fabs x) 18000000319488.0)
(/
1.0
(* s (+ 2.0 (* 2.0 (+ 1.0 (+ (/ x s) (/ (* 0.5 (* x x)) (* s s))))))))
(* 2.0 (/ 1.0 (* x (/ x s))))))))
float code(float x, float s) {
float t_0 = ((x / s) * (x / s)) * -0.0625f;
float tmp;
if (fabsf(x) <= 4.999999943633011e-27f) {
tmp = ((0.0625f - (t_0 * t_0)) / (0.25f - t_0)) / s;
} else if (fabsf(x) <= 18000000319488.0f) {
tmp = 1.0f / (s * (2.0f + (2.0f * (1.0f + ((x / s) + ((0.5f * (x * x)) / (s * s)))))));
} else {
tmp = 2.0f * (1.0f / (x * (x / s)));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: tmp
t_0 = ((x / s) * (x / s)) * (-0.0625e0)
if (abs(x) <= 4.999999943633011e-27) then
tmp = ((0.0625e0 - (t_0 * t_0)) / (0.25e0 - t_0)) / s
else if (abs(x) <= 18000000319488.0e0) then
tmp = 1.0e0 / (s * (2.0e0 + (2.0e0 * (1.0e0 + ((x / s) + ((0.5e0 * (x * x)) / (s * s)))))))
else
tmp = 2.0e0 * (1.0e0 / (x * (x / s)))
end if
code = tmp
end function
function code(x, s) t_0 = Float32(Float32(Float32(x / s) * Float32(x / s)) * Float32(-0.0625)) tmp = Float32(0.0) if (abs(x) <= Float32(4.999999943633011e-27)) tmp = Float32(Float32(Float32(Float32(0.0625) - Float32(t_0 * t_0)) / Float32(Float32(0.25) - t_0)) / s); elseif (abs(x) <= Float32(18000000319488.0)) tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * Float32(Float32(1.0) + Float32(Float32(x / s) + Float32(Float32(Float32(0.5) * Float32(x * x)) / Float32(s * s)))))))); else tmp = Float32(Float32(2.0) * Float32(Float32(1.0) / Float32(x * Float32(x / s)))); end return tmp end
function tmp_2 = code(x, s) t_0 = ((x / s) * (x / s)) * single(-0.0625); tmp = single(0.0); if (abs(x) <= single(4.999999943633011e-27)) tmp = ((single(0.0625) - (t_0 * t_0)) / (single(0.25) - t_0)) / s; elseif (abs(x) <= single(18000000319488.0)) tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * (single(1.0) + ((x / s) + ((single(0.5) * (x * x)) / (s * s))))))); else tmp = single(2.0) * (single(1.0) / (x * (x / s))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625\\
\mathbf{if}\;\left|x\right| \leq 4.999999943633011 \cdot 10^{-27}:\\
\;\;\;\;\frac{\frac{0.0625 - t_0 \cdot t_0}{0.25 - t_0}}{s}\\
\mathbf{elif}\;\left|x\right| \leq 18000000319488:\\
\;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot \left(1 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \frac{1}{x \cdot \frac{x}{s}}\\
\end{array}
\end{array}
if (fabs.f32 x) < 4.99999994e-27Initial program 99.2%
associate-*l*99.3%
+-commutative99.3%
+-commutative99.3%
Simplified99.3%
add-exp-log92.0%
log-div91.7%
add-log-exp91.7%
add-sqr-sqrt-0.0%
sqrt-unprod73.8%
sqr-neg73.8%
sqrt-unprod73.1%
add-sqr-sqrt73.1%
add-sqr-sqrt53.7%
fabs-sqr53.7%
add-sqr-sqrt87.9%
*-commutative87.9%
Applied egg-rr91.1%
associate--r+91.1%
exp-diff91.9%
cancel-sign-sub-inv91.9%
metadata-eval91.9%
rem-exp-log99.9%
Simplified99.9%
Taylor expanded in x around 0 62.8%
unpow262.8%
unpow262.8%
Simplified62.8%
flip-+62.8%
metadata-eval62.8%
*-commutative62.8%
times-frac62.8%
*-commutative62.8%
times-frac62.8%
*-commutative62.8%
times-frac84.4%
Applied egg-rr84.4%
if 4.99999994e-27 < (fabs.f32 x) < 1.80000003e13Initial program 99.8%
*-lft-identity99.8%
associate-*r/99.8%
associate-*l*99.9%
times-frac99.8%
associate-*r/99.8%
associate-/l*99.8%
distribute-frac-neg99.8%
exp-neg99.9%
Simplified99.9%
add-sqr-sqrt-0.0%
sqrt-unprod96.8%
sqr-neg96.8%
sqrt-unprod97.0%
add-sqr-sqrt97.0%
*-un-lft-identity97.0%
div-inv97.0%
exp-prod97.7%
add-sqr-sqrt97.7%
sqrt-unprod97.7%
sqr-neg97.7%
sqrt-unprod-0.0%
add-sqr-sqrt98.5%
exp-prod99.9%
div-inv99.9%
Applied egg-rr98.0%
*-lft-identity98.0%
Simplified98.0%
expm1-log1p-u96.9%
expm1-udef96.9%
add-sqr-sqrt53.6%
fabs-sqr53.6%
add-sqr-sqrt62.4%
Applied egg-rr62.4%
expm1-def62.4%
expm1-log1p63.4%
associate-/r*63.4%
associate-+r+63.4%
+-commutative63.4%
count-263.4%
*-commutative63.4%
Simplified63.4%
Taylor expanded in x around 0 67.9%
associate-*r/67.9%
unpow267.9%
unpow267.9%
Simplified67.9%
if 1.80000003e13 < (fabs.f32 x) Initial program 100.0%
*-lft-identity100.0%
associate-*r/100.0%
associate-*l*100.0%
times-frac98.8%
associate-*r/98.8%
associate-/l*98.8%
distribute-frac-neg98.8%
exp-neg98.8%
Simplified98.8%
add-sqr-sqrt-0.0%
sqrt-unprod98.8%
sqr-neg98.8%
sqrt-unprod98.8%
add-sqr-sqrt98.8%
*-un-lft-identity98.8%
div-inv98.8%
exp-prod98.8%
add-sqr-sqrt98.8%
sqrt-unprod98.8%
sqr-neg98.8%
sqrt-unprod-0.0%
add-sqr-sqrt98.8%
exp-prod98.8%
div-inv98.8%
Applied egg-rr98.8%
*-lft-identity98.8%
Simplified98.8%
Taylor expanded in x around 0 63.5%
associate-*r/63.5%
unpow263.5%
unpow263.5%
Simplified63.5%
Taylor expanded in s around 0 92.4%
unpow292.4%
Simplified92.4%
clear-num94.3%
inv-pow94.3%
Applied egg-rr94.3%
unpow-194.3%
associate-*r/94.3%
Simplified94.3%
Final simplification79.4%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ (exp (/ (fabs x) s)) 3.0))))
float code(float x, float s) {
return 1.0f / (s * (expf((fabsf(x) / s)) + 3.0f));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (s * (exp((abs(x) / s)) + 3.0e0))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(exp(Float32(abs(x) / s)) + Float32(3.0)))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (exp((abs(x) / s)) + single(3.0))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(e^{\frac{\left|x\right|}{s}} + 3\right)}
\end{array}
Initial program 99.8%
*-lft-identity99.8%
associate-*r/99.8%
associate-*l*99.8%
times-frac99.4%
associate-*r/99.4%
associate-/l*99.4%
distribute-frac-neg99.4%
exp-neg99.5%
Simplified99.5%
add-sqr-sqrt-0.0%
sqrt-unprod93.8%
sqr-neg93.8%
sqrt-unprod96.6%
add-sqr-sqrt96.6%
*-un-lft-identity96.6%
div-inv96.6%
exp-prod97.2%
add-sqr-sqrt97.2%
sqrt-unprod97.2%
sqr-neg97.2%
sqrt-unprod-0.0%
add-sqr-sqrt97.6%
exp-prod99.5%
div-inv99.5%
Applied egg-rr98.2%
*-lft-identity98.2%
Simplified98.2%
Taylor expanded in x around 0 97.6%
Final simplification97.6%
(FPCore (x s) :precision binary32 (/ (exp (/ (- (fabs x)) s)) (* s 4.0)))
float code(float x, float s) {
return expf((-fabsf(x) / s)) / (s * 4.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = exp((-abs(x) / s)) / (s * 4.0e0)
end function
function code(x, s) return Float32(exp(Float32(Float32(-abs(x)) / s)) / Float32(s * Float32(4.0))) end
function tmp = code(x, s) tmp = exp((-abs(x) / s)) / (s * single(4.0)); end
\begin{array}{l}
\\
\frac{e^{\frac{-\left|x\right|}{s}}}{s \cdot 4}
\end{array}
Initial program 99.8%
associate-*l*99.8%
+-commutative99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in s around inf 96.7%
Final simplification96.7%
(FPCore (x s) :precision binary32 (if (<= x 2.600000032318924e-27) (/ 1.0 (* s (+ 2.0 (* 2.0 (exp (- (/ x s))))))) (/ 1.0 (+ (* s 2.0) (* s (* 2.0 (exp (/ x s))))))))
float code(float x, float s) {
float tmp;
if (x <= 2.600000032318924e-27f) {
tmp = 1.0f / (s * (2.0f + (2.0f * expf(-(x / s)))));
} else {
tmp = 1.0f / ((s * 2.0f) + (s * (2.0f * expf((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.600000032318924e-27) then
tmp = 1.0e0 / (s * (2.0e0 + (2.0e0 * exp(-(x / s)))))
else
tmp = 1.0e0 / ((s * 2.0e0) + (s * (2.0e0 * exp((x / s)))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(2.600000032318924e-27)) tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * exp(Float32(-Float32(x / s))))))); else tmp = Float32(Float32(1.0) / Float32(Float32(s * Float32(2.0)) + Float32(s * Float32(Float32(2.0) * exp(Float32(x / s)))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(2.600000032318924e-27)) tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * exp(-(x / s))))); else tmp = single(1.0) / ((s * single(2.0)) + (s * (single(2.0) * exp((x / s))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.600000032318924 \cdot 10^{-27}:\\
\;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot e^{-\frac{x}{s}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot 2 + s \cdot \left(2 \cdot e^{\frac{x}{s}}\right)}\\
\end{array}
\end{array}
if x < 2.60000003e-27Initial program 99.7%
*-lft-identity99.7%
associate-*r/99.7%
associate-*l*99.8%
times-frac99.8%
associate-*r/99.8%
associate-/l*99.8%
distribute-frac-neg99.8%
exp-neg99.9%
Simplified99.9%
add-sqr-sqrt-0.0%
sqrt-unprod91.6%
sqr-neg91.6%
sqrt-unprod96.4%
add-sqr-sqrt96.4%
*-un-lft-identity96.4%
div-inv96.4%
exp-prod96.9%
add-sqr-sqrt96.9%
sqrt-unprod96.9%
sqr-neg96.9%
sqrt-unprod-0.0%
add-sqr-sqrt97.5%
exp-prod99.9%
div-inv99.9%
Applied egg-rr99.3%
*-lft-identity99.3%
Simplified99.3%
expm1-log1p-u96.9%
expm1-udef97.0%
add-sqr-sqrt15.5%
fabs-sqr15.5%
add-sqr-sqrt31.0%
Applied egg-rr31.0%
expm1-def31.0%
expm1-log1p32.6%
associate-/r*32.6%
associate-+r+32.6%
+-commutative32.6%
count-232.6%
*-commutative32.6%
Simplified32.6%
div-inv32.6%
exp-prod34.2%
add-sqr-sqrt17.3%
fabs-sqr17.3%
add-sqr-sqrt85.2%
add-sqr-sqrt85.2%
sqrt-unprod85.2%
sqr-neg85.2%
sqrt-unprod-0.0%
add-sqr-sqrt34.2%
exp-prod32.7%
div-inv32.7%
distribute-frac-neg32.7%
exp-neg32.6%
add-sqr-sqrt16.7%
fabs-sqr16.7%
add-sqr-sqrt96.4%
add-sqr-sqrt16.7%
add-sqr-sqrt96.4%
Applied egg-rr96.4%
rec-exp96.4%
distribute-frac-neg96.4%
Simplified96.4%
if 2.60000003e-27 < x Initial program 99.8%
*-lft-identity99.8%
associate-*r/99.8%
associate-*l*99.9%
times-frac99.0%
associate-*r/99.0%
associate-/l*98.9%
distribute-frac-neg98.9%
exp-neg99.0%
Simplified99.0%
add-sqr-sqrt-0.0%
sqrt-unprod96.6%
sqr-neg96.6%
sqrt-unprod96.8%
add-sqr-sqrt96.8%
*-un-lft-identity96.8%
div-inv96.8%
exp-prod97.5%
add-sqr-sqrt97.5%
sqrt-unprod97.5%
sqr-neg97.5%
sqrt-unprod-0.0%
add-sqr-sqrt97.7%
exp-prod99.0%
div-inv99.0%
Applied egg-rr96.8%
*-lft-identity96.8%
Simplified96.8%
expm1-log1p-u96.0%
expm1-udef96.0%
add-sqr-sqrt96.0%
fabs-sqr96.0%
add-sqr-sqrt96.0%
Applied egg-rr96.0%
expm1-def96.0%
expm1-log1p96.8%
associate-/r*97.7%
associate-+r+97.7%
+-commutative97.7%
count-297.7%
*-commutative97.7%
Simplified97.7%
distribute-lft-in97.7%
*-commutative97.7%
Applied egg-rr97.7%
Final simplification97.0%
(FPCore (x s) :precision binary32 (if (<= x 2.600000032318924e-27) (/ 1.0 (* s (+ 2.0 (* 2.0 (exp (- (/ x s))))))) (/ 1.0 (* s (+ 2.0 (* 2.0 (exp (/ x s))))))))
float code(float x, float s) {
float tmp;
if (x <= 2.600000032318924e-27f) {
tmp = 1.0f / (s * (2.0f + (2.0f * expf(-(x / s)))));
} else {
tmp = 1.0f / (s * (2.0f + (2.0f * expf((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.600000032318924e-27) then
tmp = 1.0e0 / (s * (2.0e0 + (2.0e0 * exp(-(x / s)))))
else
tmp = 1.0e0 / (s * (2.0e0 + (2.0e0 * exp((x / s)))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(2.600000032318924e-27)) tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * exp(Float32(-Float32(x / s))))))); else tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * exp(Float32(x / s)))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(2.600000032318924e-27)) tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * exp(-(x / s))))); else tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * exp((x / s))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.600000032318924 \cdot 10^{-27}:\\
\;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot e^{-\frac{x}{s}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot e^{\frac{x}{s}}\right)}\\
\end{array}
\end{array}
if x < 2.60000003e-27Initial program 99.7%
*-lft-identity99.7%
associate-*r/99.7%
associate-*l*99.8%
times-frac99.8%
associate-*r/99.8%
associate-/l*99.8%
distribute-frac-neg99.8%
exp-neg99.9%
Simplified99.9%
add-sqr-sqrt-0.0%
sqrt-unprod91.6%
sqr-neg91.6%
sqrt-unprod96.4%
add-sqr-sqrt96.4%
*-un-lft-identity96.4%
div-inv96.4%
exp-prod96.9%
add-sqr-sqrt96.9%
sqrt-unprod96.9%
sqr-neg96.9%
sqrt-unprod-0.0%
add-sqr-sqrt97.5%
exp-prod99.9%
div-inv99.9%
Applied egg-rr99.3%
*-lft-identity99.3%
Simplified99.3%
expm1-log1p-u96.9%
expm1-udef97.0%
add-sqr-sqrt15.5%
fabs-sqr15.5%
add-sqr-sqrt31.0%
Applied egg-rr31.0%
expm1-def31.0%
expm1-log1p32.6%
associate-/r*32.6%
associate-+r+32.6%
+-commutative32.6%
count-232.6%
*-commutative32.6%
Simplified32.6%
div-inv32.6%
exp-prod34.2%
add-sqr-sqrt17.3%
fabs-sqr17.3%
add-sqr-sqrt85.2%
add-sqr-sqrt85.2%
sqrt-unprod85.2%
sqr-neg85.2%
sqrt-unprod-0.0%
add-sqr-sqrt34.2%
exp-prod32.7%
div-inv32.7%
distribute-frac-neg32.7%
exp-neg32.6%
add-sqr-sqrt16.7%
fabs-sqr16.7%
add-sqr-sqrt96.4%
add-sqr-sqrt16.7%
add-sqr-sqrt96.4%
Applied egg-rr96.4%
rec-exp96.4%
distribute-frac-neg96.4%
Simplified96.4%
if 2.60000003e-27 < x Initial program 99.8%
*-lft-identity99.8%
associate-*r/99.8%
associate-*l*99.9%
times-frac99.0%
associate-*r/99.0%
associate-/l*98.9%
distribute-frac-neg98.9%
exp-neg99.0%
Simplified99.0%
expm1-log1p-u97.9%
expm1-udef97.9%
Applied egg-rr96.9%
expm1-def96.9%
expm1-log1p97.7%
*-commutative97.7%
+-commutative97.7%
+-commutative97.7%
associate-+l+97.7%
count-297.7%
Simplified97.7%
Final simplification97.0%
(FPCore (x s)
:precision binary32
(let* ((t_0 (exp (/ x s))))
(if (<= x -1.000000046701102e-34)
(/ t_0 (* s 4.0))
(/ 1.0 (* s (+ 2.0 (* 2.0 t_0)))))))
float code(float x, float s) {
float t_0 = expf((x / s));
float tmp;
if (x <= -1.000000046701102e-34f) {
tmp = t_0 / (s * 4.0f);
} else {
tmp = 1.0f / (s * (2.0f + (2.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 = exp((x / s))
if (x <= (-1.000000046701102e-34)) then
tmp = t_0 / (s * 4.0e0)
else
tmp = 1.0e0 / (s * (2.0e0 + (2.0e0 * t_0)))
end if
code = tmp
end function
function code(x, s) t_0 = exp(Float32(x / s)) tmp = Float32(0.0) if (x <= Float32(-1.000000046701102e-34)) tmp = Float32(t_0 / Float32(s * Float32(4.0))); else tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * t_0)))); end return tmp end
function tmp_2 = code(x, s) t_0 = exp((x / s)); tmp = single(0.0); if (x <= single(-1.000000046701102e-34)) tmp = t_0 / (s * single(4.0)); else tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * t_0))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{x}{s}}\\
\mathbf{if}\;x \leq -1.000000046701102 \cdot 10^{-34}:\\
\;\;\;\;\frac{t_0}{s \cdot 4}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot t_0\right)}\\
\end{array}
\end{array}
if x < -1.00000005e-34Initial program 99.8%
associate-*l*99.9%
+-commutative99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in s around inf 96.6%
expm1-log1p-u96.1%
expm1-udef96.1%
Applied egg-rr96.1%
expm1-def96.1%
expm1-log1p96.6%
Simplified96.6%
if -1.00000005e-34 < x Initial program 99.7%
*-lft-identity99.7%
associate-*r/99.7%
associate-*l*99.8%
times-frac99.1%
associate-*r/99.1%
associate-/l*99.1%
distribute-frac-neg99.1%
exp-neg99.1%
Simplified99.2%
expm1-log1p-u96.5%
expm1-udef96.4%
Applied egg-rr95.1%
expm1-def95.2%
expm1-log1p97.1%
*-commutative97.1%
+-commutative97.1%
+-commutative97.1%
associate-+l+97.1%
count-297.1%
Simplified97.1%
Final simplification96.9%
(FPCore (x s)
:precision binary32
(if (<= x 4.999999943633011e-27)
(/ (exp (/ x s)) (* s 4.0))
(/
1.0
(* s (+ 2.0 (* 2.0 (+ 1.0 (+ (/ x s) (/ (* 0.5 (* x x)) (* s s))))))))))
float code(float x, float s) {
float tmp;
if (x <= 4.999999943633011e-27f) {
tmp = expf((x / s)) / (s * 4.0f);
} else {
tmp = 1.0f / (s * (2.0f + (2.0f * (1.0f + ((x / s) + ((0.5f * (x * 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 <= 4.999999943633011e-27) then
tmp = exp((x / s)) / (s * 4.0e0)
else
tmp = 1.0e0 / (s * (2.0e0 + (2.0e0 * (1.0e0 + ((x / s) + ((0.5e0 * (x * x)) / (s * s)))))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(4.999999943633011e-27)) tmp = Float32(exp(Float32(x / s)) / Float32(s * Float32(4.0))); else tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * Float32(Float32(1.0) + Float32(Float32(x / s) + Float32(Float32(Float32(0.5) * Float32(x * x)) / Float32(s * s)))))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(4.999999943633011e-27)) tmp = exp((x / s)) / (s * single(4.0)); else tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * (single(1.0) + ((x / s) + ((single(0.5) * (x * x)) / (s * s))))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.999999943633011 \cdot 10^{-27}:\\
\;\;\;\;\frac{e^{\frac{x}{s}}}{s \cdot 4}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot \left(1 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)\right)}\\
\end{array}
\end{array}
if x < 4.99999994e-27Initial program 99.7%
associate-*l*99.8%
+-commutative99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in s around inf 96.1%
expm1-log1p-u94.5%
expm1-udef94.5%
Applied egg-rr93.8%
expm1-def93.8%
expm1-log1p95.4%
Simplified95.4%
if 4.99999994e-27 < x Initial program 99.8%
*-lft-identity99.8%
associate-*r/99.8%
associate-*l*99.9%
times-frac98.9%
associate-*r/98.9%
associate-/l*98.9%
distribute-frac-neg98.9%
exp-neg99.0%
Simplified99.0%
add-sqr-sqrt-0.0%
sqrt-unprod96.6%
sqr-neg96.6%
sqrt-unprod96.8%
add-sqr-sqrt96.8%
*-un-lft-identity96.8%
div-inv96.8%
exp-prod97.5%
add-sqr-sqrt97.5%
sqrt-unprod97.5%
sqr-neg97.5%
sqrt-unprod-0.0%
add-sqr-sqrt97.7%
exp-prod99.0%
div-inv99.0%
Applied egg-rr96.8%
*-lft-identity96.8%
Simplified96.8%
expm1-log1p-u96.0%
expm1-udef96.0%
add-sqr-sqrt96.0%
fabs-sqr96.0%
add-sqr-sqrt96.0%
Applied egg-rr96.0%
expm1-def96.0%
expm1-log1p96.8%
associate-/r*97.7%
associate-+r+97.7%
+-commutative97.7%
count-297.7%
*-commutative97.7%
Simplified97.7%
Taylor expanded in x around 0 79.1%
associate-*r/79.1%
unpow279.1%
unpow279.1%
Simplified79.1%
Final simplification88.4%
(FPCore (x s)
:precision binary32
(if (<= x -9999999827968.0)
(* 2.0 (/ 1.0 (* x (/ x s))))
(if (or (<= x -1.000000045813705e-18) (not (<= x 4.999999943633011e-27)))
(/
1.0
(* s (+ 2.0 (* 2.0 (+ 1.0 (+ (/ x s) (/ (* 0.5 (* x x)) (* s s))))))))
(/ (+ (* (* (/ x s) (/ x s)) -0.0625) 0.25) s))))
float code(float x, float s) {
float tmp;
if (x <= -9999999827968.0f) {
tmp = 2.0f * (1.0f / (x * (x / s)));
} else if ((x <= -1.000000045813705e-18f) || !(x <= 4.999999943633011e-27f)) {
tmp = 1.0f / (s * (2.0f + (2.0f * (1.0f + ((x / s) + ((0.5f * (x * x)) / (s * s)))))));
} else {
tmp = ((((x / s) * (x / s)) * -0.0625f) + 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 <= (-9999999827968.0e0)) then
tmp = 2.0e0 * (1.0e0 / (x * (x / s)))
else if ((x <= (-1.000000045813705e-18)) .or. (.not. (x <= 4.999999943633011e-27))) then
tmp = 1.0e0 / (s * (2.0e0 + (2.0e0 * (1.0e0 + ((x / s) + ((0.5e0 * (x * x)) / (s * s)))))))
else
tmp = ((((x / s) * (x / s)) * (-0.0625e0)) + 0.25e0) / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-9999999827968.0)) tmp = Float32(Float32(2.0) * Float32(Float32(1.0) / Float32(x * Float32(x / s)))); elseif ((x <= Float32(-1.000000045813705e-18)) || !(x <= Float32(4.999999943633011e-27))) tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(Float32(2.0) * Float32(Float32(1.0) + Float32(Float32(x / s) + Float32(Float32(Float32(0.5) * Float32(x * x)) / Float32(s * s)))))))); else tmp = Float32(Float32(Float32(Float32(Float32(x / s) * Float32(x / s)) * Float32(-0.0625)) + Float32(0.25)) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-9999999827968.0)) tmp = single(2.0) * (single(1.0) / (x * (x / s))); elseif ((x <= single(-1.000000045813705e-18)) || ~((x <= single(4.999999943633011e-27)))) tmp = single(1.0) / (s * (single(2.0) + (single(2.0) * (single(1.0) + ((x / s) + ((single(0.5) * (x * x)) / (s * s))))))); else tmp = ((((x / s) * (x / s)) * single(-0.0625)) + single(0.25)) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9999999827968:\\
\;\;\;\;2 \cdot \frac{1}{x \cdot \frac{x}{s}}\\
\mathbf{elif}\;x \leq -1.000000045813705 \cdot 10^{-18} \lor \neg \left(x \leq 4.999999943633011 \cdot 10^{-27}\right):\\
\;\;\;\;\frac{1}{s \cdot \left(2 + 2 \cdot \left(1 + \left(\frac{x}{s} + \frac{0.5 \cdot \left(x \cdot x\right)}{s \cdot s}\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625 + 0.25}{s}\\
\end{array}
\end{array}
if x < -9999999830000Initial program 100.0%
*-lft-identity100.0%
associate-*r/100.0%
associate-*l*100.0%
times-frac100.0%
associate-*r/100.0%
associate-/l*100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Simplified100.0%
add-sqr-sqrt-0.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod100.0%
add-sqr-sqrt100.0%
*-un-lft-identity100.0%
div-inv100.0%
exp-prod100.0%
add-sqr-sqrt100.0%
sqrt-unprod100.0%
sqr-neg100.0%
sqrt-unprod-0.0%
add-sqr-sqrt100.0%
exp-prod100.0%
div-inv100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 36.2%
associate-*r/36.2%
unpow236.2%
unpow236.2%
Simplified36.2%
Taylor expanded in s around 0 90.9%
unpow290.9%
Simplified90.9%
clear-num91.4%
inv-pow91.4%
Applied egg-rr91.4%
unpow-191.4%
associate-*r/91.4%
Simplified91.4%
if -9999999830000 < x < -1.00000005e-18 or 4.99999994e-27 < x Initial program 99.8%
*-lft-identity99.8%
associate-*r/99.8%
associate-*l*99.9%
times-frac99.2%
associate-*r/99.2%
associate-/l*99.2%
distribute-frac-neg99.2%
exp-neg99.3%
Simplified99.3%
add-sqr-sqrt-0.0%
sqrt-unprod97.0%
sqr-neg97.0%
sqrt-unprod97.1%
add-sqr-sqrt97.1%
*-un-lft-identity97.1%
div-inv97.1%
exp-prod97.7%
add-sqr-sqrt97.7%
sqrt-unprod97.7%
sqr-neg97.7%
sqrt-unprod-0.0%
add-sqr-sqrt98.3%
exp-prod99.3%
div-inv99.3%
Applied egg-rr97.8%
*-lft-identity97.8%
Simplified97.8%
expm1-log1p-u97.1%
expm1-udef97.1%
add-sqr-sqrt66.8%
fabs-sqr66.8%
add-sqr-sqrt69.9%
Applied egg-rr69.9%
expm1-def69.9%
expm1-log1p70.5%
associate-/r*71.2%
associate-+r+71.2%
+-commutative71.2%
count-271.2%
*-commutative71.2%
Simplified71.2%
Taylor expanded in x around 0 74.3%
associate-*r/74.3%
unpow274.3%
unpow274.3%
Simplified74.3%
if -1.00000005e-18 < x < 4.99999994e-27Initial program 99.3%
associate-*l*99.4%
+-commutative99.4%
+-commutative99.4%
Simplified99.4%
add-exp-log92.4%
log-div92.1%
add-log-exp92.1%
add-sqr-sqrt-0.0%
sqrt-unprod74.5%
sqr-neg74.5%
sqrt-unprod73.9%
add-sqr-sqrt73.9%
add-sqr-sqrt45.3%
fabs-sqr45.3%
add-sqr-sqrt88.9%
*-commutative88.9%
Applied egg-rr91.2%
associate--r+91.3%
exp-diff92.1%
cancel-sign-sub-inv92.1%
metadata-eval92.1%
rem-exp-log99.9%
Simplified99.9%
Taylor expanded in x around 0 66.7%
unpow266.7%
unpow266.7%
Simplified66.7%
times-frac85.0%
Applied egg-rr85.0%
Final simplification79.5%
(FPCore (x s) :precision binary32 (if (or (<= x -9.999999974752427e-7) (not (<= x 1.9999999920083944e-11))) (* 2.0 (/ 1.0 (* x (/ x s)))) (/ (+ (* (* (/ x s) (/ x s)) -0.0625) 0.25) s)))
float code(float x, float s) {
float tmp;
if ((x <= -9.999999974752427e-7f) || !(x <= 1.9999999920083944e-11f)) {
tmp = 2.0f * (1.0f / (x * (x / s)));
} else {
tmp = ((((x / s) * (x / s)) * -0.0625f) + 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 <= (-9.999999974752427e-7)) .or. (.not. (x <= 1.9999999920083944e-11))) then
tmp = 2.0e0 * (1.0e0 / (x * (x / s)))
else
tmp = ((((x / s) * (x / s)) * (-0.0625e0)) + 0.25e0) / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if ((x <= Float32(-9.999999974752427e-7)) || !(x <= Float32(1.9999999920083944e-11))) tmp = Float32(Float32(2.0) * Float32(Float32(1.0) / Float32(x * Float32(x / s)))); else tmp = Float32(Float32(Float32(Float32(Float32(x / s) * Float32(x / s)) * Float32(-0.0625)) + Float32(0.25)) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((x <= single(-9.999999974752427e-7)) || ~((x <= single(1.9999999920083944e-11)))) tmp = single(2.0) * (single(1.0) / (x * (x / s))); else tmp = ((((x / s) * (x / s)) * single(-0.0625)) + single(0.25)) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.999999974752427 \cdot 10^{-7} \lor \neg \left(x \leq 1.9999999920083944 \cdot 10^{-11}\right):\\
\;\;\;\;2 \cdot \frac{1}{x \cdot \frac{x}{s}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(\frac{x}{s} \cdot \frac{x}{s}\right) \cdot -0.0625 + 0.25}{s}\\
\end{array}
\end{array}
if x < -9.99999997e-7 or 1.99999999e-11 < x Initial program 100.0%
*-lft-identity100.0%
associate-*r/100.0%
associate-*l*100.0%
times-frac99.3%
associate-*r/99.3%
associate-/l*99.3%
distribute-frac-neg99.3%
exp-neg99.4%
Simplified99.3%
add-sqr-sqrt-0.0%
sqrt-unprod98.0%
sqr-neg98.0%
sqrt-unprod98.0%
add-sqr-sqrt98.0%
*-un-lft-identity98.0%
div-inv98.0%
exp-prod98.2%
add-sqr-sqrt98.2%
sqrt-unprod98.2%
sqr-neg98.2%
sqrt-unprod-0.0%
add-sqr-sqrt98.8%
exp-prod99.3%
div-inv99.3%
Applied egg-rr98.5%
*-lft-identity98.5%
Simplified98.5%
Taylor expanded in x around 0 78.0%
associate-*r/78.0%
unpow278.0%
unpow278.0%
Simplified78.0%
Taylor expanded in s around 0 63.2%
unpow263.2%
Simplified63.2%
clear-num66.8%
inv-pow66.8%
Applied egg-rr66.8%
unpow-166.8%
associate-*r/66.8%
Simplified66.8%
if -9.99999997e-7 < x < 1.99999999e-11Initial program 99.4%
associate-*l*99.6%
+-commutative99.6%
+-commutative99.6%
Simplified99.6%
add-exp-log94.9%
log-div94.8%
add-log-exp94.8%
add-sqr-sqrt-0.0%
sqrt-unprod58.0%
sqr-neg58.0%
sqrt-unprod57.7%
add-sqr-sqrt57.7%
add-sqr-sqrt40.4%
fabs-sqr40.4%
add-sqr-sqrt78.8%
*-commutative78.8%
Applied egg-rr94.1%
associate--r+94.1%
exp-diff94.4%
cancel-sign-sub-inv94.4%
metadata-eval94.4%
rem-exp-log99.9%
Simplified99.9%
Taylor expanded in x around 0 55.9%
unpow255.9%
unpow255.9%
Simplified55.9%
times-frac65.0%
Applied egg-rr65.0%
Final simplification66.1%
(FPCore (x s) :precision binary32 (if (or (<= x -9.999999974752427e-7) (not (<= x 1.9999999920083944e-11))) (* 2.0 (/ 1.0 (* x (/ x s)))) (/ 0.25 s)))
float code(float x, float s) {
float tmp;
if ((x <= -9.999999974752427e-7f) || !(x <= 1.9999999920083944e-11f)) {
tmp = 2.0f * (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 <= (-9.999999974752427e-7)) .or. (.not. (x <= 1.9999999920083944e-11))) then
tmp = 2.0e0 * (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(-9.999999974752427e-7)) || !(x <= Float32(1.9999999920083944e-11))) tmp = Float32(Float32(2.0) * 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(-9.999999974752427e-7)) || ~((x <= single(1.9999999920083944e-11)))) tmp = single(2.0) * (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 -9.999999974752427 \cdot 10^{-7} \lor \neg \left(x \leq 1.9999999920083944 \cdot 10^{-11}\right):\\
\;\;\;\;2 \cdot \frac{1}{x \cdot \frac{x}{s}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
\end{array}
if x < -9.99999997e-7 or 1.99999999e-11 < x Initial program 100.0%
*-lft-identity100.0%
associate-*r/100.0%
associate-*l*100.0%
times-frac99.3%
associate-*r/99.3%
associate-/l*99.3%
distribute-frac-neg99.3%
exp-neg99.4%
Simplified99.3%
add-sqr-sqrt-0.0%
sqrt-unprod98.0%
sqr-neg98.0%
sqrt-unprod98.0%
add-sqr-sqrt98.0%
*-un-lft-identity98.0%
div-inv98.0%
exp-prod98.2%
add-sqr-sqrt98.2%
sqrt-unprod98.2%
sqr-neg98.2%
sqrt-unprod-0.0%
add-sqr-sqrt98.8%
exp-prod99.3%
div-inv99.3%
Applied egg-rr98.5%
*-lft-identity98.5%
Simplified98.5%
Taylor expanded in x around 0 78.0%
associate-*r/78.0%
unpow278.0%
unpow278.0%
Simplified78.0%
Taylor expanded in s around 0 63.2%
unpow263.2%
Simplified63.2%
clear-num66.8%
inv-pow66.8%
Applied egg-rr66.8%
unpow-166.8%
associate-*r/66.8%
Simplified66.8%
if -9.99999997e-7 < x < 1.99999999e-11Initial program 99.4%
associate-*l*99.6%
+-commutative99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in s around inf 65.0%
Final simplification66.1%
(FPCore (x s) :precision binary32 (if (or (<= x -9.999999974752427e-7) (not (<= x 1.9999999920083944e-11))) (* 2.0 (/ s (* x x))) (/ 0.25 s)))
float code(float x, float s) {
float tmp;
if ((x <= -9.999999974752427e-7f) || !(x <= 1.9999999920083944e-11f)) {
tmp = 2.0f * (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 <= (-9.999999974752427e-7)) .or. (.not. (x <= 1.9999999920083944e-11))) then
tmp = 2.0e0 * (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(-9.999999974752427e-7)) || !(x <= Float32(1.9999999920083944e-11))) tmp = Float32(Float32(2.0) * 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(-9.999999974752427e-7)) || ~((x <= single(1.9999999920083944e-11)))) tmp = single(2.0) * (s / (x * x)); else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.999999974752427 \cdot 10^{-7} \lor \neg \left(x \leq 1.9999999920083944 \cdot 10^{-11}\right):\\
\;\;\;\;2 \cdot \frac{s}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
\end{array}
if x < -9.99999997e-7 or 1.99999999e-11 < x Initial program 100.0%
*-lft-identity100.0%
associate-*r/100.0%
associate-*l*100.0%
times-frac99.3%
associate-*r/99.3%
associate-/l*99.3%
distribute-frac-neg99.3%
exp-neg99.4%
Simplified99.3%
add-sqr-sqrt-0.0%
sqrt-unprod98.0%
sqr-neg98.0%
sqrt-unprod98.0%
add-sqr-sqrt98.0%
*-un-lft-identity98.0%
div-inv98.0%
exp-prod98.2%
add-sqr-sqrt98.2%
sqrt-unprod98.2%
sqr-neg98.2%
sqrt-unprod-0.0%
add-sqr-sqrt98.8%
exp-prod99.3%
div-inv99.3%
Applied egg-rr98.5%
*-lft-identity98.5%
Simplified98.5%
Taylor expanded in x around 0 78.0%
associate-*r/78.0%
unpow278.0%
unpow278.0%
Simplified78.0%
Taylor expanded in s around 0 63.2%
unpow263.2%
Simplified63.2%
if -9.99999997e-7 < x < 1.99999999e-11Initial program 99.4%
associate-*l*99.6%
+-commutative99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in s around inf 65.0%
Final simplification63.9%
(FPCore (x s) :precision binary32 (if (<= x -9.999999974752427e-7) (* 2.0 (/ (/ s x) x)) (if (<= x 1.9999999920083944e-11) (/ 0.25 s) (* 2.0 (/ s (* x x))))))
float code(float x, float s) {
float tmp;
if (x <= -9.999999974752427e-7f) {
tmp = 2.0f * ((s / x) / x);
} else if (x <= 1.9999999920083944e-11f) {
tmp = 0.25f / s;
} else {
tmp = 2.0f * (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 <= (-9.999999974752427e-7)) then
tmp = 2.0e0 * ((s / x) / x)
else if (x <= 1.9999999920083944e-11) then
tmp = 0.25e0 / s
else
tmp = 2.0e0 * (s / (x * x))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(-9.999999974752427e-7)) tmp = Float32(Float32(2.0) * Float32(Float32(s / x) / x)); elseif (x <= Float32(1.9999999920083944e-11)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(2.0) * Float32(s / Float32(x * x))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(-9.999999974752427e-7)) tmp = single(2.0) * ((s / x) / x); elseif (x <= single(1.9999999920083944e-11)) tmp = single(0.25) / s; else tmp = single(2.0) * (s / (x * x)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.999999974752427 \cdot 10^{-7}:\\
\;\;\;\;2 \cdot \frac{\frac{s}{x}}{x}\\
\mathbf{elif}\;x \leq 1.9999999920083944 \cdot 10^{-11}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \frac{s}{x \cdot x}\\
\end{array}
\end{array}
if x < -9.99999997e-7Initial program 100.0%
*-lft-identity100.0%
associate-*r/100.0%
associate-*l*100.0%
times-frac100.0%
associate-*r/100.0%
associate-/l*100.0%
distribute-frac-neg100.0%
exp-neg100.0%
Simplified100.0%
add-sqr-sqrt-0.0%
sqrt-unprod99.1%
sqr-neg99.1%
sqrt-unprod99.1%
add-sqr-sqrt99.1%
*-un-lft-identity99.1%
div-inv99.1%
exp-prod99.1%
add-sqr-sqrt99.1%
sqrt-unprod99.1%
sqr-neg99.1%
sqrt-unprod-0.0%
add-sqr-sqrt99.9%
exp-prod100.0%
div-inv100.0%
Applied egg-rr100.0%
*-lft-identity100.0%
Simplified100.0%
Taylor expanded in x around 0 59.5%
associate-*r/59.5%
unpow259.5%
unpow259.5%
Simplified59.5%
Taylor expanded in s around 0 66.2%
unpow266.2%
Simplified66.2%
Taylor expanded in s around 0 66.2%
unpow266.2%
associate-/r*66.2%
Simplified66.2%
if -9.99999997e-7 < x < 1.99999999e-11Initial program 99.4%
associate-*l*99.6%
+-commutative99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in s around inf 65.0%
if 1.99999999e-11 < x Initial program 100.0%
*-lft-identity100.0%
associate-*r/100.0%
associate-*l*100.0%
times-frac98.6%
associate-*r/98.6%
associate-/l*98.6%
distribute-frac-neg98.6%
exp-neg98.7%
Simplified98.6%
add-sqr-sqrt-0.0%
sqrt-unprod97.0%
sqr-neg97.0%
sqrt-unprod97.0%
add-sqr-sqrt97.0%
*-un-lft-identity97.0%
div-inv97.0%
exp-prod97.3%
add-sqr-sqrt97.3%
sqrt-unprod97.3%
sqr-neg97.3%
sqrt-unprod-0.0%
add-sqr-sqrt97.5%
exp-prod98.6%
div-inv98.6%
Applied egg-rr97.0%
*-lft-identity97.0%
Simplified97.0%
Taylor expanded in x around 0 97.1%
associate-*r/97.1%
unpow297.1%
unpow297.1%
Simplified97.1%
Taylor expanded in s around 0 60.1%
unpow260.1%
Simplified60.1%
Final simplification63.9%
(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.8%
associate-*l*99.8%
+-commutative99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in s around inf 29.0%
Final simplification29.0%
herbie shell --seed 2023175
(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))))))