
(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 (/ (fabs x) s)))
(/
(/ 1.0 s)
(+
(pow (exp (pow (cbrt t_0) 2.0)) (pow t_0 0.3333333333333333))
(+ 2.0 (exp (/ (fabs x) (- s))))))))
float code(float x, float s) {
float t_0 = fabsf(x) / s;
return (1.0f / s) / (powf(expf(powf(cbrtf(t_0), 2.0f)), powf(t_0, 0.3333333333333333f)) + (2.0f + expf((fabsf(x) / -s))));
}
function code(x, s) t_0 = Float32(abs(x) / s) return Float32(Float32(Float32(1.0) / s) / Float32((exp((cbrt(t_0) ^ Float32(2.0))) ^ (t_0 ^ Float32(0.3333333333333333))) + Float32(Float32(2.0) + exp(Float32(abs(x) / Float32(-s)))))) end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\left|x\right|}{s}\\
\frac{\frac{1}{s}}{{\left(e^{{\left(\sqrt[3]{t_0}\right)}^{2}}\right)}^{\left({t_0}^{0.3333333333333333}\right)} + \left(2 + e^{\frac{\left|x\right|}{-s}}\right)}
\end{array}
\end{array}
Initial program 99.7%
Simplified99.8%
add-cube-cbrt99.8%
exp-prod99.8%
pow299.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 99.8%
Final simplification99.8%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ (exp (/ (- (fabs x)) s)) (+ 2.0 (exp (/ (fabs x) s)))))))
float code(float x, float s) {
return 1.0f / (s * (expf((-fabsf(x) / s)) + (2.0f + expf((fabsf(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((abs(x) / s)))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(exp(Float32(Float32(-abs(x)) / s)) + Float32(Float32(2.0) + exp(Float32(abs(x) / s)))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (exp((-abs(x) / s)) + (single(2.0) + exp((abs(x) / s))))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(e^{\frac{-\left|x\right|}{s}} + \left(2 + e^{\frac{\left|x\right|}{s}}\right)\right)}
\end{array}
Initial program 99.7%
Simplified99.8%
Taylor expanded in s around 0 99.8%
mul-1-neg99.8%
distribute-frac-neg99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x s)
:precision binary32
(let* ((t_0 (* (/ x s) (/ x s))))
(if (<= (fabs x) 5.999999759184749e-13)
(/ (/ 1.0 s) (/ (- (* t_0 (/ x (/ (* s s) x))) 16.0) (- t_0 4.0)))
(/
(/ 1.0 s)
(+ 4.0 (/ (* x x) (cbrt (* (* s s) (* (* s s) (* s s))))))))))
float code(float x, float s) {
float t_0 = (x / s) * (x / s);
float tmp;
if (fabsf(x) <= 5.999999759184749e-13f) {
tmp = (1.0f / s) / (((t_0 * (x / ((s * s) / x))) - 16.0f) / (t_0 - 4.0f));
} else {
tmp = (1.0f / s) / (4.0f + ((x * x) / cbrtf(((s * s) * ((s * s) * (s * s))))));
}
return tmp;
}
function code(x, s) t_0 = Float32(Float32(x / s) * Float32(x / s)) tmp = Float32(0.0) if (abs(x) <= Float32(5.999999759184749e-13)) tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(Float32(t_0 * Float32(x / Float32(Float32(s * s) / x))) - Float32(16.0)) / Float32(t_0 - Float32(4.0)))); else tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(Float32(x * x) / cbrt(Float32(Float32(s * s) * Float32(Float32(s * s) * Float32(s * s))))))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{s} \cdot \frac{x}{s}\\
\mathbf{if}\;\left|x\right| \leq 5.999999759184749 \cdot 10^{-13}:\\
\;\;\;\;\frac{\frac{1}{s}}{\frac{t_0 \cdot \frac{x}{\frac{s \cdot s}{x}} - 16}{t_0 - 4}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{s}}{4 + \frac{x \cdot x}{\sqrt[3]{\left(s \cdot s\right) \cdot \left(\left(s \cdot s\right) \cdot \left(s \cdot s\right)\right)}}}\\
\end{array}
\end{array}
if (fabs.f32 x) < 5.99999976e-13Initial program 99.4%
Simplified99.6%
Taylor expanded in s around inf 70.0%
associate-+r+70.0%
distribute-lft1-in70.0%
metadata-eval70.0%
mul0-lft70.0%
associate-+r+70.0%
metadata-eval70.0%
unpow270.0%
sqr-abs70.0%
unpow270.0%
Simplified70.0%
flip-+52.0%
times-frac52.0%
times-frac52.1%
metadata-eval52.1%
times-frac82.2%
Applied egg-rr82.2%
frac-times69.1%
add-cbrt-cube37.5%
associate-/l*52.1%
add-cbrt-cube82.7%
Applied egg-rr82.7%
if 5.99999976e-13 < (fabs.f32 x) Initial program 99.9%
Simplified100.0%
Taylor expanded in s around inf 41.8%
associate-+r+41.8%
distribute-lft1-in41.8%
metadata-eval41.8%
mul0-lft82.8%
associate-+r+82.8%
metadata-eval82.8%
unpow282.8%
sqr-abs82.8%
unpow282.8%
Simplified82.8%
add-cbrt-cube93.5%
Applied egg-rr93.5%
Final simplification89.3%
(FPCore (x s) :precision binary32 (/ (/ 1.0 s) (+ (log1p (expm1 (* (/ x s) (/ x s)))) 4.0)))
float code(float x, float s) {
return (1.0f / s) / (log1pf(expm1f(((x / s) * (x / s)))) + 4.0f);
}
function code(x, s) return Float32(Float32(Float32(1.0) / s) / Float32(log1p(expm1(Float32(Float32(x / s) * Float32(x / s)))) + Float32(4.0))) end
\begin{array}{l}
\\
\frac{\frac{1}{s}}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{s} \cdot \frac{x}{s}\right)\right) + 4}
\end{array}
Initial program 99.7%
Simplified99.8%
Taylor expanded in s around inf 52.8%
associate-+r+52.8%
distribute-lft1-in52.8%
metadata-eval52.8%
mul0-lft77.8%
associate-+r+77.8%
metadata-eval77.8%
unpow277.8%
sqr-abs77.8%
unpow277.8%
Simplified77.8%
log1p-expm1-u89.0%
times-frac98.1%
Applied egg-rr98.1%
Final simplification98.1%
(FPCore (x s)
:precision binary32
(let* ((t_0 (* (/ x s) (/ x s))))
(if (<= (fabs x) 1.9999999996399175e-23)
(/ (/ 1.0 s) (/ (- (* t_0 t_0) 16.0) (- t_0 4.0)))
(/ (/ 1.0 s) (+ 4.0 (* (* x x) (/ 1.0 (* s s))))))))
float code(float x, float s) {
float t_0 = (x / s) * (x / s);
float tmp;
if (fabsf(x) <= 1.9999999996399175e-23f) {
tmp = (1.0f / s) / (((t_0 * t_0) - 16.0f) / (t_0 - 4.0f));
} else {
tmp = (1.0f / s) / (4.0f + ((x * x) * (1.0f / (s * 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)
if (abs(x) <= 1.9999999996399175e-23) then
tmp = (1.0e0 / s) / (((t_0 * t_0) - 16.0e0) / (t_0 - 4.0e0))
else
tmp = (1.0e0 / s) / (4.0e0 + ((x * x) * (1.0e0 / (s * s))))
end if
code = tmp
end function
function code(x, s) t_0 = Float32(Float32(x / s) * Float32(x / s)) tmp = Float32(0.0) if (abs(x) <= Float32(1.9999999996399175e-23)) tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(Float32(t_0 * t_0) - Float32(16.0)) / Float32(t_0 - Float32(4.0)))); else tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(Float32(x * x) * Float32(Float32(1.0) / Float32(s * s))))); end return tmp end
function tmp_2 = code(x, s) t_0 = (x / s) * (x / s); tmp = single(0.0); if (abs(x) <= single(1.9999999996399175e-23)) tmp = (single(1.0) / s) / (((t_0 * t_0) - single(16.0)) / (t_0 - single(4.0))); else tmp = (single(1.0) / s) / (single(4.0) + ((x * x) * (single(1.0) / (s * s)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{s} \cdot \frac{x}{s}\\
\mathbf{if}\;\left|x\right| \leq 1.9999999996399175 \cdot 10^{-23}:\\
\;\;\;\;\frac{\frac{1}{s}}{\frac{t_0 \cdot t_0 - 16}{t_0 - 4}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{s}}{4 + \left(x \cdot x\right) \cdot \frac{1}{s \cdot s}}\\
\end{array}
\end{array}
if (fabs.f32 x) < 2e-23Initial program 99.1%
Simplified99.3%
Taylor expanded in s around inf 54.7%
associate-+r+54.7%
distribute-lft1-in54.7%
metadata-eval54.7%
mul0-lft54.7%
associate-+r+54.7%
metadata-eval54.7%
unpow254.7%
sqr-abs54.7%
unpow254.7%
Simplified54.7%
flip-+54.7%
times-frac54.7%
times-frac54.7%
metadata-eval54.7%
times-frac79.9%
Applied egg-rr79.9%
if 2e-23 < (fabs.f32 x) Initial program 99.9%
Simplified100.0%
Taylor expanded in s around inf 52.2%
associate-+r+52.2%
distribute-lft1-in52.2%
metadata-eval52.2%
mul0-lft84.9%
associate-+r+84.9%
metadata-eval84.9%
unpow284.9%
sqr-abs84.9%
unpow284.9%
Simplified84.9%
div-inv86.0%
Applied egg-rr86.0%
Final simplification84.6%
(FPCore (x s) :precision binary32 (let* ((t_0 (* (/ x s) (/ x s)))) (/ (/ 1.0 s) (+ 4.0 (cbrt (* t_0 (* t_0 t_0)))))))
float code(float x, float s) {
float t_0 = (x / s) * (x / s);
return (1.0f / s) / (4.0f + cbrtf((t_0 * (t_0 * t_0))));
}
function code(x, s) t_0 = Float32(Float32(x / s) * Float32(x / s)) return Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + cbrt(Float32(t_0 * Float32(t_0 * t_0))))) end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{s} \cdot \frac{x}{s}\\
\frac{\frac{1}{s}}{4 + \sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)}}
\end{array}
\end{array}
Initial program 99.7%
Simplified99.8%
Taylor expanded in s around inf 52.8%
associate-+r+52.8%
distribute-lft1-in52.8%
metadata-eval52.8%
mul0-lft77.8%
associate-+r+77.8%
metadata-eval77.8%
unpow277.8%
sqr-abs77.8%
unpow277.8%
Simplified77.8%
add-cbrt-cube83.8%
times-frac83.8%
times-frac83.8%
times-frac89.7%
Applied egg-rr89.7%
Final simplification89.7%
(FPCore (x s) :precision binary32 (if (<= x 1.9999999996399175e-23) (/ (/ 1.0 s) (+ (* (/ x s) (/ x s)) 4.0)) (/ (/ 1.0 s) (+ 4.0 (* (* x x) (/ 1.0 (* s s)))))))
float code(float x, float s) {
float tmp;
if (x <= 1.9999999996399175e-23f) {
tmp = (1.0f / s) / (((x / s) * (x / s)) + 4.0f);
} else {
tmp = (1.0f / s) / (4.0f + ((x * x) * (1.0f / (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 <= 1.9999999996399175e-23) then
tmp = (1.0e0 / s) / (((x / s) * (x / s)) + 4.0e0)
else
tmp = (1.0e0 / s) / (4.0e0 + ((x * x) * (1.0e0 / (s * s))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.9999999996399175e-23)) tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(Float32(x / s) * Float32(x / s)) + Float32(4.0))); else tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(Float32(x * x) * Float32(Float32(1.0) / Float32(s * s))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.9999999996399175e-23)) tmp = (single(1.0) / s) / (((x / s) * (x / s)) + single(4.0)); else tmp = (single(1.0) / s) / (single(4.0) + ((x * x) * (single(1.0) / (s * s)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.9999999996399175 \cdot 10^{-23}:\\
\;\;\;\;\frac{\frac{1}{s}}{\frac{x}{s} \cdot \frac{x}{s} + 4}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{s}}{4 + \left(x \cdot x\right) \cdot \frac{1}{s \cdot s}}\\
\end{array}
\end{array}
if x < 2e-23Initial program 99.6%
Simplified99.7%
Taylor expanded in s around inf 56.6%
associate-+r+56.6%
distribute-lft1-in56.6%
metadata-eval56.6%
mul0-lft72.2%
associate-+r+72.2%
metadata-eval72.2%
unpow272.2%
sqr-abs72.2%
unpow272.2%
Simplified72.2%
times-frac72.9%
Applied egg-rr72.9%
if 2e-23 < x Initial program 99.9%
Simplified99.9%
Taylor expanded in s around inf 47.7%
associate-+r+47.7%
distribute-lft1-in47.7%
metadata-eval47.7%
mul0-lft85.4%
associate-+r+85.4%
metadata-eval85.4%
unpow285.4%
sqr-abs85.4%
unpow285.4%
Simplified85.4%
div-inv86.5%
Applied egg-rr86.5%
Final simplification78.7%
(FPCore (x s) :precision binary32 (if (<= x 1.9999999996399175e-23) (/ (/ 1.0 s) (+ (* (/ x s) (/ x s)) 4.0)) (/ (/ 1.0 s) (+ 4.0 (/ (* x x) (* s s))))))
float code(float x, float s) {
float tmp;
if (x <= 1.9999999996399175e-23f) {
tmp = (1.0f / s) / (((x / s) * (x / s)) + 4.0f);
} else {
tmp = (1.0f / s) / (4.0f + ((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 <= 1.9999999996399175e-23) then
tmp = (1.0e0 / s) / (((x / s) * (x / s)) + 4.0e0)
else
tmp = (1.0e0 / s) / (4.0e0 + ((x * x) / (s * s)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.9999999996399175e-23)) tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(Float32(x / s) * Float32(x / s)) + Float32(4.0))); else tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(Float32(x * x) / Float32(s * s)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.9999999996399175e-23)) tmp = (single(1.0) / s) / (((x / s) * (x / s)) + single(4.0)); else tmp = (single(1.0) / s) / (single(4.0) + ((x * x) / (s * s))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.9999999996399175 \cdot 10^{-23}:\\
\;\;\;\;\frac{\frac{1}{s}}{\frac{x}{s} \cdot \frac{x}{s} + 4}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{s}}{4 + \frac{x \cdot x}{s \cdot s}}\\
\end{array}
\end{array}
if x < 2e-23Initial program 99.6%
Simplified99.7%
Taylor expanded in s around inf 56.6%
associate-+r+56.6%
distribute-lft1-in56.6%
metadata-eval56.6%
mul0-lft72.2%
associate-+r+72.2%
metadata-eval72.2%
unpow272.2%
sqr-abs72.2%
unpow272.2%
Simplified72.2%
times-frac72.9%
Applied egg-rr72.9%
if 2e-23 < x Initial program 99.9%
Simplified99.9%
Taylor expanded in s around inf 47.7%
associate-+r+47.7%
distribute-lft1-in47.7%
metadata-eval47.7%
mul0-lft85.4%
associate-+r+85.4%
metadata-eval85.4%
unpow285.4%
sqr-abs85.4%
unpow285.4%
Simplified85.4%
Final simplification78.2%
(FPCore (x s) :precision binary32 (/ (/ 1.0 s) (+ (* (/ x s) (/ x s)) 4.0)))
float code(float x, float s) {
return (1.0f / s) / (((x / s) * (x / s)) + 4.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / s) / (((x / s) * (x / s)) + 4.0e0)
end function
function code(x, s) return Float32(Float32(Float32(1.0) / s) / Float32(Float32(Float32(x / s) * Float32(x / s)) + Float32(4.0))) end
function tmp = code(x, s) tmp = (single(1.0) / s) / (((x / s) * (x / s)) + single(4.0)); end
\begin{array}{l}
\\
\frac{\frac{1}{s}}{\frac{x}{s} \cdot \frac{x}{s} + 4}
\end{array}
Initial program 99.7%
Simplified99.8%
Taylor expanded in s around inf 52.8%
associate-+r+52.8%
distribute-lft1-in52.8%
metadata-eval52.8%
mul0-lft77.8%
associate-+r+77.8%
metadata-eval77.8%
unpow277.8%
sqr-abs77.8%
unpow277.8%
Simplified77.8%
times-frac74.2%
Applied egg-rr74.2%
Final simplification74.2%
(FPCore (x s) :precision binary32 (if (<= x 3.999999989900971e-6) (/ 0.25 s) (/ 1.0 (* x (/ x s)))))
float code(float x, float s) {
float tmp;
if (x <= 3.999999989900971e-6f) {
tmp = 0.25f / s;
} else {
tmp = 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) :: tmp
if (x <= 3.999999989900971e-6) then
tmp = 0.25e0 / s
else
tmp = 1.0e0 / (x * (x / s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(3.999999989900971e-6)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(1.0) / Float32(x * Float32(x / s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(3.999999989900971e-6)) tmp = single(0.25) / s; else tmp = single(1.0) / (x * (x / s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.999999989900971 \cdot 10^{-6}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \frac{x}{s}}\\
\end{array}
\end{array}
if x < 3.99999999e-6Initial program 99.6%
*-lft-identity99.6%
associate-*r/99.6%
associate-/l*99.6%
distribute-frac-neg99.6%
exp-neg99.6%
associate-/r/99.6%
/-rgt-identity99.6%
associate-*l*99.6%
Simplified99.7%
Taylor expanded in s around inf 39.1%
if 3.99999999e-6 < x Initial program 100.0%
*-lft-identity100.0%
associate-*r/100.0%
associate-/l*100.0%
distribute-frac-neg100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in s around inf 2.6%
Simplified2.6%
add-exp-log2.6%
associate-/l*2.6%
Applied egg-rr2.6%
Taylor expanded in x around inf 78.6%
unpow278.6%
associate-*r/78.6%
Simplified78.6%
Final simplification50.6%
(FPCore (x s) :precision binary32 (if (<= x 3.999999989900971e-6) (/ 0.25 s) (/ 1.0 (/ (* x x) s))))
float code(float x, float s) {
float tmp;
if (x <= 3.999999989900971e-6f) {
tmp = 0.25f / s;
} else {
tmp = 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) :: tmp
if (x <= 3.999999989900971e-6) then
tmp = 0.25e0 / s
else
tmp = 1.0e0 / ((x * x) / s)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(3.999999989900971e-6)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(1.0) / Float32(Float32(x * x) / s)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(3.999999989900971e-6)) tmp = single(0.25) / s; else tmp = single(1.0) / ((x * x) / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.999999989900971 \cdot 10^{-6}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x}{s}}\\
\end{array}
\end{array}
if x < 3.99999999e-6Initial program 99.6%
*-lft-identity99.6%
associate-*r/99.6%
associate-/l*99.6%
distribute-frac-neg99.6%
exp-neg99.6%
associate-/r/99.6%
/-rgt-identity99.6%
associate-*l*99.6%
Simplified99.7%
Taylor expanded in s around inf 39.1%
if 3.99999999e-6 < x Initial program 100.0%
*-lft-identity100.0%
associate-*r/100.0%
associate-/l*100.0%
distribute-frac-neg100.0%
exp-neg100.0%
associate-/r/100.0%
/-rgt-identity100.0%
associate-*l*100.0%
Simplified100.0%
Taylor expanded in s around inf 2.6%
Simplified2.6%
Taylor expanded in x around inf 78.6%
unpow278.6%
Simplified78.6%
Final simplification50.6%
(FPCore (x s) :precision binary32 (if (<= x 3.999999989900971e-6) (/ 0.25 s) (/ s (* x x))))
float code(float x, float s) {
float tmp;
if (x <= 3.999999989900971e-6f) {
tmp = 0.25f / s;
} else {
tmp = 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 <= 3.999999989900971e-6) then
tmp = 0.25e0 / s
else
tmp = s / (x * x)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(3.999999989900971e-6)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(s / Float32(x * x)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(3.999999989900971e-6)) tmp = single(0.25) / s; else tmp = s / (x * x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.999999989900971 \cdot 10^{-6}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{s}{x \cdot x}\\
\end{array}
\end{array}
if x < 3.99999999e-6Initial program 99.6%
*-lft-identity99.6%
associate-*r/99.6%
associate-/l*99.6%
distribute-frac-neg99.6%
exp-neg99.6%
associate-/r/99.6%
/-rgt-identity99.6%
associate-*l*99.6%
Simplified99.7%
Taylor expanded in s around inf 39.1%
if 3.99999999e-6 < x Initial program 100.0%
Simplified100.0%
Taylor expanded in s around inf 33.1%
associate-+r+33.1%
distribute-lft1-in33.1%
metadata-eval33.1%
mul0-lft87.7%
associate-+r+87.7%
metadata-eval87.7%
unpow287.7%
sqr-abs87.7%
unpow287.7%
Simplified87.7%
Taylor expanded in s around 0 76.1%
unpow276.1%
Simplified76.1%
Final simplification49.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.7%
*-lft-identity99.7%
associate-*r/99.7%
associate-/l*99.7%
distribute-frac-neg99.7%
exp-neg99.7%
associate-/r/99.7%
/-rgt-identity99.7%
associate-*l*99.7%
Simplified99.8%
Taylor expanded in s around inf 28.9%
Final simplification28.9%
herbie shell --seed 2023200
(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))))))