
(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 (/ (/ (pow (exp -0.25) (* 8.0 (/ (/ x_m s) 2.0))) s) (pow (+ (exp (/ x_m (- s))) 1.0) 2.0)))
x_m = fabs(x);
float code(float x_m, float s) {
return (powf(expf(-0.25f), (8.0f * ((x_m / s) / 2.0f))) / s) / powf((expf((x_m / -s)) + 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
code = ((exp((-0.25e0)) ** (8.0e0 * ((x_m / s) / 2.0e0))) / s) / ((exp((x_m / -s)) + 1.0e0) ** 2.0e0)
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32((exp(Float32(-0.25)) ^ Float32(Float32(8.0) * Float32(Float32(x_m / s) / Float32(2.0)))) / s) / (Float32(exp(Float32(x_m / Float32(-s))) + Float32(1.0)) ^ Float32(2.0))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = ((exp(single(-0.25)) ^ (single(8.0) * ((x_m / s) / single(2.0)))) / s) / ((exp((x_m / -s)) + single(1.0)) ^ single(2.0)); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\frac{{\left(e^{-0.25}\right)}^{\left(8 \cdot \frac{\frac{x\_m}{s}}{2}\right)}}{s}}{{\left(e^{\frac{x\_m}{-s}} + 1\right)}^{2}}
\end{array}
Initial 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.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.5%
mul-1-neg99.5%
distribute-neg-frac299.5%
+-commutative99.5%
mul-1-neg99.5%
distribute-neg-frac299.5%
Simplified99.5%
distribute-frac-neg299.5%
rec-exp99.5%
remove-double-neg99.5%
add-sqr-sqrt99.5%
sqrt-unprod95.7%
sqr-neg95.7%
sqrt-unprod-0.0%
add-sqr-sqrt91.2%
frac-2neg91.2%
add-sqr-sqrt-0.0%
sqrt-unprod96.0%
sqr-neg96.0%
sqrt-unprod99.5%
add-sqr-sqrt99.5%
add-sqr-sqrt53.2%
fabs-sqr53.2%
add-sqr-sqrt95.9%
Applied egg-rr95.9%
rec-exp95.9%
Simplified95.9%
distribute-frac-neg299.5%
rec-exp99.5%
remove-double-neg99.5%
add-sqr-sqrt99.5%
sqrt-unprod95.7%
sqr-neg95.7%
sqrt-unprod-0.0%
add-sqr-sqrt91.2%
frac-2neg91.2%
add-sqr-sqrt-0.0%
sqrt-unprod96.0%
sqr-neg96.0%
sqrt-unprod99.5%
add-sqr-sqrt99.5%
add-sqr-sqrt53.2%
fabs-sqr53.2%
add-sqr-sqrt95.9%
Applied egg-rr63.0%
rec-exp95.9%
Simplified63.3%
neg-mul-163.3%
exp-prod63.3%
Applied egg-rr63.3%
add-sqr-sqrt63.3%
unpow-prod-down63.3%
Applied egg-rr63.3%
pow-sqr63.3%
Simplified63.3%
add-sqr-sqrt63.3%
unpow-prod-down63.2%
pow1/263.2%
pow-exp63.2%
metadata-eval63.2%
associate-*r/63.2%
pow1/263.2%
pow-exp63.2%
metadata-eval63.2%
associate-*r/63.2%
Applied egg-rr63.2%
pow-sqr63.2%
associate-/l*63.2%
Simplified63.2%
sqr-pow63.2%
pow1/263.2%
pow-exp63.2%
metadata-eval63.2%
associate-*r*63.2%
metadata-eval63.2%
pow1/263.2%
pow-exp63.2%
metadata-eval63.2%
associate-*r*63.2%
metadata-eval63.2%
Applied egg-rr63.2%
pow-sqr63.2%
associate-/l*63.2%
associate-*r*63.2%
metadata-eval63.2%
Simplified63.2%
Final simplification63.2%
x_m = (fabs.f32 x)
(FPCore (x_m s)
:precision binary32
(let* ((t_0 (exp (/ x_m s))))
(if (<= (fabs x_m) 0.00011600000289035961)
(/ 1.0 (* s (exp (- (* 2.0 (log1p t_0)) (/ x_m s)))))
(/ (/ 0.5 s) (+ 1.0 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) <= 0.00011600000289035961f) {
tmp = 1.0f / (s * expf(((2.0f * log1pf(t_0)) - (x_m / s))));
} else {
tmp = (0.5f / s) / (1.0f + 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(0.00011600000289035961)) tmp = Float32(Float32(1.0) / Float32(s * exp(Float32(Float32(Float32(2.0) * log1p(t_0)) - Float32(x_m / s))))); else tmp = Float32(Float32(Float32(0.5) / s) / Float32(Float32(1.0) + 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 0.00011600000289035961:\\
\;\;\;\;\frac{1}{s \cdot e^{2 \cdot \mathsf{log1p}\left(t\_0\right) - \frac{x\_m}{s}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{s}}{1 + t\_0}\\
\end{array}
\end{array}
if (fabs.f32 x) < 1.16000003e-4Initial program 99.2%
fabs-neg99.2%
distribute-frac-neg99.2%
distribute-frac-neg299.2%
fabs-neg99.2%
*-commutative99.2%
fabs-neg99.2%
+-commutative99.2%
fabs-neg99.2%
Simplified99.1%
Taylor expanded in x around 0 99.1%
associate-/r*99.2%
mul-1-neg99.2%
distribute-neg-frac299.2%
+-commutative99.2%
mul-1-neg99.2%
distribute-neg-frac299.2%
Simplified99.2%
Applied egg-rr94.6%
Taylor expanded in x around -inf 94.9%
exp-neg94.9%
exp-sum95.3%
rem-exp-log98.9%
neg-mul-198.9%
distribute-frac-neg298.9%
+-commutative98.9%
log1p-define99.2%
distribute-frac-neg299.2%
unsub-neg99.2%
Simplified99.2%
if 1.16000003e-4 < (fabs.f32 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%
Applied egg-rr48.4%
associate-*l/48.4%
*-lft-identity48.4%
+-commutative48.4%
Simplified48.4%
Taylor expanded in x around 0 53.2%
x_m = (fabs.f32 x)
(FPCore (x_m s)
:precision binary32
(let* ((t_0 (exp (/ x_m s))))
(if (<= (fabs x_m) 0.00011600000289035961)
(/ (exp (+ (/ x_m s) (* (log1p t_0) -2.0))) s)
(/ (/ 0.5 s) (+ 1.0 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) <= 0.00011600000289035961f) {
tmp = expf(((x_m / s) + (log1pf(t_0) * -2.0f))) / s;
} else {
tmp = (0.5f / s) / (1.0f + 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(0.00011600000289035961)) tmp = Float32(exp(Float32(Float32(x_m / s) + Float32(log1p(t_0) * Float32(-2.0)))) / s); else tmp = Float32(Float32(Float32(0.5) / s) / Float32(Float32(1.0) + 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 0.00011600000289035961:\\
\;\;\;\;\frac{e^{\frac{x\_m}{s} + \mathsf{log1p}\left(t\_0\right) \cdot -2}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.5}{s}}{1 + t\_0}\\
\end{array}
\end{array}
if (fabs.f32 x) < 1.16000003e-4Initial program 99.2%
fabs-neg99.2%
distribute-frac-neg99.2%
distribute-frac-neg299.2%
fabs-neg99.2%
*-commutative99.2%
fabs-neg99.2%
+-commutative99.2%
fabs-neg99.2%
Simplified99.1%
Applied egg-rr70.6%
associate-*r/70.6%
*-rgt-identity70.6%
rem-exp-log67.0%
exp-to-pow66.9%
+-commutative66.9%
log1p-undefine66.9%
*-commutative66.9%
exp-sum68.1%
+-commutative68.1%
exp-diff94.8%
associate--r+94.8%
exp-diff95.2%
Simplified99.2%
if 1.16000003e-4 < (fabs.f32 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%
Applied egg-rr48.4%
associate-*l/48.4%
*-lft-identity48.4%
+-commutative48.4%
Simplified48.4%
Taylor expanded in x around 0 53.2%
Final simplification75.8%
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.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.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.5%
mul-1-neg99.5%
distribute-neg-frac299.5%
+-commutative99.5%
mul-1-neg99.5%
distribute-neg-frac299.5%
Simplified99.5%
distribute-frac-neg299.5%
rec-exp99.5%
remove-double-neg99.5%
add-sqr-sqrt99.5%
sqrt-unprod95.7%
sqr-neg95.7%
sqrt-unprod-0.0%
add-sqr-sqrt91.2%
frac-2neg91.2%
add-sqr-sqrt-0.0%
sqrt-unprod96.0%
sqr-neg96.0%
sqrt-unprod99.5%
add-sqr-sqrt99.5%
add-sqr-sqrt53.2%
fabs-sqr53.2%
add-sqr-sqrt95.9%
Applied egg-rr95.9%
rec-exp95.9%
Simplified95.9%
distribute-frac-neg299.5%
rec-exp99.5%
remove-double-neg99.5%
add-sqr-sqrt99.5%
sqrt-unprod95.7%
sqr-neg95.7%
sqrt-unprod-0.0%
add-sqr-sqrt91.2%
frac-2neg91.2%
add-sqr-sqrt-0.0%
sqrt-unprod96.0%
sqr-neg96.0%
sqrt-unprod99.5%
add-sqr-sqrt99.5%
add-sqr-sqrt53.2%
fabs-sqr53.2%
add-sqr-sqrt95.9%
Applied egg-rr63.0%
rec-exp95.9%
Simplified63.3%
Final simplification63.3%
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(Float32(0.5) / 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{\frac{0.5}{s}}{1 + e^{\frac{x\_m}{s}}}
\end{array}
Initial 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.4%
Applied egg-rr60.1%
associate-*l/60.1%
*-lft-identity60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in x around 0 58.2%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (* (exp (/ x_m (- s))) 0.25) s))
x_m = fabs(x);
float code(float x_m, float s) {
return (expf((x_m / -s)) * 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 = (exp((x_m / -s)) * 0.25e0) / s
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(exp(Float32(x_m / Float32(-s))) * Float32(0.25)) / s) end
x_m = abs(x); function tmp = code(x_m, s) tmp = (exp((x_m / -s)) * single(0.25)) / s; end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{e^{\frac{x\_m}{-s}} \cdot 0.25}{s}
\end{array}
Initial 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.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.5%
mul-1-neg99.5%
distribute-neg-frac299.5%
+-commutative99.5%
mul-1-neg99.5%
distribute-neg-frac299.5%
Simplified99.5%
distribute-frac-neg299.5%
rec-exp99.5%
remove-double-neg99.5%
add-sqr-sqrt99.5%
sqrt-unprod95.7%
sqr-neg95.7%
sqrt-unprod-0.0%
add-sqr-sqrt91.2%
frac-2neg91.2%
add-sqr-sqrt-0.0%
sqrt-unprod96.0%
sqr-neg96.0%
sqrt-unprod99.5%
add-sqr-sqrt99.5%
add-sqr-sqrt53.2%
fabs-sqr53.2%
add-sqr-sqrt95.9%
Applied egg-rr95.9%
rec-exp95.9%
Simplified95.9%
distribute-frac-neg299.5%
rec-exp99.5%
remove-double-neg99.5%
add-sqr-sqrt99.5%
sqrt-unprod95.7%
sqr-neg95.7%
sqrt-unprod-0.0%
add-sqr-sqrt91.2%
frac-2neg91.2%
add-sqr-sqrt-0.0%
sqrt-unprod96.0%
sqr-neg96.0%
sqrt-unprod99.5%
add-sqr-sqrt99.5%
add-sqr-sqrt53.2%
fabs-sqr53.2%
add-sqr-sqrt95.9%
Applied egg-rr63.0%
rec-exp95.9%
Simplified63.3%
Taylor expanded in x around 0 57.3%
Taylor expanded in x around inf 57.3%
associate-*r/57.3%
distribute-neg-frac257.3%
Simplified57.3%
Final simplification57.3%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 5.000000229068525e-19) (/ (- (/ (+ (* -0.25 x_m) (* s 0.25)) s) (* -0.25 (/ x_m s))) s) (/ (/ 0.0 s) s)))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 5.000000229068525e-19f) {
tmp = ((((-0.25f * x_m) + (s * 0.25f)) / s) - (-0.25f * (x_m / s))) / s;
} else {
tmp = (0.0f / s) / 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 <= 5.000000229068525e-19) then
tmp = (((((-0.25e0) * x_m) + (s * 0.25e0)) / s) - ((-0.25e0) * (x_m / s))) / s
else
tmp = (0.0e0 / s) / s
end if
code = tmp
end function
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (x_m <= Float32(5.000000229068525e-19)) tmp = Float32(Float32(Float32(Float32(Float32(Float32(-0.25) * x_m) + Float32(s * Float32(0.25))) / s) - Float32(Float32(-0.25) * Float32(x_m / s))) / s); else tmp = Float32(Float32(Float32(0.0) / s) / s); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, s) tmp = single(0.0); if (x_m <= single(5.000000229068525e-19)) tmp = ((((single(-0.25) * x_m) + (s * single(0.25))) / s) - (single(-0.25) * (x_m / s))) / s; else tmp = (single(0.0) / s) / s; end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 5.000000229068525 \cdot 10^{-19}:\\
\;\;\;\;\frac{\frac{-0.25 \cdot x\_m + s \cdot 0.25}{s} - -0.25 \cdot \frac{x\_m}{s}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0}{s}}{s}\\
\end{array}
\end{array}
if x < 5.00000023e-19Initial 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%
Applied egg-rr91.6%
associate-*r/91.7%
times-frac91.1%
associate-*r/91.2%
*-rgt-identity91.2%
+-commutative91.2%
Simplified91.2%
*-un-lft-identity91.2%
exp-prod91.1%
Applied egg-rr91.1%
exp-1-e91.1%
Simplified91.1%
Taylor expanded in s around -inf 31.5%
mul-1-neg31.5%
log-E62.1%
*-commutative62.1%
associate-*r/62.2%
*-commutative62.2%
Simplified62.2%
Taylor expanded in s around 0 63.4%
if 5.00000023e-19 < x 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.5%
Applied egg-rr11.5%
associate-*l/11.5%
*-lft-identity11.5%
+-commutative11.5%
Simplified11.5%
Taylor expanded in s around inf 38.8%
div-inv38.8%
associate--l+38.7%
associate-*r/38.7%
associate-*r/38.7%
sub-div38.7%
Applied egg-rr38.7%
Taylor expanded in s around inf 63.5%
cancel-sign-sub-inv63.5%
distribute-rgt-out--63.5%
metadata-eval63.5%
associate-/l*48.3%
metadata-eval48.3%
*-commutative48.3%
Simplified48.3%
Taylor expanded in s around 0 88.2%
distribute-rgt-out88.2%
metadata-eval88.2%
mul0-rgt88.2%
Simplified88.2%
Final simplification73.3%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 5.499999890083859e-19) (/ (- (+ 0.25 (/ (* -0.25 x_m) s)) (* -0.25 (/ x_m s))) s) (/ (/ 0.0 s) s)))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 5.499999890083859e-19f) {
tmp = ((0.25f + ((-0.25f * x_m) / s)) - (-0.25f * (x_m / s))) / s;
} else {
tmp = (0.0f / s) / 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 <= 5.499999890083859e-19) then
tmp = ((0.25e0 + (((-0.25e0) * x_m) / s)) - ((-0.25e0) * (x_m / s))) / s
else
tmp = (0.0e0 / s) / s
end if
code = tmp
end function
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (x_m <= Float32(5.499999890083859e-19)) tmp = Float32(Float32(Float32(Float32(0.25) + Float32(Float32(Float32(-0.25) * x_m) / s)) - Float32(Float32(-0.25) * Float32(x_m / s))) / s); else tmp = Float32(Float32(Float32(0.0) / s) / s); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, s) tmp = single(0.0); if (x_m <= single(5.499999890083859e-19)) tmp = ((single(0.25) + ((single(-0.25) * x_m) / s)) - (single(-0.25) * (x_m / s))) / s; else tmp = (single(0.0) / s) / s; end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 5.499999890083859 \cdot 10^{-19}:\\
\;\;\;\;\frac{\left(0.25 + \frac{-0.25 \cdot x\_m}{s}\right) - -0.25 \cdot \frac{x\_m}{s}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0}{s}}{s}\\
\end{array}
\end{array}
if x < 5.49999989e-19Initial 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%
Applied egg-rr91.7%
associate-*r/91.7%
times-frac91.1%
associate-*r/91.2%
*-rgt-identity91.2%
+-commutative91.2%
Simplified91.2%
*-un-lft-identity91.2%
exp-prod91.2%
Applied egg-rr91.2%
exp-1-e91.2%
Simplified91.2%
Taylor expanded in s around -inf 31.9%
mul-1-neg31.9%
log-E62.3%
*-commutative62.3%
associate-*r/62.4%
*-commutative62.4%
Simplified62.4%
if 5.49999989e-19 < x 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%
Applied egg-rr10.7%
associate-*l/10.6%
*-lft-identity10.6%
+-commutative10.6%
Simplified10.6%
Taylor expanded in s around inf 38.2%
div-inv38.2%
associate--l+38.1%
associate-*r/38.1%
associate-*r/38.1%
sub-div38.1%
Applied egg-rr38.1%
Taylor expanded in s around inf 63.1%
cancel-sign-sub-inv63.1%
distribute-rgt-out--63.1%
metadata-eval63.1%
associate-/l*47.9%
metadata-eval47.9%
*-commutative47.9%
Simplified47.9%
Taylor expanded in s around 0 89.0%
distribute-rgt-out89.0%
metadata-eval89.0%
mul0-rgt89.0%
Simplified89.0%
Final simplification72.9%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 5.499999890083859e-19) (/ (+ (+ 0.25 (* (/ x_m s) 0.125)) (* (/ x_m s) -0.125)) s) (/ (/ 0.0 s) s)))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 5.499999890083859e-19f) {
tmp = ((0.25f + ((x_m / s) * 0.125f)) + ((x_m / s) * -0.125f)) / s;
} else {
tmp = (0.0f / s) / 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 <= 5.499999890083859e-19) then
tmp = ((0.25e0 + ((x_m / s) * 0.125e0)) + ((x_m / s) * (-0.125e0))) / s
else
tmp = (0.0e0 / s) / s
end if
code = tmp
end function
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (x_m <= Float32(5.499999890083859e-19)) tmp = Float32(Float32(Float32(Float32(0.25) + Float32(Float32(x_m / s) * Float32(0.125))) + Float32(Float32(x_m / s) * Float32(-0.125))) / s); else tmp = Float32(Float32(Float32(0.0) / s) / s); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, s) tmp = single(0.0); if (x_m <= single(5.499999890083859e-19)) tmp = ((single(0.25) + ((x_m / s) * single(0.125))) + ((x_m / s) * single(-0.125))) / s; else tmp = (single(0.0) / s) / s; end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 5.499999890083859 \cdot 10^{-19}:\\
\;\;\;\;\frac{\left(0.25 + \frac{x\_m}{s} \cdot 0.125\right) + \frac{x\_m}{s} \cdot -0.125}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0}{s}}{s}\\
\end{array}
\end{array}
if x < 5.49999989e-19Initial 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%
Applied egg-rr92.3%
associate-*l/92.3%
*-lft-identity92.3%
+-commutative92.3%
Simplified92.3%
Taylor expanded in s around inf 34.4%
div-inv34.3%
associate--l+34.4%
associate-*r/34.4%
associate-*r/34.4%
sub-div35.0%
Applied egg-rr35.0%
Taylor expanded in s around inf 62.4%
cancel-sign-sub-inv62.4%
distribute-rgt-out--62.4%
metadata-eval62.4%
associate-/l*55.5%
metadata-eval55.5%
*-commutative55.5%
Simplified55.5%
Taylor expanded in x around 0 62.3%
*-commutative62.3%
Simplified62.3%
if 5.49999989e-19 < x 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%
Applied egg-rr10.7%
associate-*l/10.6%
*-lft-identity10.6%
+-commutative10.6%
Simplified10.6%
Taylor expanded in s around inf 38.2%
div-inv38.2%
associate--l+38.1%
associate-*r/38.1%
associate-*r/38.1%
sub-div38.1%
Applied egg-rr38.1%
Taylor expanded in s around inf 63.1%
cancel-sign-sub-inv63.1%
distribute-rgt-out--63.1%
metadata-eval63.1%
associate-/l*47.9%
metadata-eval47.9%
*-commutative47.9%
Simplified47.9%
Taylor expanded in s around 0 89.0%
distribute-rgt-out89.0%
metadata-eval89.0%
mul0-rgt89.0%
Simplified89.0%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 4.0000000126843074e-29) (/ (/ (* s 0.25) s) s) (/ (/ 0.0 s) s)))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 4.0000000126843074e-29f) {
tmp = ((s * 0.25f) / s) / s;
} else {
tmp = (0.0f / s) / 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 <= 4.0000000126843074e-29) then
tmp = ((s * 0.25e0) / s) / s
else
tmp = (0.0e0 / s) / s
end if
code = tmp
end function
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (x_m <= Float32(4.0000000126843074e-29)) tmp = Float32(Float32(Float32(s * Float32(0.25)) / s) / s); else tmp = Float32(Float32(Float32(0.0) / s) / s); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, s) tmp = single(0.0); if (x_m <= single(4.0000000126843074e-29)) tmp = ((s * single(0.25)) / s) / s; else tmp = (single(0.0) / s) / s; end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 4.0000000126843074 \cdot 10^{-29}:\\
\;\;\;\;\frac{\frac{s \cdot 0.25}{s}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0}{s}}{s}\\
\end{array}
\end{array}
if x < 4.00000001e-29Initial 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%
Applied egg-rr97.2%
associate-*l/97.2%
*-lft-identity97.2%
+-commutative97.2%
Simplified97.2%
Taylor expanded in s around inf 27.4%
div-inv27.3%
associate--l+27.3%
associate-*r/27.3%
associate-*r/27.4%
sub-div28.0%
Applied egg-rr28.0%
Taylor expanded in s around inf 59.3%
cancel-sign-sub-inv59.3%
distribute-rgt-out--59.3%
metadata-eval59.3%
associate-/l*52.9%
metadata-eval52.9%
*-commutative52.9%
Simplified52.9%
Taylor expanded in s around 0 81.7%
+-commutative81.7%
+-commutative81.7%
associate-+l+26.0%
*-commutative26.0%
distribute-rgt-out26.0%
metadata-eval26.0%
mul0-rgt26.0%
Simplified26.0%
if 4.00000001e-29 < x 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.5%
Applied egg-rr19.3%
associate-*l/19.3%
*-lft-identity19.3%
+-commutative19.3%
Simplified19.3%
Taylor expanded in s around inf 45.3%
div-inv45.2%
associate--l+45.2%
associate-*r/45.2%
associate-*r/45.2%
sub-div45.2%
Applied egg-rr45.2%
Taylor expanded in s around inf 66.3%
cancel-sign-sub-inv66.3%
distribute-rgt-out--66.3%
metadata-eval66.3%
associate-/l*52.1%
metadata-eval52.1%
*-commutative52.1%
Simplified52.1%
Taylor expanded in s around 0 80.8%
distribute-rgt-out80.8%
metadata-eval80.8%
mul0-rgt80.8%
Simplified80.8%
Final simplification52.1%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 4.0000000126843074e-29) (/ 0.25 s) (/ (/ 0.0 s) s)))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 4.0000000126843074e-29f) {
tmp = 0.25f / s;
} else {
tmp = (0.0f / s) / 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 <= 4.0000000126843074e-29) then
tmp = 0.25e0 / s
else
tmp = (0.0e0 / s) / s
end if
code = tmp
end function
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (x_m <= Float32(4.0000000126843074e-29)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(Float32(0.0) / s) / s); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, s) tmp = single(0.0); if (x_m <= single(4.0000000126843074e-29)) tmp = single(0.25) / s; else tmp = (single(0.0) / s) / s; end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 4.0000000126843074 \cdot 10^{-29}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{0}{s}}{s}\\
\end{array}
\end{array}
if x < 4.00000001e-29Initial 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 s around inf 26.0%
if 4.00000001e-29 < x 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.5%
Applied egg-rr19.3%
associate-*l/19.3%
*-lft-identity19.3%
+-commutative19.3%
Simplified19.3%
Taylor expanded in s around inf 45.3%
div-inv45.2%
associate--l+45.2%
associate-*r/45.2%
associate-*r/45.2%
sub-div45.2%
Applied egg-rr45.2%
Taylor expanded in s around inf 66.3%
cancel-sign-sub-inv66.3%
distribute-rgt-out--66.3%
metadata-eval66.3%
associate-/l*52.1%
metadata-eval52.1%
*-commutative52.1%
Simplified52.1%
Taylor expanded in s around 0 80.8%
distribute-rgt-out80.8%
metadata-eval80.8%
mul0-rgt80.8%
Simplified80.8%
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.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.4%
Taylor expanded in s around inf 23.3%
herbie shell --seed 2024107
(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))))))