
(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 15 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}
(FPCore (x s) :precision binary32 (/ 1.0 (* (+ 1.0 (exp (/ (- (fabs x)) s))) (fma s (exp (/ (fabs x) s)) s))))
float code(float x, float s) {
return 1.0f / ((1.0f + expf((-fabsf(x) / s))) * fmaf(s, expf((fabsf(x) / s)), s));
}
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + exp(Float32(Float32(-abs(x)) / s))) * fma(s, exp(Float32(abs(x) / s)), s))) end
\begin{array}{l}
\\
\frac{1}{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \mathsf{fma}\left(s, e^{\frac{\left|x\right|}{s}}, s\right)}
\end{array}
Initial program 99.8%
Simplified99.9%
Final simplification99.9%
(FPCore (x s) :precision binary32 (/ 1.0 (* (+ 1.0 (exp (/ (- x) s))) (* s (+ 1.0 (exp (/ x s)))))))
float code(float x, float s) {
return 1.0f / ((1.0f + expf((-x / s))) * (s * (1.0f + expf((x / s)))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / ((1.0e0 + exp((-x / s))) * (s * (1.0e0 + exp((x / s)))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + exp(Float32(Float32(-x) / s))) * Float32(s * Float32(Float32(1.0) + exp(Float32(x / s)))))) end
function tmp = code(x, s) tmp = single(1.0) / ((single(1.0) + exp((-x / s))) * (s * (single(1.0) + exp((x / s))))); end
\begin{array}{l}
\\
\frac{1}{\left(1 + e^{\frac{-x}{s}}\right) \cdot \left(s \cdot \left(1 + e^{\frac{x}{s}}\right)\right)}
\end{array}
Initial program 99.8%
Simplified99.9%
fma-udef99.8%
+-commutative99.8%
add-sqr-sqrt99.8%
sqrt-unprod93.8%
sqr-neg93.8%
sqrt-unprod-0.0%
add-sqr-sqrt28.2%
*-commutative28.2%
distribute-rgt1-in28.2%
+-commutative28.2%
*-un-lft-identity28.2%
Applied egg-rr64.6%
distribute-frac-neg64.6%
rec-exp64.6%
frac-2neg64.6%
frac-2neg64.6%
add-sqr-sqrt48.7%
fabs-sqr48.7%
add-sqr-sqrt99.8%
Applied egg-rr99.8%
rec-exp99.8%
distribute-neg-frac99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x s) :precision binary32 (/ 1.0 (* 2.0 (* s (+ 1.0 (pow E (/ x s)))))))
float code(float x, float s) {
return 1.0f / (2.0f * (s * (1.0f + powf(((float) M_E), (x / s)))));
}
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(2.0) * Float32(s * Float32(Float32(1.0) + (Float32(exp(1)) ^ Float32(x / s)))))) end
function tmp = code(x, s) tmp = single(1.0) / (single(2.0) * (s * (single(1.0) + (single(2.71828182845904523536) ^ (x / s))))); end
\begin{array}{l}
\\
\frac{1}{2 \cdot \left(s \cdot \left(1 + {e}^{\left(\frac{x}{s}\right)}\right)\right)}
\end{array}
Initial program 99.8%
Simplified99.9%
fma-udef99.8%
+-commutative99.8%
add-sqr-sqrt99.8%
sqrt-unprod93.8%
sqr-neg93.8%
sqrt-unprod-0.0%
add-sqr-sqrt28.2%
*-commutative28.2%
distribute-rgt1-in28.2%
+-commutative28.2%
*-un-lft-identity28.2%
Applied egg-rr64.6%
Taylor expanded in s around inf 62.6%
*-un-lft-identity62.6%
exp-prod62.6%
Applied egg-rr62.6%
exp-1-e62.6%
Simplified62.6%
Final simplification62.6%
(FPCore (x s) :precision binary32 (/ 1.0 (* (* s (+ 1.0 (exp (/ x s)))) 2.0)))
float code(float x, float s) {
return 1.0f / ((s * (1.0f + expf((x / s)))) * 2.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / ((s * (1.0e0 + exp((x / s)))) * 2.0e0)
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(s * Float32(Float32(1.0) + exp(Float32(x / s)))) * Float32(2.0))) end
function tmp = code(x, s) tmp = single(1.0) / ((s * (single(1.0) + exp((x / s)))) * single(2.0)); end
\begin{array}{l}
\\
\frac{1}{\left(s \cdot \left(1 + e^{\frac{x}{s}}\right)\right) \cdot 2}
\end{array}
Initial program 99.8%
Simplified99.9%
fma-udef99.8%
+-commutative99.8%
add-sqr-sqrt99.8%
sqrt-unprod93.8%
sqr-neg93.8%
sqrt-unprod-0.0%
add-sqr-sqrt28.2%
*-commutative28.2%
distribute-rgt1-in28.2%
+-commutative28.2%
*-un-lft-identity28.2%
Applied egg-rr64.6%
Taylor expanded in s around inf 62.6%
Final simplification62.6%
(FPCore (x s) :precision binary32 (/ (/ 0.5 s) (+ 1.0 (exp (/ x s)))))
float code(float x, float s) {
return (0.5f / s) / (1.0f + expf((x / s)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (0.5e0 / s) / (1.0e0 + exp((x / s)))
end function
function code(x, s) return Float32(Float32(Float32(0.5) / s) / Float32(Float32(1.0) + exp(Float32(x / s)))) end
function tmp = code(x, s) tmp = (single(0.5) / s) / (single(1.0) + exp((x / s))); end
\begin{array}{l}
\\
\frac{\frac{0.5}{s}}{1 + e^{\frac{x}{s}}}
\end{array}
Initial program 99.8%
Simplified99.9%
fma-udef99.8%
+-commutative99.8%
add-sqr-sqrt99.8%
sqrt-unprod93.8%
sqr-neg93.8%
sqrt-unprod-0.0%
add-sqr-sqrt28.2%
*-commutative28.2%
distribute-rgt1-in28.2%
+-commutative28.2%
*-un-lft-identity28.2%
Applied egg-rr64.6%
Taylor expanded in s around inf 62.6%
Taylor expanded in x around inf 62.6%
associate-/r*62.6%
Simplified62.6%
Final simplification62.6%
(FPCore (x s)
:precision binary32
(let* ((t_0 (+ 4.0 (/ (* x 2.0) s))) (t_1 (* (/ x s) (+ (/ x s) 2.0))))
(if (<= x 9.999999960041972e-12)
(/ 1.0 (* s (/ (- (* t_1 t_1) (* t_0 t_0)) (- t_1 t_0))))
(/ 1.0 (+ (* s t_1) (* s t_0))))))
float code(float x, float s) {
float t_0 = 4.0f + ((x * 2.0f) / s);
float t_1 = (x / s) * ((x / s) + 2.0f);
float tmp;
if (x <= 9.999999960041972e-12f) {
tmp = 1.0f / (s * (((t_1 * t_1) - (t_0 * t_0)) / (t_1 - t_0)));
} else {
tmp = 1.0f / ((s * t_1) + (s * t_0));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: t_1
real(4) :: tmp
t_0 = 4.0e0 + ((x * 2.0e0) / s)
t_1 = (x / s) * ((x / s) + 2.0e0)
if (x <= 9.999999960041972e-12) then
tmp = 1.0e0 / (s * (((t_1 * t_1) - (t_0 * t_0)) / (t_1 - t_0)))
else
tmp = 1.0e0 / ((s * t_1) + (s * t_0))
end if
code = tmp
end function
function code(x, s) t_0 = Float32(Float32(4.0) + Float32(Float32(x * Float32(2.0)) / s)) t_1 = Float32(Float32(x / s) * Float32(Float32(x / s) + Float32(2.0))) tmp = Float32(0.0) if (x <= Float32(9.999999960041972e-12)) tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(Float32(t_1 * t_1) - Float32(t_0 * t_0)) / Float32(t_1 - t_0)))); else tmp = Float32(Float32(1.0) / Float32(Float32(s * t_1) + Float32(s * t_0))); end return tmp end
function tmp_2 = code(x, s) t_0 = single(4.0) + ((x * single(2.0)) / s); t_1 = (x / s) * ((x / s) + single(2.0)); tmp = single(0.0); if (x <= single(9.999999960041972e-12)) tmp = single(1.0) / (s * (((t_1 * t_1) - (t_0 * t_0)) / (t_1 - t_0))); else tmp = single(1.0) / ((s * t_1) + (s * t_0)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 + \frac{x \cdot 2}{s}\\
t_1 := \frac{x}{s} \cdot \left(\frac{x}{s} + 2\right)\\
\mathbf{if}\;x \leq 9.999999960041972 \cdot 10^{-12}:\\
\;\;\;\;\frac{1}{s \cdot \frac{t_1 \cdot t_1 - t_0 \cdot t_0}{t_1 - t_0}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot t_1 + s \cdot t_0}\\
\end{array}
\end{array}
if x < 9.99999996e-12Initial program 99.7%
Simplified99.8%
Applied egg-rr45.8%
expm1-def45.8%
expm1-log1p47.7%
associate-/l/47.7%
*-commutative47.7%
Simplified47.7%
Taylor expanded in x around 0 70.2%
unpow270.2%
+-commutative70.2%
+-commutative70.2%
Applied egg-rr70.2%
metadata-eval70.2%
distribute-lft-in52.1%
flip-+45.4%
Applied egg-rr45.4%
if 9.99999996e-12 < x Initial program 99.9%
Simplified99.9%
Applied egg-rr97.9%
expm1-def97.9%
expm1-log1p97.9%
associate-/l/97.9%
*-commutative97.9%
Simplified97.9%
Taylor expanded in x around 0 78.1%
unpow278.1%
+-commutative78.1%
+-commutative78.1%
Applied egg-rr78.1%
metadata-eval78.1%
distribute-lft-in78.1%
distribute-rgt-in78.1%
*-commutative78.1%
metadata-eval78.1%
+-commutative78.1%
metadata-eval78.1%
Applied egg-rr78.1%
Final simplification54.8%
(FPCore (x s) :precision binary32 (/ 1.0 (+ (* s (* (/ x s) (+ (/ x s) 2.0))) (* s (+ 4.0 (/ (* x 2.0) s))))))
float code(float x, float s) {
return 1.0f / ((s * ((x / s) * ((x / s) + 2.0f))) + (s * (4.0f + ((x * 2.0f) / s))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / ((s * ((x / s) * ((x / s) + 2.0e0))) + (s * (4.0e0 + ((x * 2.0e0) / s))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(s * Float32(Float32(x / s) * Float32(Float32(x / s) + Float32(2.0)))) + Float32(s * Float32(Float32(4.0) + Float32(Float32(x * Float32(2.0)) / s))))) end
function tmp = code(x, s) tmp = single(1.0) / ((s * ((x / s) * ((x / s) + single(2.0)))) + (s * (single(4.0) + ((x * single(2.0)) / s)))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(\frac{x}{s} \cdot \left(\frac{x}{s} + 2\right)\right) + s \cdot \left(4 + \frac{x \cdot 2}{s}\right)}
\end{array}
Initial program 99.8%
Simplified99.9%
Applied egg-rr60.8%
expm1-def60.8%
expm1-log1p62.2%
associate-/l/62.2%
*-commutative62.2%
Simplified62.2%
Taylor expanded in x around 0 72.5%
unpow272.5%
+-commutative72.5%
+-commutative72.5%
Applied egg-rr72.5%
metadata-eval72.5%
distribute-lft-in59.6%
distribute-rgt-in59.6%
*-commutative59.6%
metadata-eval59.6%
+-commutative59.6%
metadata-eval59.6%
Applied egg-rr59.6%
Final simplification59.6%
(FPCore (x s) :precision binary32 (if (<= x 1.2000000136174153e-17) (/ 0.25 s) (/ 1.0 (* s (* (/ x s) (+ (/ x s) 2.0))))))
float code(float x, float s) {
float tmp;
if (x <= 1.2000000136174153e-17f) {
tmp = 0.25f / s;
} else {
tmp = 1.0f / (s * ((x / s) * ((x / s) + 2.0f)));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 1.2000000136174153e-17) then
tmp = 0.25e0 / s
else
tmp = 1.0e0 / (s * ((x / s) * ((x / s) + 2.0e0)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.2000000136174153e-17)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(x / s) * Float32(Float32(x / s) + Float32(2.0))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.2000000136174153e-17)) tmp = single(0.25) / s; else tmp = single(1.0) / (s * ((x / s) * ((x / s) + single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.2000000136174153 \cdot 10^{-17}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(\frac{x}{s} \cdot \left(\frac{x}{s} + 2\right)\right)}\\
\end{array}
\end{array}
if x < 1.20000001e-17Initial program 99.7%
Simplified99.9%
Taylor expanded in s around inf 42.3%
if 1.20000001e-17 < x Initial program 99.8%
Simplified99.9%
Applied egg-rr97.1%
expm1-def97.1%
expm1-log1p97.1%
associate-/l/97.1%
*-commutative97.1%
Simplified97.1%
Taylor expanded in x around 0 69.5%
unpow269.5%
+-commutative69.5%
+-commutative69.5%
Applied egg-rr69.5%
Taylor expanded in x around inf 67.7%
Final simplification50.9%
(FPCore (x s) :precision binary32 (if (<= x 2.0000000233721948e-7) (/ 1.0 (+ (/ (* x x) s) (* s 4.0))) (/ 1.0 (* s (* (/ x s) (+ (/ x s) 2.0))))))
float code(float x, float s) {
float tmp;
if (x <= 2.0000000233721948e-7f) {
tmp = 1.0f / (((x * x) / s) + (s * 4.0f));
} else {
tmp = 1.0f / (s * ((x / s) * ((x / s) + 2.0f)));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 2.0000000233721948e-7) then
tmp = 1.0e0 / (((x * x) / s) + (s * 4.0e0))
else
tmp = 1.0e0 / (s * ((x / s) * ((x / s) + 2.0e0)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(2.0000000233721948e-7)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(x * x) / s) + Float32(s * Float32(4.0)))); else tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(x / s) * Float32(Float32(x / s) + Float32(2.0))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(2.0000000233721948e-7)) tmp = single(1.0) / (((x * x) / s) + (s * single(4.0))); else tmp = single(1.0) / (s * ((x / s) * ((x / s) + single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.0000000233721948 \cdot 10^{-7}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x}{s} + s \cdot 4}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(\frac{x}{s} \cdot \left(\frac{x}{s} + 2\right)\right)}\\
\end{array}
\end{array}
if x < 2.00000002e-7Initial program 99.7%
Simplified99.8%
Taylor expanded in s around -inf 51.3%
+-commutative51.3%
mul-1-neg51.3%
distribute-lft1-in65.5%
metadata-eval65.5%
associate-*r/65.5%
mul-1-neg65.5%
remove-double-neg65.5%
associate-+l+65.5%
unpow265.5%
sqr-abs65.5%
+-commutative65.5%
Simplified66.0%
if 2.00000002e-7 < x Initial program 100.0%
Simplified100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
associate-/l/100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 82.1%
unpow282.1%
+-commutative82.1%
+-commutative82.1%
Applied egg-rr82.1%
Taylor expanded in x around inf 82.1%
Final simplification70.1%
(FPCore (x s) :precision binary32 (let* ((t_0 (+ (/ x s) 2.0))) (/ 1.0 (* s (* t_0 t_0)))))
float code(float x, float s) {
float t_0 = (x / s) + 2.0f;
return 1.0f / (s * (t_0 * t_0));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
t_0 = (x / s) + 2.0e0
code = 1.0e0 / (s * (t_0 * t_0))
end function
function code(x, s) t_0 = Float32(Float32(x / s) + Float32(2.0)) return Float32(Float32(1.0) / Float32(s * Float32(t_0 * t_0))) end
function tmp = code(x, s) t_0 = (x / s) + single(2.0); tmp = single(1.0) / (s * (t_0 * t_0)); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{s} + 2\\
\frac{1}{s \cdot \left(t_0 \cdot t_0\right)}
\end{array}
\end{array}
Initial program 99.8%
Simplified99.9%
Applied egg-rr60.8%
expm1-def60.8%
expm1-log1p62.2%
associate-/l/62.2%
*-commutative62.2%
Simplified62.2%
Taylor expanded in x around 0 72.5%
unpow272.5%
+-commutative72.5%
+-commutative72.5%
Applied egg-rr72.5%
Final simplification72.5%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ 4.0 (* (/ x s) 4.0)))))
float code(float x, float s) {
return 1.0f / (s * (4.0f + ((x / s) * 4.0f)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (s * (4.0e0 + ((x / s) * 4.0e0)))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(Float32(x / s) * Float32(4.0))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (single(4.0) + ((x / s) * single(4.0)))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(4 + \frac{x}{s} \cdot 4\right)}
\end{array}
Initial program 99.8%
Simplified99.9%
Applied egg-rr60.8%
expm1-def60.8%
expm1-log1p62.2%
associate-/l/62.2%
*-commutative62.2%
Simplified62.2%
Taylor expanded in x around 0 52.3%
*-commutative52.3%
Simplified52.3%
Final simplification52.3%
(FPCore (x s) :precision binary32 (if (<= x 3.999999989900971e-6) (/ 0.25 s) (/ 0.25 x)))
float code(float x, float s) {
float tmp;
if (x <= 3.999999989900971e-6f) {
tmp = 0.25f / s;
} else {
tmp = 0.25f / x;
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 3.999999989900971e-6) then
tmp = 0.25e0 / s
else
tmp = 0.25e0 / x
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(3.999999989900971e-6)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(0.25) / x); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(3.999999989900971e-6)) tmp = single(0.25) / s; else tmp = single(0.25) / x; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.999999989900971 \cdot 10^{-6}:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{x}\\
\end{array}
\end{array}
if x < 3.99999999e-6Initial program 99.7%
Simplified99.8%
Taylor expanded in s around inf 39.6%
if 3.99999999e-6 < x Initial program 100.0%
Simplified100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
associate-/l/100.0%
*-commutative100.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 simplification32.3%
(FPCore (x s) :precision binary32 (/ 1.0 (* 4.0 (+ x s))))
float code(float x, float s) {
return 1.0f / (4.0f * (x + s));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (4.0e0 * (x + s))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(4.0) * Float32(x + s))) end
function tmp = code(x, s) tmp = single(1.0) / (single(4.0) * (x + s)); end
\begin{array}{l}
\\
\frac{1}{4 \cdot \left(x + s\right)}
\end{array}
Initial program 99.8%
Simplified99.9%
Applied egg-rr60.8%
expm1-def60.8%
expm1-log1p62.2%
associate-/l/62.2%
*-commutative62.2%
Simplified62.2%
Taylor expanded in s around inf 31.8%
distribute-lft-out31.8%
Simplified31.8%
Final simplification31.8%
(FPCore (x s) :precision binary32 (/ 0.25 (+ x s)))
float code(float x, float s) {
return 0.25f / (x + s);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.25e0 / (x + s)
end function
function code(x, s) return Float32(Float32(0.25) / Float32(x + s)) end
function tmp = code(x, s) tmp = single(0.25) / (x + s); end
\begin{array}{l}
\\
\frac{0.25}{x + s}
\end{array}
Initial program 99.8%
Simplified99.9%
Applied egg-rr60.8%
expm1-def60.8%
expm1-log1p62.2%
associate-/l/62.2%
*-commutative62.2%
Simplified62.2%
Taylor expanded in s around inf 31.8%
distribute-lft-out31.8%
Simplified31.8%
expm1-log1p-u29.8%
expm1-udef60.6%
associate-/r*60.6%
metadata-eval60.6%
+-commutative60.6%
Applied egg-rr60.6%
expm1-def29.6%
expm1-log1p31.5%
+-commutative31.5%
Simplified31.5%
Final simplification31.5%
(FPCore (x s) :precision binary32 (/ 0.25 s))
float code(float x, float s) {
return 0.25f / s;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.25e0 / s
end function
function code(x, s) return Float32(Float32(0.25) / s) end
function tmp = code(x, s) tmp = single(0.25) / s; end
\begin{array}{l}
\\
\frac{0.25}{s}
\end{array}
Initial program 99.8%
Simplified99.9%
Taylor expanded in s around inf 30.7%
Final simplification30.7%
herbie shell --seed 2024018
(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))))))