
(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 14 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.05000000074505806) (/ (exp (+ (/ x_m s) (* -2.0 (log1p (exp (/ x_m s)))))) s) (exp (- (/ (- x_m) s) (log (* s 4.0))))))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (fabsf(x_m) <= 0.05000000074505806f) {
tmp = expf(((x_m / s) + (-2.0f * log1pf(expf((x_m / s)))))) / s;
} else {
tmp = expf(((-x_m / s) - logf((s * 4.0f))));
}
return tmp;
}
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (abs(x_m) <= Float32(0.05000000074505806)) tmp = Float32(exp(Float32(Float32(x_m / s) + Float32(Float32(-2.0) * log1p(exp(Float32(x_m / s)))))) / s); else tmp = exp(Float32(Float32(Float32(-x_m) / s) - log(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.05000000074505806:\\
\;\;\;\;\frac{e^{\frac{x\_m}{s} + -2 \cdot \mathsf{log1p}\left(e^{\frac{x\_m}{s}}\right)}}{s}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{-x\_m}{s} - \log \left(s \cdot 4\right)}\\
\end{array}
\end{array}
if (fabs.f32 x) < 0.0500000007Initial 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.0%
associate-/r*99.0%
div-inv99.0%
Applied egg-rr80.9%
associate-*l/80.9%
add-exp-log80.9%
prod-exp99.0%
pow-flip99.0%
log-pow99.0%
metadata-eval99.0%
log1p-define99.1%
Applied egg-rr99.1%
if 0.0500000007 < (fabs.f32 x) Initial program 99.9%
fabs-neg99.9%
distribute-frac-neg99.9%
distribute-frac-neg299.9%
fabs-neg99.9%
*-commutative99.9%
fabs-neg99.9%
+-commutative99.9%
fabs-neg99.9%
Simplified99.9%
Taylor expanded in s around inf 99.9%
clear-num99.9%
inv-pow99.9%
Applied egg-rr54.2%
unpow-154.2%
*-commutative54.2%
Simplified54.2%
inv-pow54.2%
pow-to-exp54.2%
log-prod54.2%
add-log-exp54.2%
Applied egg-rr54.2%
Taylor expanded in x around inf 54.2%
+-commutative54.2%
*-commutative54.2%
neg-mul-154.2%
neg-sub054.2%
associate--r+54.2%
neg-sub054.2%
distribute-neg-frac254.2%
Simplified54.2%
Final simplification77.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(abs(x_m) / Float32(-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.4%
*-commutative99.4%
fabs-neg99.4%
+-commutative99.4%
fabs-neg99.4%
distribute-lft-in99.5%
*-rgt-identity99.5%
+-commutative99.5%
Simplified99.5%
Final simplification99.5%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 2.7999999628422514e-18) (/ (+ (+ 0.25 (* (/ x_m s) -0.25)) (* -0.25 (* x_m (/ -1.0 s)))) s) (exp (/ (- x_m) s))))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 2.7999999628422514e-18f) {
tmp = ((0.25f + ((x_m / s) * -0.25f)) + (-0.25f * (x_m * (-1.0f / s)))) / s;
} else {
tmp = 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.7999999628422514e-18) then
tmp = ((0.25e0 + ((x_m / s) * (-0.25e0))) + ((-0.25e0) * (x_m * ((-1.0e0) / s)))) / s
else
tmp = 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.7999999628422514e-18)) tmp = Float32(Float32(Float32(Float32(0.25) + Float32(Float32(x_m / s) * Float32(-0.25))) + Float32(Float32(-0.25) * Float32(x_m * Float32(Float32(-1.0) / s)))) / s); else tmp = exp(Float32(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.7999999628422514e-18)) tmp = ((single(0.25) + ((x_m / s) * single(-0.25))) + (single(-0.25) * (x_m * (single(-1.0) / s)))) / s; else tmp = 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.7999999628422514 \cdot 10^{-18}:\\
\;\;\;\;\frac{\left(0.25 + \frac{x\_m}{s} \cdot -0.25\right) + -0.25 \cdot \left(x\_m \cdot \frac{-1}{s}\right)}{s}\\
\mathbf{else}:\\
\;\;\;\;e^{\frac{-x\_m}{s}}\\
\end{array}
\end{array}
if x < 2.79999996e-18Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Applied egg-rr95.9%
*-lft-identity95.9%
Simplified95.9%
*-un-lft-identity39.6%
exp-prod39.6%
Applied egg-rr95.8%
exp-1-e39.6%
Simplified95.8%
Taylor expanded in s around -inf 42.0%
mul-1-neg42.0%
log-E71.1%
associate-/l*61.2%
Simplified61.2%
if 2.79999996e-18 < 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%
Taylor expanded in s around inf 95.5%
clear-num95.5%
inv-pow95.5%
Applied egg-rr95.5%
unpow-195.5%
*-commutative95.5%
Simplified95.5%
inv-pow95.5%
pow-to-exp95.5%
log-prod95.5%
add-log-exp95.5%
Applied egg-rr95.5%
Taylor expanded in x around inf 93.5%
Final simplification72.7%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (/ 0.25 s) (exp (/ x_m s))))
x_m = fabs(x);
float code(float x_m, float s) {
return (0.25f / s) / 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.25e0 / s) / exp((x_m / s))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(Float32(0.25) / s) / exp(Float32(x_m / s))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = (single(0.25) / s) / exp((x_m / s)); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\frac{0.25}{s}}{e^{\frac{x\_m}{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 s around inf 92.9%
clear-num92.9%
inv-pow92.9%
Applied egg-rr59.5%
unpow-159.5%
*-commutative59.5%
Simplified59.5%
*-un-lft-identity59.5%
exp-prod59.5%
Applied egg-rr59.5%
exp-1-e59.5%
Simplified59.5%
Taylor expanded in x around inf 59.5%
associate-/r*59.5%
log-E59.5%
metadata-eval59.5%
log-E59.5%
log-E59.5%
metadata-eval59.5%
*-rgt-identity59.5%
Simplified59.5%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 0.25 (* s (exp (/ x_m s)))))
x_m = fabs(x);
float code(float x_m, float s) {
return 0.25f / (s * 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.25e0 / (s * exp((x_m / s)))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(0.25) / Float32(s * exp(Float32(x_m / s)))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(0.25) / (s * exp((x_m / s))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{0.25}{s \cdot e^{\frac{x\_m}{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 s around inf 92.9%
clear-num92.9%
inv-pow92.9%
Applied egg-rr59.5%
unpow-159.5%
*-commutative59.5%
Simplified59.5%
Taylor expanded in x around inf 59.5%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 5000000000.0) (/ (+ (+ 0.25 (* (/ x_m s) -0.25)) (* -0.25 (* x_m (/ -1.0 s)))) s) (/ 1.0 (+ (* s 4.0) (* x_m (+ 4.0 (* (/ x_m s) 2.0)))))))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 5000000000.0f) {
tmp = ((0.25f + ((x_m / s) * -0.25f)) + (-0.25f * (x_m * (-1.0f / s)))) / s;
} else {
tmp = 1.0f / ((s * 4.0f) + (x_m * (4.0f + ((x_m / s) * 2.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 <= 5000000000.0e0) then
tmp = ((0.25e0 + ((x_m / s) * (-0.25e0))) + ((-0.25e0) * (x_m * ((-1.0e0) / s)))) / s
else
tmp = 1.0e0 / ((s * 4.0e0) + (x_m * (4.0e0 + ((x_m / s) * 2.0e0))))
end if
code = tmp
end function
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (x_m <= Float32(5000000000.0)) tmp = Float32(Float32(Float32(Float32(0.25) + Float32(Float32(x_m / s) * Float32(-0.25))) + Float32(Float32(-0.25) * Float32(x_m * Float32(Float32(-1.0) / s)))) / s); else tmp = Float32(Float32(1.0) / Float32(Float32(s * Float32(4.0)) + Float32(x_m * Float32(Float32(4.0) + Float32(Float32(x_m / s) * Float32(2.0)))))); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, s) tmp = single(0.0); if (x_m <= single(5000000000.0)) tmp = ((single(0.25) + ((x_m / s) * single(-0.25))) + (single(-0.25) * (x_m * (single(-1.0) / s)))) / s; else tmp = single(1.0) / ((s * single(4.0)) + (x_m * (single(4.0) + ((x_m / s) * single(2.0))))); end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 5000000000:\\
\;\;\;\;\frac{\left(0.25 + \frac{x\_m}{s} \cdot -0.25\right) + -0.25 \cdot \left(x\_m \cdot \frac{-1}{s}\right)}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot 4 + x\_m \cdot \left(4 + \frac{x\_m}{s} \cdot 2\right)}\\
\end{array}
\end{array}
if x < 5e9Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Applied egg-rr81.7%
*-lft-identity81.7%
Simplified81.7%
*-un-lft-identity48.6%
exp-prod48.6%
Applied egg-rr81.6%
exp-1-e48.6%
Simplified81.6%
Taylor expanded in s around -inf 39.1%
mul-1-neg39.1%
log-E71.5%
associate-/l*60.5%
Simplified60.5%
if 5e9 < 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 s around inf 100.0%
clear-num100.0%
inv-pow100.0%
Applied egg-rr100.0%
unpow-1100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 95.6%
Final simplification67.9%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 1.0 (+ (* s 4.0) (* x_m (+ 4.0 (* (/ x_m s) 2.0))))))
x_m = fabs(x);
float code(float x_m, float s) {
return 1.0f / ((s * 4.0f) + (x_m * (4.0f + ((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 = 1.0e0 / ((s * 4.0e0) + (x_m * (4.0e0 + ((x_m / s) * 2.0e0))))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(1.0) / Float32(Float32(s * Float32(4.0)) + Float32(x_m * Float32(Float32(4.0) + Float32(Float32(x_m / s) * Float32(2.0)))))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(1.0) / ((s * single(4.0)) + (x_m * (single(4.0) + ((x_m / s) * single(2.0))))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1}{s \cdot 4 + x\_m \cdot \left(4 + \frac{x\_m}{s} \cdot 2\right)}
\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 s around inf 92.9%
clear-num92.9%
inv-pow92.9%
Applied egg-rr59.5%
unpow-159.5%
*-commutative59.5%
Simplified59.5%
Taylor expanded in x around 0 64.1%
Final simplification64.1%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 1.0 (* (* s 4.0) (+ 1.0 (* x_m (/ 1.0 s))))))
x_m = fabs(x);
float code(float x_m, float s) {
return 1.0f / ((s * 4.0f) * (1.0f + (x_m * (1.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) * (1.0e0 + (x_m * (1.0e0 / s))))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(1.0) / Float32(Float32(s * Float32(4.0)) * Float32(Float32(1.0) + Float32(x_m * Float32(Float32(1.0) / s))))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(1.0) / ((s * single(4.0)) * (single(1.0) + (x_m * (single(1.0) / s)))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1}{\left(s \cdot 4\right) \cdot \left(1 + x\_m \cdot \frac{1}{s}\right)}
\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 s around inf 92.9%
clear-num92.9%
inv-pow92.9%
Applied egg-rr59.5%
unpow-159.5%
*-commutative59.5%
Simplified59.5%
*-un-lft-identity59.5%
exp-prod59.5%
Applied egg-rr59.5%
exp-1-e59.5%
Simplified59.5%
Taylor expanded in x around 0 52.9%
log-E52.9%
metadata-eval52.9%
log-E52.9%
log-E52.9%
metadata-eval52.9%
associate-/l*53.3%
Simplified53.3%
Final simplification53.3%
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(1.0) / Float32(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{1}{s \cdot \left(4 + \frac{x\_m}{s} \cdot 4\right)}
\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 s around inf 92.9%
clear-num92.9%
inv-pow92.9%
Applied egg-rr59.5%
unpow-159.5%
*-commutative59.5%
Simplified59.5%
Taylor expanded in s around inf 53.3%
Final simplification53.3%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 0.05000000074505806) (/ 0.25 s) (/ 0.25 x_m)))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 0.05000000074505806f) {
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.05000000074505806e0) 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.05000000074505806)) 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.05000000074505806)) 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.05000000074505806:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{x\_m}\\
\end{array}
\end{array}
if x < 0.0500000007Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Taylor expanded in s around inf 37.2%
if 0.0500000007 < 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 s around inf 99.8%
clear-num99.8%
inv-pow99.8%
Applied egg-rr99.8%
unpow-199.8%
*-commutative99.8%
Simplified99.8%
Taylor expanded in x around 0 15.8%
distribute-lft-out15.8%
Simplified15.8%
Taylor expanded in s around 0 12.9%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 1.0 (* 4.0 (+ x_m s))))
x_m = fabs(x);
float code(float x_m, float s) {
return 1.0f / (4.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
code = 1.0e0 / (4.0e0 * (x_m + s))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(1.0) / Float32(Float32(4.0) * Float32(x_m + s))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(1.0) / (single(4.0) * (x_m + s)); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1}{4 \cdot \left(x\_m + s\right)}
\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 s around inf 92.9%
clear-num92.9%
inv-pow92.9%
Applied egg-rr59.5%
unpow-159.5%
*-commutative59.5%
Simplified59.5%
Taylor expanded in x around 0 32.2%
distribute-lft-out32.2%
Simplified32.2%
Final simplification32.2%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (* 0.25 (/ 1.0 (+ x_m s))))
x_m = fabs(x);
float code(float x_m, float s) {
return 0.25f * (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
code = 0.25e0 * (1.0e0 / (x_m + s))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(0.25) * Float32(Float32(1.0) / Float32(x_m + s))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(0.25) * (single(1.0) / (x_m + s)); end
\begin{array}{l}
x_m = \left|x\right|
\\
0.25 \cdot \frac{1}{x\_m + 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 s around inf 92.9%
clear-num92.9%
inv-pow92.9%
Applied egg-rr59.5%
unpow-159.5%
*-commutative59.5%
Simplified59.5%
Taylor expanded in x around 0 32.2%
distribute-lft-out32.2%
Simplified32.2%
associate-/r*30.7%
metadata-eval30.7%
div-inv30.7%
+-commutative30.7%
Applied egg-rr30.7%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 0.25 (+ x_m s)))
x_m = fabs(x);
float code(float x_m, float s) {
return 0.25f / (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.25e0 / (x_m + s)
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(0.25) / Float32(x_m + s)) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(0.25) / (x_m + s); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{0.25}{x\_m + 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 s around inf 92.9%
clear-num92.9%
inv-pow92.9%
Applied egg-rr59.5%
unpow-159.5%
*-commutative59.5%
Simplified59.5%
Taylor expanded in x around 0 32.2%
distribute-lft-out32.2%
Simplified32.2%
*-un-lft-identity32.2%
associate-/r*30.7%
metadata-eval30.7%
+-commutative30.7%
Applied egg-rr30.7%
*-lft-identity30.7%
+-commutative30.7%
Simplified30.7%
Final simplification30.7%
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.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 28.8%
herbie shell --seed 2024081
(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))))))