
(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 (/ 1.0 (* (+ 1.0 (exp (/ (- x_m) s))) (fma s (expm1 (log1p (exp (/ x_m s)))) s))))
x_m = fabs(x);
float code(float x_m, float s) {
return 1.0f / ((1.0f + expf((-x_m / s))) * fmaf(s, expm1f(log1pf(expf((x_m / s)))), s));
}
x_m = abs(x) function code(x_m, s) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + exp(Float32(Float32(-x_m) / s))) * fma(s, expm1(log1p(exp(Float32(x_m / s)))), s))) end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1}{\left(1 + e^{\frac{-x_m}{s}}\right) \cdot \mathsf{fma}\left(s, \mathsf{expm1}\left(\mathsf{log1p}\left(e^{\frac{x_m}{s}}\right)\right), s\right)}
\end{array}
Initial program 99.8%
Simplified99.8%
fma-udef99.8%
+-commutative99.8%
add-sqr-sqrt53.0%
fabs-sqr53.0%
add-sqr-sqrt62.6%
Applied egg-rr62.6%
+-commutative62.6%
fma-def62.6%
Simplified62.6%
expm1-log1p-u62.6%
Applied egg-rr62.6%
distribute-frac-neg62.6%
rec-exp62.7%
add-sqr-sqrt53.0%
fabs-sqr53.0%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
rec-exp99.8%
distribute-neg-frac99.8%
Simplified99.8%
Final simplification99.8%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 1.0 (* (+ 1.0 (exp (/ (- x_m) s))) (fma s (+ 1.0 (expm1 (/ x_m s))) s))))
x_m = fabs(x);
float code(float x_m, float s) {
return 1.0f / ((1.0f + expf((-x_m / s))) * fmaf(s, (1.0f + expm1f((x_m / s))), s));
}
x_m = abs(x) function code(x_m, s) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + exp(Float32(Float32(-x_m) / s))) * fma(s, Float32(Float32(1.0) + expm1(Float32(x_m / s))), s))) end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1}{\left(1 + e^{\frac{-x_m}{s}}\right) \cdot \mathsf{fma}\left(s, 1 + \mathsf{expm1}\left(\frac{x_m}{s}\right), s\right)}
\end{array}
Initial program 99.8%
Simplified99.8%
fma-udef99.8%
+-commutative99.8%
add-sqr-sqrt53.0%
fabs-sqr53.0%
add-sqr-sqrt62.6%
Applied egg-rr62.6%
+-commutative62.6%
fma-def62.6%
Simplified62.6%
expm1-log1p-u62.6%
expm1-udef62.7%
log1p-udef62.6%
add-exp-log62.6%
Applied egg-rr62.6%
associate--l+62.6%
expm1-def62.6%
Simplified62.6%
distribute-frac-neg62.6%
rec-exp62.7%
add-sqr-sqrt53.0%
fabs-sqr53.0%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
rec-exp99.8%
distribute-neg-frac99.8%
Simplified99.8%
Final simplification99.8%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 1.0 (* (+ 1.0 (exp (/ (- x_m) s))) (fma s (exp (/ x_m s)) s))))
x_m = fabs(x);
float code(float x_m, float s) {
return 1.0f / ((1.0f + expf((-x_m / s))) * fmaf(s, expf((x_m / s)), s));
}
x_m = abs(x) function code(x_m, s) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + exp(Float32(Float32(-x_m) / s))) * fma(s, exp(Float32(x_m / s)), s))) end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1}{\left(1 + e^{\frac{-x_m}{s}}\right) \cdot \mathsf{fma}\left(s, e^{\frac{x_m}{s}}, s\right)}
\end{array}
Initial program 99.8%
Simplified99.8%
fma-udef99.8%
+-commutative99.8%
add-sqr-sqrt53.0%
fabs-sqr53.0%
add-sqr-sqrt62.6%
Applied egg-rr62.6%
+-commutative62.6%
fma-def62.6%
Simplified62.6%
distribute-frac-neg62.6%
rec-exp62.7%
add-sqr-sqrt53.0%
fabs-sqr53.0%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
rec-exp99.8%
distribute-neg-frac99.8%
Simplified99.8%
Final simplification99.8%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 1.0 (* s (* (+ 1.0 (exp (/ (- x_m) s))) (+ 1.0 (exp (/ x_m s)))))))
x_m = fabs(x);
float code(float x_m, float s) {
return 1.0f / (s * ((1.0f + expf((-x_m / 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 = 1.0e0 / (s * ((1.0e0 + exp((-x_m / s))) * (1.0e0 + exp((x_m / s)))))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(Float32(1.0) + exp(Float32(Float32(-x_m) / s))) * Float32(Float32(1.0) + exp(Float32(x_m / s)))))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(1.0) / (s * ((single(1.0) + exp((-x_m / s))) * (single(1.0) + exp((x_m / s))))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1}{s \cdot \left(\left(1 + e^{\frac{-x_m}{s}}\right) \cdot \left(1 + e^{\frac{x_m}{s}}\right)\right)}
\end{array}
Initial program 99.8%
Simplified99.8%
fma-udef99.8%
+-commutative99.8%
add-sqr-sqrt53.0%
fabs-sqr53.0%
add-sqr-sqrt62.6%
Applied egg-rr62.6%
+-commutative62.6%
fma-def62.6%
Simplified62.6%
Taylor expanded in s around 0 62.6%
associate-*r/62.6%
mul-1-neg62.6%
Simplified62.6%
distribute-frac-neg62.6%
rec-exp62.7%
add-sqr-sqrt53.0%
fabs-sqr53.0%
add-sqr-sqrt99.9%
Applied egg-rr99.8%
rec-exp99.8%
distribute-neg-frac99.8%
Simplified99.8%
Final simplification99.8%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 1.0 (* (+ 1.0 (exp (/ (- x_m) s))) (* s (+ 1.0 (exp (/ x_m s)))))))
x_m = fabs(x);
float code(float x_m, float s) {
return 1.0f / ((1.0f + expf((-x_m / s))) * (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 = 1.0e0 / ((1.0e0 + exp((-x_m / s))) * (s * (1.0e0 + exp((x_m / s)))))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + exp(Float32(Float32(-x_m) / s))) * Float32(s * Float32(Float32(1.0) + exp(Float32(x_m / s)))))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(1.0) / ((single(1.0) + exp((-x_m / s))) * (s * (single(1.0) + exp((x_m / s))))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1}{\left(1 + e^{\frac{-x_m}{s}}\right) \cdot \left(s \cdot \left(1 + e^{\frac{x_m}{s}}\right)\right)}
\end{array}
Initial program 99.8%
Simplified99.8%
fma-udef99.8%
+-commutative99.8%
add-sqr-sqrt53.0%
fabs-sqr53.0%
add-sqr-sqrt62.6%
Applied egg-rr62.6%
+-commutative62.6%
fma-def62.6%
Simplified62.6%
expm1-log1p-u62.6%
Applied egg-rr62.6%
distribute-frac-neg62.6%
rec-exp62.7%
add-sqr-sqrt53.0%
fabs-sqr53.0%
add-sqr-sqrt99.9%
Applied egg-rr99.9%
rec-exp99.8%
distribute-neg-frac99.8%
Simplified99.8%
Taylor expanded in s around 0 99.8%
Final simplification99.8%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 0.5 (+ s (* s (exp (/ x_m s))))))
x_m = fabs(x);
float code(float x_m, float s) {
return 0.5f / (s + (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.5e0 / (s + (s * exp((x_m / s))))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(0.5) / Float32(s + Float32(s * exp(Float32(x_m / s))))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(0.5) / (s + (s * exp((x_m / s)))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{0.5}{s + s \cdot e^{\frac{x_m}{s}}}
\end{array}
Initial program 99.8%
Simplified99.8%
fma-udef99.8%
+-commutative99.8%
add-sqr-sqrt53.0%
fabs-sqr53.0%
add-sqr-sqrt62.6%
Applied egg-rr62.6%
+-commutative62.6%
fma-def62.6%
Simplified62.6%
Taylor expanded in s around inf 59.9%
Taylor expanded in x around inf 59.9%
Final simplification59.9%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 0.5 (+ s (* s (+ 1.0 (/ x_m s))))))
x_m = fabs(x);
float code(float x_m, float s) {
return 0.5f / (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
code = 0.5e0 / (s + (s * (1.0e0 + (x_m / s))))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(0.5) / Float32(s + Float32(s * Float32(Float32(1.0) + Float32(x_m / s))))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(0.5) / (s + (s * (single(1.0) + (x_m / s)))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{0.5}{s + s \cdot \left(1 + \frac{x_m}{s}\right)}
\end{array}
Initial program 99.8%
Simplified99.8%
fma-udef99.8%
+-commutative99.8%
add-sqr-sqrt53.0%
fabs-sqr53.0%
add-sqr-sqrt62.6%
Applied egg-rr62.6%
+-commutative62.6%
fma-def62.6%
Simplified62.6%
Taylor expanded in s around inf 59.9%
Taylor expanded in x around inf 59.9%
Taylor expanded in x around 0 46.4%
Final simplification46.4%
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.8%
Simplified99.8%
*-commutative99.8%
distribute-lft-in26.0%
*-commutative26.0%
*-un-lft-identity26.0%
add-sqr-sqrt16.7%
fabs-sqr16.7%
add-sqr-sqrt24.8%
add-sqr-sqrt16.6%
fabs-sqr16.6%
add-sqr-sqrt26.3%
Applied egg-rr59.5%
*-commutative59.5%
distribute-rgt1-in59.5%
+-commutative59.5%
fma-def59.5%
distribute-rgt-out59.5%
associate-*l*59.5%
distribute-lft-out59.5%
*-lft-identity59.5%
distribute-rgt-in59.5%
+-commutative59.5%
unpow259.5%
Simplified59.5%
Taylor expanded in x around 0 46.7%
*-commutative46.7%
Simplified46.7%
Final simplification46.7%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 1.0 (+ (* s 4.0) (/ (* x_m x_m) s))))
x_m = fabs(x);
float code(float x_m, float s) {
return 1.0f / ((s * 4.0f) + ((x_m * 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 / ((s * 4.0e0) + ((x_m * x_m) / 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(x_m * x_m) / s))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(1.0) / ((s * single(4.0)) + ((x_m * x_m) / s)); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{1}{s \cdot 4 + \frac{x_m \cdot x_m}{s}}
\end{array}
Initial program 99.8%
Simplified99.8%
Taylor expanded in s around -inf 35.5%
+-commutative35.5%
mul-1-neg35.5%
distribute-lft1-in62.0%
metadata-eval62.0%
associate-*r/62.0%
mul-1-neg62.0%
remove-double-neg62.0%
associate-+r+62.0%
Simplified62.0%
Final simplification62.0%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 4.999999987376214e-7) (/ 0.25 s) (/ 0.25 x_m)))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 4.999999987376214e-7f) {
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 <= 4.999999987376214e-7) 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(4.999999987376214e-7)) 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(4.999999987376214e-7)) 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 4.999999987376214 \cdot 10^{-7}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{x_m}\\
\end{array}
\end{array}
if x < 4.99999999e-7Initial program 99.7%
Simplified99.8%
*-commutative99.8%
distribute-lft-in36.0%
*-commutative36.0%
*-un-lft-identity36.0%
add-sqr-sqrt23.1%
fabs-sqr23.1%
add-sqr-sqrt34.3%
add-sqr-sqrt23.0%
fabs-sqr23.0%
add-sqr-sqrt36.4%
Applied egg-rr43.9%
*-commutative43.9%
distribute-rgt1-in43.9%
+-commutative43.9%
fma-def43.9%
distribute-rgt-out43.9%
associate-*l*43.9%
distribute-lft-out43.9%
*-lft-identity43.9%
distribute-rgt-in43.9%
+-commutative43.9%
unpow243.9%
Simplified43.9%
Taylor expanded in s around inf 34.8%
if 4.99999999e-7 < x Initial program 100.0%
Simplified100.0%
*-commutative100.0%
distribute-lft-in-0.0%
*-commutative-0.0%
*-un-lft-identity-0.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt-0.0%
add-sqr-sqrt-0.0%
fabs-sqr-0.0%
add-sqr-sqrt-0.0%
Applied egg-rr100.0%
*-commutative100.0%
distribute-rgt1-in100.0%
+-commutative100.0%
fma-def100.0%
distribute-rgt-out100.0%
associate-*l*100.0%
distribute-lft-out100.0%
*-lft-identity100.0%
distribute-rgt-in100.0%
+-commutative100.0%
unpow2100.0%
Simplified100.0%
Taylor expanded in s around inf 11.1%
distribute-lft-out11.1%
Simplified11.1%
Taylor expanded in s around 0 11.1%
Final simplification28.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.8%
Simplified99.8%
*-commutative99.8%
distribute-lft-in26.0%
*-commutative26.0%
*-un-lft-identity26.0%
add-sqr-sqrt16.7%
fabs-sqr16.7%
add-sqr-sqrt24.8%
add-sqr-sqrt16.6%
fabs-sqr16.6%
add-sqr-sqrt26.3%
Applied egg-rr59.5%
*-commutative59.5%
distribute-rgt1-in59.5%
+-commutative59.5%
fma-def59.5%
distribute-rgt-out59.5%
associate-*l*59.5%
distribute-lft-out59.5%
*-lft-identity59.5%
distribute-rgt-in59.5%
+-commutative59.5%
unpow259.5%
Simplified59.5%
Taylor expanded in s around inf 28.3%
distribute-lft-out28.3%
Simplified28.3%
associate-/r*28.3%
div-inv28.3%
metadata-eval28.3%
+-commutative28.3%
Applied egg-rr28.3%
Final simplification28.3%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 0.5 (+ x_m (* s 2.0))))
x_m = fabs(x);
float code(float x_m, float s) {
return 0.5f / (x_m + (s * 2.0f));
}
x_m = abs(x)
real(4) function code(x_m, s)
real(4), intent (in) :: x_m
real(4), intent (in) :: s
code = 0.5e0 / (x_m + (s * 2.0e0))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(0.5) / Float32(x_m + Float32(s * Float32(2.0)))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(0.5) / (x_m + (s * single(2.0))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{0.5}{x_m + s \cdot 2}
\end{array}
Initial program 99.8%
Simplified99.8%
fma-udef99.8%
+-commutative99.8%
add-sqr-sqrt53.0%
fabs-sqr53.0%
add-sqr-sqrt62.6%
Applied egg-rr62.6%
+-commutative62.6%
fma-def62.6%
Simplified62.6%
Taylor expanded in s around inf 59.9%
Taylor expanded in x around inf 59.9%
Taylor expanded in s around inf 28.6%
Final simplification28.6%
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.8%
Simplified99.8%
*-commutative99.8%
distribute-lft-in26.0%
*-commutative26.0%
*-un-lft-identity26.0%
add-sqr-sqrt16.7%
fabs-sqr16.7%
add-sqr-sqrt24.8%
add-sqr-sqrt16.6%
fabs-sqr16.6%
add-sqr-sqrt26.3%
Applied egg-rr59.5%
*-commutative59.5%
distribute-rgt1-in59.5%
+-commutative59.5%
fma-def59.5%
distribute-rgt-out59.5%
associate-*l*59.5%
distribute-lft-out59.5%
*-lft-identity59.5%
distribute-rgt-in59.5%
+-commutative59.5%
unpow259.5%
Simplified59.5%
Taylor expanded in s around inf 28.3%
distribute-lft-out28.3%
Simplified28.3%
expm1-log1p-u26.5%
expm1-udef60.7%
associate-/r*60.7%
metadata-eval60.7%
+-commutative60.7%
Applied egg-rr60.7%
expm1-def26.5%
expm1-log1p28.3%
+-commutative28.3%
Simplified28.3%
Final simplification28.3%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 0.25 s))
x_m = fabs(x);
float code(float x_m, float s) {
return 0.25f / s;
}
x_m = abs(x)
real(4) function code(x_m, s)
real(4), intent (in) :: x_m
real(4), intent (in) :: s
code = 0.25e0 / s
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(0.25) / s) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(0.25) / s; end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{0.25}{s}
\end{array}
Initial program 99.8%
Simplified99.8%
*-commutative99.8%
distribute-lft-in26.0%
*-commutative26.0%
*-un-lft-identity26.0%
add-sqr-sqrt16.7%
fabs-sqr16.7%
add-sqr-sqrt24.8%
add-sqr-sqrt16.6%
fabs-sqr16.6%
add-sqr-sqrt26.3%
Applied egg-rr59.5%
*-commutative59.5%
distribute-rgt1-in59.5%
+-commutative59.5%
fma-def59.5%
distribute-rgt-out59.5%
associate-*l*59.5%
distribute-lft-out59.5%
*-lft-identity59.5%
distribute-rgt-in59.5%
+-commutative59.5%
unpow259.5%
Simplified59.5%
Taylor expanded in s around inf 26.4%
Final simplification26.4%
herbie shell --seed 2024026
(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))))))