
(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 11 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
(let* ((t_0 (exp (/ x_m s))))
(if (<= (fabs x_m) 3.9999998989515007e-5)
(/ (exp (- (/ x_m s) (* 2.0 (log1p t_0)))) s)
(/ -0.25 (* x_m t_0)))))x_m = fabs(x);
float code(float x_m, float s) {
float t_0 = expf((x_m / s));
float tmp;
if (fabsf(x_m) <= 3.9999998989515007e-5f) {
tmp = expf(((x_m / s) - (2.0f * log1pf(t_0)))) / s;
} else {
tmp = -0.25f / (x_m * t_0);
}
return tmp;
}
x_m = abs(x) function code(x_m, s) t_0 = exp(Float32(x_m / s)) tmp = Float32(0.0) if (abs(x_m) <= Float32(3.9999998989515007e-5)) tmp = Float32(exp(Float32(Float32(x_m / s) - Float32(Float32(2.0) * log1p(t_0)))) / s); else tmp = Float32(Float32(-0.25) / Float32(x_m * t_0)); end return tmp end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := e^{\frac{x\_m}{s}}\\
\mathbf{if}\;\left|x\_m\right| \leq 3.9999998989515007 \cdot 10^{-5}:\\
\;\;\;\;\frac{e^{\frac{x\_m}{s} - 2 \cdot \mathsf{log1p}\left(t\_0\right)}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.25}{x\_m \cdot t\_0}\\
\end{array}
\end{array}
if (fabs.f32 x) < 3.9999999e-5Initial program 99.1%
fabs-neg99.1%
distribute-frac-neg99.1%
distribute-frac-neg299.1%
fabs-neg99.1%
*-commutative99.1%
fabs-neg99.1%
+-commutative99.1%
fabs-neg99.1%
Simplified99.2%
Applied egg-rr75.7%
*-lft-identity75.7%
*-commutative75.7%
exp-to-pow75.7%
log1p-undefine75.9%
*-commutative75.9%
rem-exp-log71.9%
prod-exp71.4%
exp-diff94.5%
associate--r+94.8%
exp-diff95.2%
rem-exp-log99.4%
Simplified99.4%
if 3.9999999e-5 < (fabs.f32 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%
Taylor expanded in x around 0 100.0%
associate-/r*100.0%
exp-prod100.0%
rem-square-sqrt53.8%
fabs-sqr53.8%
rem-square-sqrt55.2%
exp-prod55.2%
neg-mul-155.2%
distribute-neg-frac255.2%
+-commutative55.2%
exp-prod55.2%
rem-square-sqrt53.8%
fabs-sqr53.8%
rem-square-sqrt53.8%
exp-prod53.8%
neg-mul-153.8%
distribute-neg-frac253.8%
Simplified53.8%
Taylor expanded in x around 0 54.7%
associate-*r/54.7%
*-commutative54.7%
Simplified54.7%
Taylor expanded in x around inf 55.2%
neg-mul-155.2%
distribute-neg-frac55.2%
Simplified55.2%
clear-num55.2%
un-div-inv55.2%
div-inv55.2%
add-sqr-sqrt1.5%
sqrt-unprod3.1%
distribute-frac-neg3.1%
distribute-frac-neg3.1%
sqr-neg3.1%
sqrt-unprod1.7%
add-sqr-sqrt47.9%
exp-neg47.9%
distribute-frac-neg47.9%
add-sqr-sqrt46.2%
sqrt-unprod100.0%
distribute-frac-neg100.0%
distribute-frac-neg100.0%
sqr-neg100.0%
Applied egg-rr55.2%
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%
*-commutative99.6%
fabs-neg99.6%
distribute-lft-in99.7%
*-rgt-identity99.7%
fabs-neg99.7%
distribute-rgt-in99.7%
cancel-sign-sub99.7%
Simplified99.7%
Final simplification99.7%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (let* ((t_0 (exp (/ x_m (- s))))) (/ (/ t_0 s) (pow (+ 1.0 t_0) 2.0))))
x_m = fabs(x);
float code(float x_m, float s) {
float t_0 = expf((x_m / -s));
return (t_0 / s) / powf((1.0f + t_0), 2.0f);
}
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((x_m / -s))
code = (t_0 / s) / ((1.0e0 + t_0) ** 2.0e0)
end function
x_m = abs(x) function code(x_m, s) t_0 = exp(Float32(x_m / Float32(-s))) return Float32(Float32(t_0 / s) / (Float32(Float32(1.0) + t_0) ^ Float32(2.0))) end
x_m = abs(x); function tmp = code(x_m, s) t_0 = exp((x_m / -s)); tmp = (t_0 / s) / ((single(1.0) + t_0) ^ single(2.0)); end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := e^{\frac{x\_m}{-s}}\\
\frac{\frac{t\_0}{s}}{{\left(1 + t\_0\right)}^{2}}
\end{array}
\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.7%
Taylor expanded in x around 0 99.7%
associate-/r*99.6%
exp-prod99.6%
rem-square-sqrt56.1%
fabs-sqr56.1%
rem-square-sqrt63.5%
exp-prod63.5%
neg-mul-163.5%
distribute-neg-frac263.5%
+-commutative63.5%
exp-prod63.5%
rem-square-sqrt56.1%
fabs-sqr56.1%
rem-square-sqrt65.2%
exp-prod65.3%
neg-mul-165.3%
distribute-neg-frac265.3%
Simplified65.3%
Final simplification65.3%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (/ (exp (/ x_m (- s))) s) (+ 4.0 (/ (* x_m -4.0) s))))
x_m = fabs(x);
float code(float x_m, float s) {
return (expf((x_m / -s)) / s) / (4.0f + ((x_m * -4.0f) / s));
}
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 + ((x_m * (-4.0e0)) / s))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(exp(Float32(x_m / Float32(-s))) / s) / Float32(Float32(4.0) + Float32(Float32(x_m * Float32(-4.0)) / s))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = (exp((x_m / -s)) / s) / (single(4.0) + ((x_m * single(-4.0)) / s)); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\frac{e^{\frac{x\_m}{-s}}}{s}}{4 + \frac{x\_m \cdot -4}{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.7%
Taylor expanded in x around 0 99.7%
associate-/r*99.6%
exp-prod99.6%
rem-square-sqrt56.1%
fabs-sqr56.1%
rem-square-sqrt63.5%
exp-prod63.5%
neg-mul-163.5%
distribute-neg-frac263.5%
+-commutative63.5%
exp-prod63.5%
rem-square-sqrt56.1%
fabs-sqr56.1%
rem-square-sqrt65.2%
exp-prod65.3%
neg-mul-165.3%
distribute-neg-frac265.3%
Simplified65.3%
Taylor expanded in x around 0 62.8%
associate-*r/62.8%
*-commutative62.8%
Simplified62.8%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 2.00000009162741e-18) (/ 0.25 s) (/ -0.25 (* x_m (exp (/ x_m s))))))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 2.00000009162741e-18f) {
tmp = 0.25f / s;
} else {
tmp = -0.25f / (x_m * expf((x_m / 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 <= 2.00000009162741e-18) then
tmp = 0.25e0 / s
else
tmp = (-0.25e0) / (x_m * exp((x_m / s)))
end if
code = tmp
end function
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (x_m <= Float32(2.00000009162741e-18)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(-0.25) / Float32(x_m * exp(Float32(x_m / s)))); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, s) tmp = single(0.0); if (x_m <= single(2.00000009162741e-18)) tmp = single(0.25) / s; else tmp = single(-0.25) / (x_m * exp((x_m / s))); end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 2.00000009162741 \cdot 10^{-18}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.25}{x\_m \cdot e^{\frac{x\_m}{s}}}\\
\end{array}
\end{array}
if x < 2.00000009e-18Initial program 99.5%
fabs-neg99.5%
distribute-frac-neg99.5%
distribute-frac-neg299.5%
fabs-neg99.5%
*-commutative99.5%
fabs-neg99.5%
+-commutative99.5%
fabs-neg99.5%
Simplified99.5%
Taylor expanded in s around inf 33.8%
if 2.00000009e-18 < x Initial program 99.8%
fabs-neg99.8%
distribute-frac-neg99.8%
distribute-frac-neg299.8%
fabs-neg99.8%
*-commutative99.8%
fabs-neg99.8%
+-commutative99.8%
fabs-neg99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
associate-/r*99.8%
exp-prod99.8%
rem-square-sqrt99.8%
fabs-sqr99.8%
rem-square-sqrt99.8%
exp-prod99.8%
neg-mul-199.8%
distribute-neg-frac299.8%
+-commutative99.8%
exp-prod99.8%
rem-square-sqrt99.8%
fabs-sqr99.8%
rem-square-sqrt99.8%
exp-prod99.8%
neg-mul-199.8%
distribute-neg-frac299.8%
Simplified99.8%
Taylor expanded in x around 0 99.3%
associate-*r/99.3%
*-commutative99.3%
Simplified99.3%
Taylor expanded in x around inf 91.5%
neg-mul-191.5%
distribute-neg-frac91.5%
Simplified91.5%
clear-num91.5%
un-div-inv91.5%
div-inv91.5%
add-sqr-sqrt-0.0%
sqrt-unprod3.1%
distribute-frac-neg3.1%
distribute-frac-neg3.1%
sqr-neg3.1%
sqrt-unprod3.1%
add-sqr-sqrt3.1%
exp-neg3.1%
distribute-frac-neg3.1%
add-sqr-sqrt-0.0%
sqrt-unprod91.5%
distribute-frac-neg91.5%
distribute-frac-neg91.5%
sqr-neg91.5%
Applied egg-rr91.5%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (/ 1.0 (exp (/ x_m s))) (* s 4.0)))
x_m = fabs(x);
float code(float x_m, float s) {
return (1.0f / 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 = (1.0e0 / exp((x_m / s))) / (s * 4.0e0)
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(Float32(1.0) / exp(Float32(x_m / s))) / Float32(s * Float32(4.0))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = (single(1.0) / exp((x_m / s))) / (s * single(4.0)); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\frac{1}{e^{\frac{x\_m}{s}}}}{s \cdot 4}
\end{array}
Initial program 99.6%
*-commutative99.6%
distribute-lft-in99.7%
*-rgt-identity99.7%
fabs-neg99.7%
+-commutative99.7%
fma-define99.7%
fabs-neg99.7%
Simplified99.7%
Taylor expanded in s around inf 94.7%
*-commutative94.7%
Simplified94.7%
div-inv94.7%
exp-prod82.2%
neg-mul-182.2%
exp-prod82.2%
add-sqr-sqrt47.1%
fabs-sqr47.1%
add-sqr-sqrt55.4%
exp-prod55.4%
neg-mul-155.4%
exp-prod61.5%
div-inv61.5%
distribute-frac-neg61.5%
exp-neg61.5%
Applied egg-rr61.5%
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(x_m / Float32(-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%
distribute-lft-in99.7%
*-rgt-identity99.7%
fabs-neg99.7%
+-commutative99.7%
fma-define99.7%
fabs-neg99.7%
Simplified99.7%
Taylor expanded in s around inf 94.7%
*-commutative94.7%
Simplified94.7%
neg-fabs94.7%
add-sqr-sqrt40.8%
fabs-sqr40.8%
add-sqr-sqrt55.3%
neg-sub055.3%
sub-neg55.3%
add-sqr-sqrt40.8%
sqrt-unprod93.3%
sqr-neg93.3%
sqrt-unprod54.0%
add-sqr-sqrt61.5%
Applied egg-rr61.5%
+-lft-identity61.5%
Simplified61.5%
Final simplification61.5%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 3.9999998989515007e-5) (/ 0.25 s) (/ (/ 1.0 s) (* x_m (/ -4.0 s)))))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 3.9999998989515007e-5f) {
tmp = 0.25f / s;
} else {
tmp = (1.0f / s) / (x_m * (-4.0f / 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 <= 3.9999998989515007e-5) then
tmp = 0.25e0 / s
else
tmp = (1.0e0 / s) / (x_m * ((-4.0e0) / s))
end if
code = tmp
end function
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (x_m <= Float32(3.9999998989515007e-5)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(Float32(1.0) / s) / Float32(x_m * Float32(Float32(-4.0) / s))); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, s) tmp = single(0.0); if (x_m <= single(3.9999998989515007e-5)) tmp = single(0.25) / s; else tmp = (single(1.0) / s) / (x_m * (single(-4.0) / s)); end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 3.9999998989515007 \cdot 10^{-5}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{s}}{x\_m \cdot \frac{-4}{s}}\\
\end{array}
\end{array}
if x < 3.9999999e-5Initial program 99.5%
fabs-neg99.5%
distribute-frac-neg99.5%
distribute-frac-neg299.5%
fabs-neg99.5%
*-commutative99.5%
fabs-neg99.5%
+-commutative99.5%
fabs-neg99.5%
Simplified99.5%
Taylor expanded in s around inf 34.2%
if 3.9999999e-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%
Taylor expanded in x around 0 100.0%
associate-/r*100.0%
exp-prod100.0%
rem-square-sqrt100.0%
fabs-sqr100.0%
rem-square-sqrt100.0%
exp-prod100.0%
neg-mul-1100.0%
distribute-neg-frac2100.0%
+-commutative100.0%
exp-prod100.0%
rem-square-sqrt100.0%
fabs-sqr100.0%
rem-square-sqrt100.0%
exp-prod100.0%
neg-mul-1100.0%
distribute-neg-frac2100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
associate-*r/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 49.3%
Taylor expanded in x around inf 49.3%
metadata-eval49.3%
distribute-lft-neg-in49.3%
associate-*r/49.3%
*-commutative49.3%
associate-*r/50.5%
metadata-eval50.5%
associate-*r/50.5%
distribute-rgt-neg-in50.5%
associate-*r/50.5%
metadata-eval50.5%
distribute-neg-frac50.5%
metadata-eval50.5%
Simplified50.5%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (/ 1.0 s) (+ 4.0 (/ (* x_m -4.0) s))))
x_m = fabs(x);
float code(float x_m, float s) {
return (1.0f / s) / (4.0f + ((x_m * -4.0f) / s));
}
x_m = abs(x)
real(4) function code(x_m, s)
real(4), intent (in) :: x_m
real(4), intent (in) :: s
code = (1.0e0 / s) / (4.0e0 + ((x_m * (-4.0e0)) / s))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(Float32(x_m * Float32(-4.0)) / s))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = (single(1.0) / s) / (single(4.0) + ((x_m * single(-4.0)) / s)); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\frac{1}{s}}{4 + \frac{x\_m \cdot -4}{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.7%
Taylor expanded in x around 0 99.7%
associate-/r*99.6%
exp-prod99.6%
rem-square-sqrt56.1%
fabs-sqr56.1%
rem-square-sqrt63.5%
exp-prod63.5%
neg-mul-163.5%
distribute-neg-frac263.5%
+-commutative63.5%
exp-prod63.5%
rem-square-sqrt56.1%
fabs-sqr56.1%
rem-square-sqrt65.2%
exp-prod65.3%
neg-mul-165.3%
distribute-neg-frac265.3%
Simplified65.3%
Taylor expanded in x around 0 62.8%
associate-*r/62.8%
*-commutative62.8%
Simplified62.8%
Taylor expanded in x around 0 47.3%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 3.9999998989515007e-5) (/ 0.25 s) (/ -0.25 x_m)))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 3.9999998989515007e-5f) {
tmp = 0.25f / s;
} else {
tmp = -0.25f / 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 <= 3.9999998989515007e-5) then
tmp = 0.25e0 / s
else
tmp = (-0.25e0) / 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(3.9999998989515007e-5)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(-0.25) / 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(3.9999998989515007e-5)) tmp = single(0.25) / s; else tmp = single(-0.25) / x_m; end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 3.9999998989515007 \cdot 10^{-5}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.25}{x\_m}\\
\end{array}
\end{array}
if x < 3.9999999e-5Initial program 99.5%
fabs-neg99.5%
distribute-frac-neg99.5%
distribute-frac-neg299.5%
fabs-neg99.5%
*-commutative99.5%
fabs-neg99.5%
+-commutative99.5%
fabs-neg99.5%
Simplified99.5%
Taylor expanded in s around inf 34.2%
if 3.9999999e-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%
Taylor expanded in x around 0 100.0%
associate-/r*100.0%
exp-prod100.0%
rem-square-sqrt100.0%
fabs-sqr100.0%
rem-square-sqrt100.0%
exp-prod100.0%
neg-mul-1100.0%
distribute-neg-frac2100.0%
+-commutative100.0%
exp-prod100.0%
rem-square-sqrt100.0%
fabs-sqr100.0%
rem-square-sqrt100.0%
exp-prod100.0%
neg-mul-1100.0%
distribute-neg-frac2100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
associate-*r/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 49.3%
Taylor expanded in s around 0 11.4%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ -0.25 x_m))
x_m = fabs(x);
float code(float x_m, float s) {
return -0.25f / x_m;
}
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) / x_m
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(-0.25) / x_m) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(-0.25) / x_m; end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{-0.25}{x\_m}
\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.7%
Taylor expanded in x around 0 99.7%
associate-/r*99.6%
exp-prod99.6%
rem-square-sqrt56.1%
fabs-sqr56.1%
rem-square-sqrt63.5%
exp-prod63.5%
neg-mul-163.5%
distribute-neg-frac263.5%
+-commutative63.5%
exp-prod63.5%
rem-square-sqrt56.1%
fabs-sqr56.1%
rem-square-sqrt65.2%
exp-prod65.3%
neg-mul-165.3%
distribute-neg-frac265.3%
Simplified65.3%
Taylor expanded in x around 0 62.8%
associate-*r/62.8%
*-commutative62.8%
Simplified62.8%
Taylor expanded in x around 0 47.3%
Taylor expanded in s around 0 8.9%
herbie shell --seed 2024144
(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))))))