
(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 (let* ((t_0 (exp (/ (- x_m) s)))) (/ (/ t_0 (+ t_0 1.0)) (+ s (/ s (exp (/ 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 / 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
real(4) :: t_0
t_0 = exp((-x_m / s))
code = (t_0 / (t_0 + 1.0e0)) / (s + (s / exp((x_m / s))))
end function
x_m = abs(x) function code(x_m, s) t_0 = exp(Float32(Float32(-x_m) / s)) return Float32(Float32(t_0 / Float32(t_0 + Float32(1.0))) / Float32(s + Float32(s / exp(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 / exp((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}{e^{\frac{x\_m}{s}}}}
\end{array}
\end{array}
Initial program 99.1%
*-commutative99.1%
fabs-neg99.1%
+-commutative99.1%
fabs-neg99.1%
distribute-lft-in99.1%
*-rgt-identity99.1%
+-commutative99.1%
Simplified99.2%
Taylor expanded in x around 0 99.2%
associate-/r*99.2%
Simplified61.2%
Final simplification61.2%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= (fabs x_m) 0.0011500000255182385) (/ (exp (+ (/ x_m s) (* -2.0 (log1p (exp (/ x_m s)))))) s) (/ (/ (exp (/ (- x_m) s)) s) 4.0)))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (fabsf(x_m) <= 0.0011500000255182385f) {
tmp = expf(((x_m / s) + (-2.0f * log1pf(expf((x_m / s)))))) / s;
} else {
tmp = (expf((-x_m / s)) / s) / 4.0f;
}
return tmp;
}
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (abs(x_m) <= Float32(0.0011500000255182385)) tmp = Float32(exp(Float32(Float32(x_m / s) + Float32(Float32(-2.0) * log1p(exp(Float32(x_m / s)))))) / s); else tmp = Float32(Float32(exp(Float32(Float32(-x_m) / s)) / 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.0011500000255182385:\\
\;\;\;\;\frac{e^{\frac{x\_m}{s} + -2 \cdot \mathsf{log1p}\left(e^{\frac{x\_m}{s}}\right)}}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{e^{\frac{-x\_m}{s}}}{s}}{4}\\
\end{array}
\end{array}
if (fabs.f32 x) < 0.00115000003Initial program 98.1%
fabs-neg98.1%
distribute-frac-neg98.1%
distribute-frac-neg298.1%
fabs-neg98.1%
*-commutative98.1%
fabs-neg98.1%
+-commutative98.1%
fabs-neg98.1%
Simplified98.0%
Applied egg-rr79.4%
associate-*r/79.4%
*-rgt-identity79.4%
associate-/r*78.8%
+-commutative78.8%
Simplified78.8%
associate-/l/79.4%
*-un-lft-identity79.4%
times-frac78.7%
pow-flip78.7%
+-commutative78.7%
metadata-eval78.7%
Applied egg-rr78.7%
associate-*r/79.4%
pow-to-exp79.4%
prod-exp97.7%
rem-log-exp97.7%
pow-to-exp97.7%
log-pow97.7%
+-commutative97.7%
log1p-undefine98.0%
Applied egg-rr98.0%
if 0.00115000003 < (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-sqrt48.9%
fabs-sqr48.9%
rem-square-sqrt50.5%
exp-prod50.5%
neg-mul-150.5%
distribute-neg-frac250.5%
Simplified48.9%
Taylor expanded in x around 0 49.6%
*-commutative49.6%
Simplified49.6%
Taylor expanded in x around 0 50.5%
Final simplification72.2%
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(Float32(-x_m) / s)) return Float32(t_0 / Float32(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{t\_0}{s \cdot {\left(t\_0 + 1\right)}^{2}}
\end{array}
\end{array}
Initial 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 x around 0 99.1%
+-commutative99.1%
exp-prod99.1%
rem-square-sqrt49.6%
fabs-sqr49.6%
rem-square-sqrt95.9%
exp-prod95.9%
neg-mul-195.9%
distribute-neg-frac295.9%
Simplified95.9%
Taylor expanded in x around 0 95.9%
exp-prod95.9%
rem-square-sqrt49.6%
fabs-sqr49.6%
rem-square-sqrt60.8%
exp-prod60.8%
neg-mul-160.8%
distribute-neg-frac260.8%
Simplified60.8%
Final simplification60.8%
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(Float32(-x_m) / 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.1%
*-commutative99.1%
fabs-neg99.1%
+-commutative99.1%
fabs-neg99.1%
distribute-lft-in99.1%
*-rgt-identity99.1%
+-commutative99.1%
Simplified99.2%
Taylor expanded in x around 0 99.2%
associate-/r*99.2%
Simplified61.2%
Taylor expanded in x around 0 57.2%
+-commutative57.2%
Simplified57.2%
Final simplification57.2%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (/ (exp (/ (- x_m) s)) s) (pow (+ 1.0 (- 1.0 (/ x_m s))) 2.0)))
x_m = fabs(x);
float code(float x_m, float s) {
return (expf((-x_m / s)) / s) / powf((1.0f + (1.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 = (exp((-x_m / s)) / s) / ((1.0e0 + (1.0e0 - (x_m / s))) ** 2.0e0)
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(exp(Float32(Float32(-x_m) / s)) / s) / (Float32(Float32(1.0) + Float32(Float32(1.0) - Float32(x_m / s))) ^ Float32(2.0))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = (exp((-x_m / s)) / s) / ((single(1.0) + (single(1.0) - (x_m / s))) ^ single(2.0)); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\frac{e^{\frac{-x\_m}{s}}}{s}}{{\left(1 + \left(1 - \frac{x\_m}{s}\right)\right)}^{2}}
\end{array}
Initial 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 x around 0 99.1%
associate-/r*99.1%
exp-prod99.1%
rem-square-sqrt49.6%
fabs-sqr49.6%
rem-square-sqrt59.2%
exp-prod59.2%
neg-mul-159.2%
distribute-neg-frac259.2%
Simplified60.4%
Taylor expanded in x around 0 57.1%
neg-mul-157.1%
unsub-neg57.1%
Simplified57.1%
Final simplification57.1%
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(Float32(-x_m) / 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.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 x around 0 99.1%
associate-/r*99.1%
exp-prod99.1%
rem-square-sqrt49.6%
fabs-sqr49.6%
rem-square-sqrt59.2%
exp-prod59.2%
neg-mul-159.2%
distribute-neg-frac259.2%
Simplified60.4%
Taylor expanded in x around 0 57.0%
*-commutative57.0%
Simplified57.0%
Final simplification57.0%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (* 0.5 (/ (/ 1.0 s) (+ 1.0 (exp (/ x_m s))))))
x_m = fabs(x);
float code(float x_m, float s) {
return 0.5f * ((1.0f / 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 * ((1.0e0 / s) / (1.0e0 + exp((x_m / s))))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(0.5) * Float32(Float32(Float32(1.0) / 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) * ((single(1.0) / s) / (single(1.0) + exp((x_m / s)))); end
\begin{array}{l}
x_m = \left|x\right|
\\
0.5 \cdot \frac{\frac{1}{s}}{1 + e^{\frac{x\_m}{s}}}
\end{array}
Initial 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%
Applied egg-rr64.0%
associate-*r/64.0%
*-rgt-identity64.0%
associate-/r*63.7%
+-commutative63.7%
Simplified63.7%
Applied egg-rr86.6%
Taylor expanded in x around 0 57.1%
neg-mul-157.1%
*-commutative57.1%
exp-to-pow57.1%
metadata-eval57.1%
Simplified57.1%
Final simplification57.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(Float32(-x_m) / 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.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 x around 0 99.1%
associate-/r*99.1%
exp-prod99.1%
rem-square-sqrt49.6%
fabs-sqr49.6%
rem-square-sqrt59.2%
exp-prod59.2%
neg-mul-159.2%
distribute-neg-frac259.2%
Simplified60.4%
Taylor expanded in x around 0 57.0%
*-commutative57.0%
Simplified57.0%
Taylor expanded in x around 0 56.3%
Final simplification56.3%
x_m = (fabs.f32 x)
(FPCore (x_m s)
:precision binary32
(if (<= s 7.99999974612418e-19)
(/ (/ 1.0 s) (- 4.0 (* (/ x_m s) -4.0)))
(/
(- 0.5 (/ (* x_m 0.25) s))
(+ s (+ s (* x_m (+ (* (/ x_m s) 0.5) -1.0)))))))x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (s <= 7.99999974612418e-19f) {
tmp = (1.0f / s) / (4.0f - ((x_m / s) * -4.0f));
} else {
tmp = (0.5f - ((x_m * 0.25f) / s)) / (s + (s + (x_m * (((x_m / s) * 0.5f) + -1.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 (s <= 7.99999974612418e-19) then
tmp = (1.0e0 / s) / (4.0e0 - ((x_m / s) * (-4.0e0)))
else
tmp = (0.5e0 - ((x_m * 0.25e0) / s)) / (s + (s + (x_m * (((x_m / s) * 0.5e0) + (-1.0e0)))))
end if
code = tmp
end function
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (s <= Float32(7.99999974612418e-19)) tmp = Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) - Float32(Float32(x_m / s) * Float32(-4.0)))); else tmp = Float32(Float32(Float32(0.5) - Float32(Float32(x_m * Float32(0.25)) / s)) / Float32(s + Float32(s + Float32(x_m * Float32(Float32(Float32(x_m / s) * Float32(0.5)) + Float32(-1.0)))))); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, s) tmp = single(0.0); if (s <= single(7.99999974612418e-19)) tmp = (single(1.0) / s) / (single(4.0) - ((x_m / s) * single(-4.0))); else tmp = (single(0.5) - ((x_m * single(0.25)) / s)) / (s + (s + (x_m * (((x_m / s) * single(0.5)) + single(-1.0))))); end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;s \leq 7.99999974612418 \cdot 10^{-19}:\\
\;\;\;\;\frac{\frac{1}{s}}{4 - \frac{x\_m}{s} \cdot -4}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5 - \frac{x\_m \cdot 0.25}{s}}{s + \left(s + x\_m \cdot \left(\frac{x\_m}{s} \cdot 0.5 + -1\right)\right)}\\
\end{array}
\end{array}
if s < 7.99999975e-19Initial 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%
Taylor expanded in x around 0 99.0%
associate-/r*98.9%
exp-prod98.9%
rem-square-sqrt47.7%
fabs-sqr47.7%
rem-square-sqrt53.6%
exp-prod53.6%
neg-mul-153.6%
distribute-neg-frac253.6%
Simplified54.6%
Taylor expanded in x around 0 50.3%
*-commutative50.3%
Simplified50.3%
Taylor expanded in x around 0 54.8%
add-sqr-sqrt54.8%
sqrt-unprod76.4%
sqr-neg76.4%
sqrt-unprod-0.0%
add-sqr-sqrt55.2%
distribute-frac-neg255.2%
Applied egg-rr55.2%
distribute-neg-frac255.2%
Simplified55.2%
if 7.99999975e-19 < s Initial program 99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
distribute-lft-in99.3%
*-rgt-identity99.3%
+-commutative99.3%
Simplified99.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.4%
Simplified68.1%
Taylor expanded in x around 0 59.5%
metadata-eval59.5%
distribute-lft-neg-in59.5%
unsub-neg59.5%
associate-*r/62.2%
*-commutative62.2%
Simplified62.2%
Taylor expanded in x around 0 69.5%
Final simplification61.5%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 0.0011500000255182385) (/ 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.0011500000255182385f) {
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.0011500000255182385e0) 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.0011500000255182385)) 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.0011500000255182385)) 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.0011500000255182385:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{s}}{\frac{x\_m \cdot -4}{s}}\\
\end{array}
\end{array}
if x < 0.00115000003Initial program 98.8%
fabs-neg98.8%
distribute-frac-neg98.8%
distribute-frac-neg298.8%
fabs-neg98.8%
*-commutative98.8%
fabs-neg98.8%
+-commutative98.8%
fabs-neg98.8%
Simplified98.8%
Taylor expanded in s around inf 32.7%
if 0.00115000003 < 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%
Simplified100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 53.3%
Taylor expanded in x around inf 53.3%
associate-*r/53.3%
*-commutative53.3%
Simplified53.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(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.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 x around 0 99.1%
associate-/r*99.1%
exp-prod99.1%
rem-square-sqrt49.6%
fabs-sqr49.6%
rem-square-sqrt59.2%
exp-prod59.2%
neg-mul-159.2%
distribute-neg-frac259.2%
Simplified60.4%
Taylor expanded in x around 0 57.0%
*-commutative57.0%
Simplified57.0%
Taylor expanded in x around 0 52.6%
add-sqr-sqrt52.6%
sqrt-unprod64.7%
sqr-neg64.7%
sqrt-unprod-0.0%
add-sqr-sqrt52.8%
distribute-frac-neg252.8%
Applied egg-rr52.8%
distribute-neg-frac252.8%
Simplified52.8%
Final simplification52.8%
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.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 x around 0 99.1%
associate-/r*99.1%
exp-prod99.1%
rem-square-sqrt49.6%
fabs-sqr49.6%
rem-square-sqrt59.2%
exp-prod59.2%
neg-mul-159.2%
distribute-neg-frac259.2%
Simplified60.4%
Taylor expanded in x around 0 57.0%
*-commutative57.0%
Simplified57.0%
Taylor expanded in x around 0 52.6%
Taylor expanded in x around 0 52.6%
*-commutative52.6%
associate-*l/52.6%
associate-/l*52.6%
Simplified52.6%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 0.0011500000255182385) (/ 0.25 s) (/ -0.25 x_m)))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 0.0011500000255182385f) {
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.0011500000255182385e0) 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.0011500000255182385)) 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.0011500000255182385)) 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.0011500000255182385:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.25}{x\_m}\\
\end{array}
\end{array}
if x < 0.00115000003Initial program 98.8%
fabs-neg98.8%
distribute-frac-neg98.8%
distribute-frac-neg298.8%
fabs-neg98.8%
*-commutative98.8%
fabs-neg98.8%
+-commutative98.8%
fabs-neg98.8%
Simplified98.8%
Taylor expanded in s around inf 32.7%
if 0.00115000003 < 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%
Simplified100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 53.3%
Taylor expanded in s around 0 11.5%
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.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 x around 0 99.1%
associate-/r*99.1%
exp-prod99.1%
rem-square-sqrt49.6%
fabs-sqr49.6%
rem-square-sqrt59.2%
exp-prod59.2%
neg-mul-159.2%
distribute-neg-frac259.2%
Simplified60.4%
Taylor expanded in x around 0 57.0%
*-commutative57.0%
Simplified57.0%
Taylor expanded in x around 0 52.6%
Taylor expanded in s around 0 9.4%
herbie shell --seed 2024145
(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))))))