
(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}
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (let* ((t_0 (exp (/ x_m (- s))))) (/ (/ t_0 s) (pow (+ t_0 1.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((t_0 + 1.0f), 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) / ((t_0 + 1.0e0) ** 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(t_0 + Float32(1.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) / ((t_0 + single(1.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(t\_0 + 1\right)}^{2}}
\end{array}
\end{array}
Initial 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.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.4%
mul-1-neg99.4%
rec-exp99.4%
rem-square-sqrt52.0%
fabs-sqr52.0%
rem-square-sqrt66.2%
rec-exp66.2%
distribute-neg-frac266.2%
Simplified67.2%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= (fabs x_m) 0.800000011920929) (/ (exp (+ (/ x_m s) (* -2.0 (log1p (exp (/ x_m s)))))) s) 0.0))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (fabsf(x_m) <= 0.800000011920929f) {
tmp = expf(((x_m / s) + (-2.0f * log1pf(expf((x_m / s)))))) / s;
} else {
tmp = 0.0f;
}
return tmp;
}
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (abs(x_m) <= Float32(0.800000011920929)) tmp = Float32(exp(Float32(Float32(x_m / s) + Float32(Float32(-2.0) * log1p(exp(Float32(x_m / s)))))) / s); else tmp = Float32(0.0); end return tmp end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;\left|x\_m\right| \leq 0.800000011920929:\\
\;\;\;\;\frac{e^{\frac{x\_m}{s} + -2 \cdot \mathsf{log1p}\left(e^{\frac{x\_m}{s}}\right)}}{s}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if (fabs.f32 x) < 0.800000012Initial program 98.7%
fabs-neg98.7%
distribute-frac-neg98.7%
distribute-frac-neg298.7%
fabs-neg98.7%
*-commutative98.7%
fabs-neg98.7%
+-commutative98.7%
fabs-neg98.7%
Simplified98.8%
Applied egg-rr80.1%
*-lft-identity80.1%
*-commutative80.1%
exp-to-pow80.0%
log1p-undefine80.1%
*-commutative80.1%
rem-exp-log76.1%
exp-sum76.5%
exp-diff94.6%
associate--r+95.0%
exp-diff94.7%
cancel-sign-sub-inv94.7%
metadata-eval94.7%
rem-exp-log98.8%
Simplified98.8%
if 0.800000012 < (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%
Applied egg-rr39.1%
Taylor expanded in s around inf 100.0%
Final simplification99.4%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (let* ((t_0 (exp (/ x_m (- s))))) (/ (/ t_0 (+ t_0 1.0)) (+ s (/ s (+ 1.0 (/ x_m s)))))))
x_m = fabs(x);
float code(float x_m, float s) {
float t_0 = expf((x_m / -s));
return (t_0 / (t_0 + 1.0f)) / (s + (s / (1.0f + (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((x_m / -s))
code = (t_0 / (t_0 + 1.0e0)) / (s + (s / (1.0e0 + (x_m / s))))
end function
x_m = abs(x) function code(x_m, s) t_0 = exp(Float32(x_m / Float32(-s))) return Float32(Float32(t_0 / Float32(t_0 + Float32(1.0))) / Float32(s + Float32(s / Float32(Float32(1.0) + Float32(x_m / s))))) end
x_m = abs(x); function tmp = code(x_m, s) t_0 = exp((x_m / -s)); tmp = (t_0 / (t_0 + single(1.0))) / (s + (s / (single(1.0) + (x_m / s)))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := e^{\frac{x\_m}{-s}}\\
\frac{\frac{t\_0}{t\_0 + 1}}{s + \frac{s}{1 + \frac{x\_m}{s}}}
\end{array}
\end{array}
Initial program 99.4%
*-commutative99.4%
fabs-neg99.4%
+-commutative99.4%
fabs-neg99.4%
distribute-lft-in99.4%
*-rgt-identity99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.4%
Simplified67.2%
Taylor expanded in x around 0 63.7%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (/ (exp (/ x_m (- s))) s) (+ 4.0 (* (/ x_m s) -4.0))))
x_m = fabs(x);
float code(float x_m, float s) {
return (expf((x_m / -s)) / s) / (4.0f + ((x_m / 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 + ((x_m / s) * (-4.0e0)))
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 / s) * Float32(-4.0)))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = (exp((x_m / -s)) / s) / (single(4.0) + ((x_m / s) * single(-4.0))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\frac{e^{\frac{x\_m}{-s}}}{s}}{4 + \frac{x\_m}{s} \cdot -4}
\end{array}
Initial 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.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.4%
mul-1-neg99.4%
rec-exp99.4%
rem-square-sqrt52.0%
fabs-sqr52.0%
rem-square-sqrt66.2%
rec-exp66.2%
distribute-neg-frac266.2%
Simplified67.2%
Taylor expanded in x around 0 63.5%
*-commutative63.5%
Simplified63.5%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 1.0000000195414814e-25) (/ (+ 0.25 (* (/ x_m (* s (/ s x_m))) -0.0625)) s) (/ (* (exp (/ x_m (- s))) 0.5) s)))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 1.0000000195414814e-25f) {
tmp = (0.25f + ((x_m / (s * (s / x_m))) * -0.0625f)) / s;
} else {
tmp = (expf((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 <= 1.0000000195414814e-25) then
tmp = (0.25e0 + ((x_m / (s * (s / x_m))) * (-0.0625e0))) / s
else
tmp = (exp((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(1.0000000195414814e-25)) tmp = Float32(Float32(Float32(0.25) + Float32(Float32(x_m / Float32(s * Float32(s / x_m))) * Float32(-0.0625))) / s); else tmp = Float32(Float32(exp(Float32(x_m / Float32(-s))) * 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(1.0000000195414814e-25)) tmp = (single(0.25) + ((x_m / (s * (s / x_m))) * single(-0.0625))) / s; else tmp = (exp((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 1.0000000195414814 \cdot 10^{-25}:\\
\;\;\;\;\frac{0.25 + \frac{x\_m}{s \cdot \frac{s}{x\_m}} \cdot -0.0625}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\frac{x\_m}{-s}} \cdot 0.5}{s}\\
\end{array}
\end{array}
if x < 1.00000002e-25Initial 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-rr97.1%
*-lft-identity97.1%
*-commutative97.1%
exp-to-pow97.0%
log1p-undefine97.1%
*-commutative97.1%
rem-exp-log94.0%
exp-sum93.8%
exp-diff96.1%
associate--r+96.3%
exp-diff96.2%
cancel-sign-sub-inv96.2%
metadata-eval96.2%
rem-exp-log99.2%
Simplified99.2%
*-un-lft-identity99.2%
exp-prod99.1%
+-commutative99.1%
fma-define99.1%
Applied egg-rr99.1%
Taylor expanded in x around 0 30.2%
*-commutative30.2%
unpow230.2%
unpow230.2%
times-frac38.6%
unpow238.6%
Simplified38.6%
unpow238.6%
clear-num38.6%
frac-times38.6%
*-un-lft-identity38.6%
Applied egg-rr38.6%
if 1.00000002e-25 < x Initial program 99.7%
*-commutative99.7%
fabs-neg99.7%
+-commutative99.7%
fabs-neg99.7%
distribute-lft-in99.7%
*-rgt-identity99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
associate-/r*99.7%
Simplified99.7%
Taylor expanded in x around 0 96.9%
Taylor expanded in x around 0 95.8%
Taylor expanded in x around inf 92.3%
associate-*r/92.3%
mul-1-neg92.3%
distribute-neg-frac292.3%
Simplified92.3%
Final simplification62.1%
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(Float32(exp(Float32(x_m / Float32(-s))) / 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{\frac{e^{\frac{x\_m}{-s}}}{s}}{4}
\end{array}
Initial 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.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.4%
mul-1-neg99.4%
rec-exp99.4%
rem-square-sqrt52.0%
fabs-sqr52.0%
rem-square-sqrt66.2%
rec-exp66.2%
distribute-neg-frac266.2%
Simplified67.2%
Taylor expanded in x around 0 63.5%
*-commutative63.5%
Simplified63.5%
Taylor expanded in x around 0 63.0%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 1.0000000195414814e-25) (/ (+ 0.25 (* (/ x_m (* s (/ s x_m))) -0.0625)) s) 0.0))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 1.0000000195414814e-25f) {
tmp = (0.25f + ((x_m / (s * (s / x_m))) * -0.0625f)) / s;
} else {
tmp = 0.0f;
}
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 <= 1.0000000195414814e-25) then
tmp = (0.25e0 + ((x_m / (s * (s / x_m))) * (-0.0625e0))) / s
else
tmp = 0.0e0
end if
code = tmp
end function
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (x_m <= Float32(1.0000000195414814e-25)) tmp = Float32(Float32(Float32(0.25) + Float32(Float32(x_m / Float32(s * Float32(s / x_m))) * Float32(-0.0625))) / s); else tmp = Float32(0.0); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, s) tmp = single(0.0); if (x_m <= single(1.0000000195414814e-25)) tmp = (single(0.25) + ((x_m / (s * (s / x_m))) * single(-0.0625))) / s; else tmp = single(0.0); end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 1.0000000195414814 \cdot 10^{-25}:\\
\;\;\;\;\frac{0.25 + \frac{x\_m}{s \cdot \frac{s}{x\_m}} \cdot -0.0625}{s}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}
\end{array}
if x < 1.00000002e-25Initial 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-rr97.1%
*-lft-identity97.1%
*-commutative97.1%
exp-to-pow97.0%
log1p-undefine97.1%
*-commutative97.1%
rem-exp-log94.0%
exp-sum93.8%
exp-diff96.1%
associate--r+96.3%
exp-diff96.2%
cancel-sign-sub-inv96.2%
metadata-eval96.2%
rem-exp-log99.2%
Simplified99.2%
*-un-lft-identity99.2%
exp-prod99.1%
+-commutative99.1%
fma-define99.1%
Applied egg-rr99.1%
Taylor expanded in x around 0 30.2%
*-commutative30.2%
unpow230.2%
unpow230.2%
times-frac38.6%
unpow238.6%
Simplified38.6%
unpow238.6%
clear-num38.6%
frac-times38.6%
*-un-lft-identity38.6%
Applied egg-rr38.6%
if 1.00000002e-25 < x Initial program 99.7%
fabs-neg99.7%
distribute-frac-neg99.7%
distribute-frac-neg299.7%
fabs-neg99.7%
*-commutative99.7%
fabs-neg99.7%
+-commutative99.7%
fabs-neg99.7%
Simplified99.7%
Applied egg-rr4.0%
Taylor expanded in s around inf 89.9%
Final simplification61.1%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 0.800000011920929) (/ 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 <= 0.800000011920929f) {
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 <= 0.800000011920929e0) 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(0.800000011920929)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(x_m * 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(0.800000011920929)) 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 0.800000011920929:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{s}}{\frac{x\_m \cdot -4}{s}}\\
\end{array}
\end{array}
if x < 0.800000012Initial 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.1%
Taylor expanded in s around inf 36.4%
if 0.800000012 < 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%
mul-1-neg100.0%
rec-exp100.0%
rem-square-sqrt100.0%
fabs-sqr100.0%
rem-square-sqrt100.0%
rec-exp100.0%
distribute-neg-frac2100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 49.1%
Taylor expanded in x around inf 49.1%
*-commutative49.1%
associate-*l/49.1%
Simplified49.1%
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.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.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.4%
mul-1-neg99.4%
rec-exp99.4%
rem-square-sqrt52.0%
fabs-sqr52.0%
rem-square-sqrt66.2%
rec-exp66.2%
distribute-neg-frac266.2%
Simplified67.2%
Taylor expanded in x around 0 63.5%
*-commutative63.5%
Simplified63.5%
Taylor expanded in x around 0 49.5%
associate-*l/49.5%
frac-2neg49.5%
add-sqr-sqrt-0.0%
sqrt-unprod66.9%
sqr-neg66.9%
sqrt-unprod49.7%
add-sqr-sqrt49.7%
Applied egg-rr49.7%
distribute-rgt-neg-in49.7%
metadata-eval49.7%
Simplified49.7%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (/ 1.0 s) (+ 4.0 (* (/ x_m s) -4.0))))
x_m = fabs(x);
float code(float x_m, float s) {
return (1.0f / s) / (4.0f + ((x_m / 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 / s) / (4.0e0 + ((x_m / s) * (-4.0e0)))
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 / s) * Float32(-4.0)))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = (single(1.0) / s) / (single(4.0) + ((x_m / s) * single(-4.0))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\frac{1}{s}}{4 + \frac{x\_m}{s} \cdot -4}
\end{array}
Initial 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.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.4%
mul-1-neg99.4%
rec-exp99.4%
rem-square-sqrt52.0%
fabs-sqr52.0%
rem-square-sqrt66.2%
rec-exp66.2%
distribute-neg-frac266.2%
Simplified67.2%
Taylor expanded in x around 0 63.5%
*-commutative63.5%
Simplified63.5%
Taylor expanded in x around 0 49.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(x_m * Float32(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 + x\_m \cdot \frac{-4}{s}}
\end{array}
Initial 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.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.4%
mul-1-neg99.4%
rec-exp99.4%
rem-square-sqrt52.0%
fabs-sqr52.0%
rem-square-sqrt66.2%
rec-exp66.2%
distribute-neg-frac266.2%
Simplified67.2%
Taylor expanded in x around 0 63.5%
*-commutative63.5%
Simplified63.5%
Taylor expanded in x around 0 49.5%
Taylor expanded in x around 0 49.5%
associate-*r/49.5%
*-commutative49.5%
associate-/l*49.5%
Simplified49.5%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 0.800000011920929) (/ 0.25 s) (/ -0.25 x_m)))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 0.800000011920929f) {
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 <= 0.800000011920929e0) 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(0.800000011920929)) 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(0.800000011920929)) 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 0.800000011920929:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.25}{x\_m}\\
\end{array}
\end{array}
if x < 0.800000012Initial 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.1%
Taylor expanded in s around inf 36.4%
if 0.800000012 < 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%
mul-1-neg100.0%
rec-exp100.0%
rem-square-sqrt100.0%
fabs-sqr100.0%
rem-square-sqrt100.0%
rec-exp100.0%
distribute-neg-frac2100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 49.1%
Taylor expanded in s around 0 10.0%
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.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.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.4%
mul-1-neg99.4%
rec-exp99.4%
rem-square-sqrt52.0%
fabs-sqr52.0%
rem-square-sqrt66.2%
rec-exp66.2%
distribute-neg-frac266.2%
Simplified67.2%
Taylor expanded in x around 0 63.5%
*-commutative63.5%
Simplified63.5%
Taylor expanded in x around 0 49.5%
Taylor expanded in s around 0 8.7%
herbie shell --seed 2024149
(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))))))