
(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 12 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}
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= (fabs x_m) 0.019999999552965164) (/ (pow E (fma (log1p (exp (/ x_m s))) -2.0 (/ x_m s))) s) (/ (exp (/ (- x_m) s)) (* s 4.0))))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (fabsf(x_m) <= 0.019999999552965164f) {
tmp = powf(((float) M_E), fmaf(log1pf(expf((x_m / s))), -2.0f, (x_m / s))) / s;
} else {
tmp = expf((-x_m / s)) / (s * 4.0f);
}
return tmp;
}
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (abs(x_m) <= Float32(0.019999999552965164)) tmp = Float32((Float32(exp(1)) ^ fma(log1p(exp(Float32(x_m / s))), Float32(-2.0), Float32(x_m / s))) / s); else tmp = Float32(exp(Float32(Float32(-x_m) / s)) / Float32(s * Float32(4.0))); end return tmp end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;\left|x\_m\right| \leq 0.019999999552965164:\\
\;\;\;\;\frac{{e}^{\left(\mathsf{fma}\left(\mathsf{log1p}\left(e^{\frac{x\_m}{s}}\right), -2, \frac{x\_m}{s}\right)\right)}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\frac{-x\_m}{s}}}{s \cdot 4}\\
\end{array}
\end{array}
if (fabs.f32 x) < 0.0199999996Initial program 99.0%
fabs-neg99.0%
distribute-frac-neg99.0%
distribute-frac-neg299.0%
fabs-neg99.0%
*-commutative99.0%
fabs-neg99.0%
+-commutative99.0%
fabs-neg99.0%
Simplified99.1%
Applied egg-rr76.7%
*-lft-identity76.7%
*-commutative76.7%
exp-to-pow76.7%
log1p-undefine77.1%
*-commutative77.1%
rem-exp-log73.3%
exp-sum72.7%
exp-diff95.1%
associate--r+95.1%
exp-diff95.6%
cancel-sign-sub-inv95.6%
metadata-eval95.6%
Simplified99.3%
*-un-lft-identity99.3%
exp-prod99.5%
+-commutative99.5%
*-commutative99.5%
fma-define99.5%
Applied egg-rr99.5%
if 0.0199999996 < (fabs.f32 x) Initial program 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in s around inf 100.0%
*-commutative100.0%
Simplified100.0%
distribute-frac-neg100.0%
exp-neg100.0%
add-sqr-sqrt45.0%
fabs-sqr45.0%
add-sqr-sqrt46.7%
Applied egg-rr46.7%
rec-exp46.7%
distribute-frac-neg46.7%
Simplified46.7%
Final simplification70.6%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (let* ((t_0 (exp (/ (- (fabs x_m)) s)))) (/ t_0 (* (+ t_0 1.0) (+ s (/ s (exp (/ (fabs x_m) s))))))))
x_m = fabs(x);
float code(float x_m, float s) {
float t_0 = expf((-fabsf(x_m) / s));
return t_0 / ((t_0 + 1.0f) * (s + (s / expf((fabsf(x_m) / s)))));
}
x_m = abs(x)
real(4) function code(x_m, s)
real(4), intent (in) :: x_m
real(4), intent (in) :: s
real(4) :: t_0
t_0 = exp((-abs(x_m) / s))
code = t_0 / ((t_0 + 1.0e0) * (s + (s / exp((abs(x_m) / s)))))
end function
x_m = abs(x) function code(x_m, s) t_0 = exp(Float32(Float32(-abs(x_m)) / s)) return Float32(t_0 / Float32(Float32(t_0 + Float32(1.0)) * Float32(s + Float32(s / exp(Float32(abs(x_m) / s)))))) end
x_m = abs(x); function tmp = code(x_m, s) t_0 = exp((-abs(x_m) / s)); tmp = t_0 / ((t_0 + single(1.0)) * (s + (s / exp((abs(x_m) / s))))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := e^{\frac{-\left|x\_m\right|}{s}}\\
\frac{t\_0}{\left(t\_0 + 1\right) \cdot \left(s + \frac{s}{e^{\frac{\left|x\_m\right|}{s}}}\right)}
\end{array}
\end{array}
Initial program 99.6%
Simplified99.6%
Final simplification99.6%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= (fabs x_m) 0.019999999552965164) (/ 1.0 (* s (exp (- (* (log1p (exp (/ x_m s))) 2.0) (/ x_m s))))) (/ (exp (/ (- x_m) s)) (* s 4.0))))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (fabsf(x_m) <= 0.019999999552965164f) {
tmp = 1.0f / (s * expf(((log1pf(expf((x_m / s))) * 2.0f) - (x_m / s))));
} else {
tmp = expf((-x_m / s)) / (s * 4.0f);
}
return tmp;
}
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (abs(x_m) <= Float32(0.019999999552965164)) tmp = Float32(Float32(1.0) / Float32(s * exp(Float32(Float32(log1p(exp(Float32(x_m / s))) * Float32(2.0)) - Float32(x_m / s))))); else tmp = Float32(exp(Float32(Float32(-x_m) / s)) / Float32(s * Float32(4.0))); end return tmp end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;\left|x\_m\right| \leq 0.019999999552965164:\\
\;\;\;\;\frac{1}{s \cdot e^{\mathsf{log1p}\left(e^{\frac{x\_m}{s}}\right) \cdot 2 - \frac{x\_m}{s}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\frac{-x\_m}{s}}}{s \cdot 4}\\
\end{array}
\end{array}
if (fabs.f32 x) < 0.0199999996Initial program 99.0%
fabs-neg99.0%
distribute-frac-neg99.0%
distribute-frac-neg299.0%
fabs-neg99.0%
*-commutative99.0%
fabs-neg99.0%
+-commutative99.0%
fabs-neg99.0%
Simplified99.1%
distribute-frac-neg299.1%
distribute-frac-neg99.1%
*-un-lft-identity99.1%
times-frac99.1%
Applied egg-rr76.8%
*-commutative76.8%
clear-num76.7%
frac-times76.8%
metadata-eval76.8%
pow-to-exp76.7%
div-exp98.9%
log1p-undefine99.3%
Applied egg-rr99.3%
if 0.0199999996 < (fabs.f32 x) Initial program 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in s around inf 100.0%
*-commutative100.0%
Simplified100.0%
distribute-frac-neg100.0%
exp-neg100.0%
add-sqr-sqrt45.0%
fabs-sqr45.0%
add-sqr-sqrt46.7%
Applied egg-rr46.7%
rec-exp46.7%
distribute-frac-neg46.7%
Simplified46.7%
Final simplification70.5%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= (fabs x_m) 0.019999999552965164) (/ (exp (+ (/ x_m s) (* (log1p (exp (/ x_m s))) -2.0))) s) (/ (exp (/ (- x_m) s)) (* s 4.0))))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (fabsf(x_m) <= 0.019999999552965164f) {
tmp = expf(((x_m / s) + (log1pf(expf((x_m / s))) * -2.0f))) / s;
} else {
tmp = expf((-x_m / s)) / (s * 4.0f);
}
return tmp;
}
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (abs(x_m) <= Float32(0.019999999552965164)) tmp = Float32(exp(Float32(Float32(x_m / s) + Float32(log1p(exp(Float32(x_m / s))) * Float32(-2.0)))) / s); else tmp = Float32(exp(Float32(Float32(-x_m) / s)) / Float32(s * Float32(4.0))); end return tmp end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;\left|x\_m\right| \leq 0.019999999552965164:\\
\;\;\;\;\frac{e^{\frac{x\_m}{s} + \mathsf{log1p}\left(e^{\frac{x\_m}{s}}\right) \cdot -2}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\frac{-x\_m}{s}}}{s \cdot 4}\\
\end{array}
\end{array}
if (fabs.f32 x) < 0.0199999996Initial program 99.0%
fabs-neg99.0%
distribute-frac-neg99.0%
distribute-frac-neg299.0%
fabs-neg99.0%
*-commutative99.0%
fabs-neg99.0%
+-commutative99.0%
fabs-neg99.0%
Simplified99.1%
Applied egg-rr76.7%
*-lft-identity76.7%
*-commutative76.7%
exp-to-pow76.7%
log1p-undefine77.1%
*-commutative77.1%
rem-exp-log73.3%
exp-sum72.7%
exp-diff95.1%
associate--r+95.1%
exp-diff95.6%
cancel-sign-sub-inv95.6%
metadata-eval95.6%
Simplified99.3%
if 0.0199999996 < (fabs.f32 x) Initial program 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in s around inf 100.0%
*-commutative100.0%
Simplified100.0%
distribute-frac-neg100.0%
exp-neg100.0%
add-sqr-sqrt45.0%
fabs-sqr45.0%
add-sqr-sqrt46.7%
Applied egg-rr46.7%
rec-exp46.7%
distribute-frac-neg46.7%
Simplified46.7%
Final simplification70.6%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 0.5 (* s (+ 1.0 (exp (/ x_m s))))))
x_m = fabs(x);
float code(float x_m, float s) {
return 0.5f / (s * (1.0f + expf((x_m / s))));
}
x_m = abs(x)
real(4) function code(x_m, s)
real(4), intent (in) :: x_m
real(4), intent (in) :: s
code = 0.5e0 / (s * (1.0e0 + exp((x_m / s))))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(0.5) / Float32(s * Float32(Float32(1.0) + exp(Float32(x_m / s))))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(0.5) / (s * (single(1.0) + exp((x_m / s)))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{0.5}{s \cdot \left(1 + e^{\frac{x\_m}{s}}\right)}
\end{array}
Initial program 99.6%
fabs-neg99.6%
distribute-frac-neg99.6%
distribute-frac-neg299.6%
fabs-neg99.6%
*-commutative99.6%
fabs-neg99.6%
+-commutative99.6%
fabs-neg99.6%
Simplified99.6%
distribute-frac-neg299.6%
distribute-frac-neg99.6%
associate-*r*99.6%
distribute-frac-neg299.6%
distribute-frac-neg99.6%
+-commutative99.6%
distribute-frac-neg299.6%
distribute-frac-neg99.6%
+-commutative99.6%
Applied egg-rr65.2%
Taylor expanded in x around 0 58.6%
frac-times58.6%
metadata-eval58.6%
Applied egg-rr58.6%
Final simplification58.6%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (exp (/ (- x_m) s)) (* s 4.0)))
x_m = fabs(x);
float code(float x_m, float s) {
return expf((-x_m / s)) / (s * 4.0f);
}
x_m = abs(x)
real(4) function code(x_m, s)
real(4), intent (in) :: x_m
real(4), intent (in) :: s
code = exp((-x_m / s)) / (s * 4.0e0)
end function
x_m = abs(x) function code(x_m, s) return Float32(exp(Float32(Float32(-x_m) / s)) / Float32(s * Float32(4.0))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = exp((-x_m / s)) / (s * single(4.0)); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{e^{\frac{-x\_m}{s}}}{s \cdot 4}
\end{array}
Initial program 99.6%
*-commutative99.6%
Simplified99.6%
Taylor expanded in s around inf 94.1%
*-commutative94.1%
Simplified94.1%
distribute-frac-neg94.1%
exp-neg94.1%
add-sqr-sqrt47.6%
fabs-sqr47.6%
add-sqr-sqrt57.7%
Applied egg-rr57.7%
rec-exp57.6%
distribute-frac-neg57.6%
Simplified57.6%
Final simplification57.6%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 0.5 (+ (* s 2.0) (* x_m (+ 1.0 (* (/ x_m s) 0.5))))))
x_m = fabs(x);
float code(float x_m, float s) {
return 0.5f / ((s * 2.0f) + (x_m * (1.0f + ((x_m / s) * 0.5f))));
}
x_m = abs(x)
real(4) function code(x_m, s)
real(4), intent (in) :: x_m
real(4), intent (in) :: s
code = 0.5e0 / ((s * 2.0e0) + (x_m * (1.0e0 + ((x_m / s) * 0.5e0))))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(0.5) / Float32(Float32(s * Float32(2.0)) + Float32(x_m * Float32(Float32(1.0) + Float32(Float32(x_m / s) * Float32(0.5)))))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(0.5) / ((s * single(2.0)) + (x_m * (single(1.0) + ((x_m / s) * single(0.5))))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{0.5}{s \cdot 2 + x\_m \cdot \left(1 + \frac{x\_m}{s} \cdot 0.5\right)}
\end{array}
Initial program 99.6%
fabs-neg99.6%
distribute-frac-neg99.6%
distribute-frac-neg299.6%
fabs-neg99.6%
*-commutative99.6%
fabs-neg99.6%
+-commutative99.6%
fabs-neg99.6%
Simplified99.6%
distribute-frac-neg299.6%
distribute-frac-neg99.6%
associate-*r*99.6%
distribute-frac-neg299.6%
distribute-frac-neg99.6%
+-commutative99.6%
distribute-frac-neg299.6%
distribute-frac-neg99.6%
+-commutative99.6%
Applied egg-rr65.2%
Taylor expanded in x around 0 58.6%
frac-times58.6%
metadata-eval58.6%
Applied egg-rr58.6%
Taylor expanded in x around 0 65.9%
Final simplification65.9%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 9.999999747378752e-5) (/ 0.25 s) (* (/ 1.0 (/ x_m s)) (/ 0.5 s))))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 9.999999747378752e-5f) {
tmp = 0.25f / s;
} else {
tmp = (1.0f / (x_m / s)) * (0.5f / s);
}
return tmp;
}
x_m = abs(x)
real(4) function code(x_m, s)
real(4), intent (in) :: x_m
real(4), intent (in) :: s
real(4) :: tmp
if (x_m <= 9.999999747378752e-5) then
tmp = 0.25e0 / s
else
tmp = (1.0e0 / (x_m / s)) * (0.5e0 / s)
end if
code = tmp
end function
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (x_m <= Float32(9.999999747378752e-5)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(Float32(1.0) / Float32(x_m / s)) * Float32(Float32(0.5) / s)); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, s) tmp = single(0.0); if (x_m <= single(9.999999747378752e-5)) tmp = single(0.25) / s; else tmp = (single(1.0) / (x_m / s)) * (single(0.5) / s); end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 9.999999747378752 \cdot 10^{-5}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x\_m}{s}} \cdot \frac{0.5}{s}\\
\end{array}
\end{array}
if x < 9.99999975e-5Initial program 99.4%
fabs-neg99.4%
distribute-frac-neg99.4%
distribute-frac-neg299.4%
fabs-neg99.4%
*-commutative99.4%
fabs-neg99.4%
+-commutative99.4%
fabs-neg99.4%
Simplified99.5%
Taylor expanded in s around inf 36.2%
if 9.99999975e-5 < x Initial program 100.0%
fabs-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
fabs-neg100.0%
*-commutative100.0%
fabs-neg100.0%
+-commutative100.0%
fabs-neg100.0%
Simplified100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
associate-*r*100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
+-commutative100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
+-commutative100.0%
Applied egg-rr1.4%
Taylor expanded in x around 0 99.0%
Taylor expanded in x around 0 48.1%
Taylor expanded in x around inf 48.0%
Final simplification39.5%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 9.999999747378752e-5) (/ 0.25 s) (* (/ 0.5 s) (/ s x_m))))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 9.999999747378752e-5f) {
tmp = 0.25f / s;
} else {
tmp = (0.5f / s) * (s / x_m);
}
return tmp;
}
x_m = abs(x)
real(4) function code(x_m, s)
real(4), intent (in) :: x_m
real(4), intent (in) :: s
real(4) :: tmp
if (x_m <= 9.999999747378752e-5) then
tmp = 0.25e0 / s
else
tmp = (0.5e0 / s) * (s / x_m)
end if
code = tmp
end function
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (x_m <= Float32(9.999999747378752e-5)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(Float32(0.5) / s) * Float32(s / x_m)); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, s) tmp = single(0.0); if (x_m <= single(9.999999747378752e-5)) tmp = single(0.25) / s; else tmp = (single(0.5) / s) * (s / x_m); end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 9.999999747378752 \cdot 10^{-5}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{s} \cdot \frac{s}{x\_m}\\
\end{array}
\end{array}
if x < 9.99999975e-5Initial program 99.4%
fabs-neg99.4%
distribute-frac-neg99.4%
distribute-frac-neg299.4%
fabs-neg99.4%
*-commutative99.4%
fabs-neg99.4%
+-commutative99.4%
fabs-neg99.4%
Simplified99.5%
Taylor expanded in s around inf 36.2%
if 9.99999975e-5 < x Initial program 100.0%
fabs-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
fabs-neg100.0%
*-commutative100.0%
fabs-neg100.0%
+-commutative100.0%
fabs-neg100.0%
Simplified100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
associate-*r*100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
+-commutative100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
+-commutative100.0%
Applied egg-rr1.4%
Taylor expanded in x around 0 99.0%
Taylor expanded in x around 0 48.1%
Taylor expanded in x around inf 33.8%
Final simplification35.6%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 0.5 (* s (+ (/ x_m s) 2.0))))
x_m = fabs(x);
float code(float x_m, float s) {
return 0.5f / (s * ((x_m / s) + 2.0f));
}
x_m = abs(x)
real(4) function code(x_m, s)
real(4), intent (in) :: x_m
real(4), intent (in) :: s
code = 0.5e0 / (s * ((x_m / s) + 2.0e0))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(0.5) / Float32(s * Float32(Float32(x_m / s) + Float32(2.0)))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(0.5) / (s * ((x_m / s) + single(2.0))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{0.5}{s \cdot \left(\frac{x\_m}{s} + 2\right)}
\end{array}
Initial program 99.6%
fabs-neg99.6%
distribute-frac-neg99.6%
distribute-frac-neg299.6%
fabs-neg99.6%
*-commutative99.6%
fabs-neg99.6%
+-commutative99.6%
fabs-neg99.6%
Simplified99.6%
distribute-frac-neg299.6%
distribute-frac-neg99.6%
associate-*r*99.6%
distribute-frac-neg299.6%
distribute-frac-neg99.6%
+-commutative99.6%
distribute-frac-neg299.6%
distribute-frac-neg99.6%
+-commutative99.6%
Applied egg-rr65.2%
Taylor expanded in x around 0 58.6%
Taylor expanded in x around 0 52.6%
frac-times52.6%
metadata-eval52.6%
+-commutative52.6%
Applied egg-rr52.6%
Final simplification52.6%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 9.999999747378752e-5) (/ 0.25 s) (/ 0.5 x_m)))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 9.999999747378752e-5f) {
tmp = 0.25f / s;
} else {
tmp = 0.5f / x_m;
}
return tmp;
}
x_m = abs(x)
real(4) function code(x_m, s)
real(4), intent (in) :: x_m
real(4), intent (in) :: s
real(4) :: tmp
if (x_m <= 9.999999747378752e-5) then
tmp = 0.25e0 / s
else
tmp = 0.5e0 / x_m
end if
code = tmp
end function
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (x_m <= Float32(9.999999747378752e-5)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(0.5) / x_m); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, s) tmp = single(0.0); if (x_m <= single(9.999999747378752e-5)) tmp = single(0.25) / s; else tmp = single(0.5) / x_m; end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 9.999999747378752 \cdot 10^{-5}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{x\_m}\\
\end{array}
\end{array}
if x < 9.99999975e-5Initial program 99.4%
fabs-neg99.4%
distribute-frac-neg99.4%
distribute-frac-neg299.4%
fabs-neg99.4%
*-commutative99.4%
fabs-neg99.4%
+-commutative99.4%
fabs-neg99.4%
Simplified99.5%
Taylor expanded in s around inf 36.2%
if 9.99999975e-5 < x Initial program 100.0%
fabs-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
fabs-neg100.0%
*-commutative100.0%
fabs-neg100.0%
+-commutative100.0%
fabs-neg100.0%
Simplified100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
associate-*r*100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
+-commutative100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
+-commutative100.0%
Applied egg-rr1.4%
Taylor expanded in x around 0 99.0%
Taylor expanded in x around 0 48.1%
Taylor expanded in x around inf 10.9%
Final simplification29.3%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 0.25 s))
x_m = fabs(x);
float code(float x_m, float s) {
return 0.25f / s;
}
x_m = abs(x)
real(4) function code(x_m, s)
real(4), intent (in) :: x_m
real(4), intent (in) :: s
code = 0.25e0 / s
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(0.25) / s) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(0.25) / s; end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{0.25}{s}
\end{array}
Initial program 99.6%
fabs-neg99.6%
distribute-frac-neg99.6%
distribute-frac-neg299.6%
fabs-neg99.6%
*-commutative99.6%
fabs-neg99.6%
+-commutative99.6%
fabs-neg99.6%
Simplified99.6%
Taylor expanded in s around inf 27.7%
Final simplification27.7%
herbie shell --seed 2024080
(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))))))