
(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 16 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 (let* ((t_0 (exp (/ (fabs x) (- s))))) (/ t_0 (* (+ t_0 1.0) (fma s t_0 s)))))
float code(float x, float s) {
float t_0 = expf((fabsf(x) / -s));
return t_0 / ((t_0 + 1.0f) * fmaf(s, t_0, s));
}
function code(x, s) t_0 = exp(Float32(abs(x) / Float32(-s))) return Float32(t_0 / Float32(Float32(t_0 + Float32(1.0)) * fma(s, t_0, s))) end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{\left|x\right|}{-s}}\\
\frac{t_0}{\left(t_0 + 1\right) \cdot \mathsf{fma}\left(s, t_0, s\right)}
\end{array}
\end{array}
Initial program 99.4%
fabs-neg99.4%
*-commutative99.4%
fabs-neg99.4%
fabs-neg99.4%
associate-*r*99.4%
/-rgt-identity99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x s) :precision binary32 (/ 1.0 (* (fma s (/ 1.0 (exp (/ x s))) s) (+ 1.0 (exp (/ (fabs x) s))))))
float code(float x, float s) {
return 1.0f / (fmaf(s, (1.0f / expf((x / s))), s) * (1.0f + expf((fabsf(x) / s))));
}
function code(x, s) return Float32(Float32(1.0) / Float32(fma(s, Float32(Float32(1.0) / exp(Float32(x / s))), s) * Float32(Float32(1.0) + exp(Float32(abs(x) / s))))) end
\begin{array}{l}
\\
\frac{1}{\mathsf{fma}\left(s, \frac{1}{e^{\frac{x}{s}}}, s\right) \cdot \left(1 + e^{\frac{\left|x\right|}{s}}\right)}
\end{array}
Initial program 99.4%
Simplified99.4%
*-un-lft-identity99.4%
neg-mul-199.4%
times-frac99.4%
metadata-eval99.4%
metadata-eval99.4%
times-frac99.4%
neg-mul-199.4%
*-un-lft-identity99.4%
distribute-frac-neg99.4%
rec-exp99.4%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt96.7%
Applied egg-rr96.7%
Final simplification96.7%
(FPCore (x s) :precision binary32 (/ (/ 1.0 s) (* (+ 1.0 (exp (/ x s))) (+ 1.0 (exp (/ (- x) s))))))
float code(float x, float s) {
return (1.0f / s) / ((1.0f + expf((x / 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 / s) / ((1.0e0 + exp((x / s))) * (1.0e0 + exp((-x / s))))
end function
function code(x, s) return Float32(Float32(Float32(1.0) / s) / Float32(Float32(Float32(1.0) + exp(Float32(x / s))) * Float32(Float32(1.0) + exp(Float32(Float32(-x) / s))))) end
function tmp = code(x, s) tmp = (single(1.0) / s) / ((single(1.0) + exp((x / s))) * (single(1.0) + exp((-x / s)))); end
\begin{array}{l}
\\
\frac{\frac{1}{s}}{\left(1 + e^{\frac{x}{s}}\right) \cdot \left(1 + e^{\frac{-x}{s}}\right)}
\end{array}
Initial program 99.4%
Simplified99.4%
*-un-lft-identity99.4%
neg-mul-199.4%
times-frac99.4%
metadata-eval99.4%
metadata-eval99.4%
times-frac99.4%
neg-mul-199.4%
*-un-lft-identity99.4%
distribute-frac-neg99.4%
rec-exp99.4%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt96.7%
Applied egg-rr96.7%
associate-/r*96.7%
div-inv96.7%
fma-udef96.7%
+-commutative96.7%
un-div-inv96.7%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt99.4%
Applied egg-rr99.4%
Taylor expanded in s around 0 99.3%
associate-/r*99.4%
rec-exp99.4%
distribute-neg-frac99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ x s)))) (/ 1.0 (* (+ 1.0 t_0) (+ s (/ s t_0))))))
float code(float x, float s) {
float t_0 = expf((x / s));
return 1.0f / ((1.0f + t_0) * (s + (s / t_0)));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
t_0 = exp((x / s))
code = 1.0e0 / ((1.0e0 + t_0) * (s + (s / t_0)))
end function
function code(x, s) t_0 = exp(Float32(x / s)) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + t_0) * Float32(s + Float32(s / t_0)))) end
function tmp = code(x, s) t_0 = exp((x / s)); tmp = single(1.0) / ((single(1.0) + t_0) * (s + (s / t_0))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{x}{s}}\\
\frac{1}{\left(1 + t_0\right) \cdot \left(s + \frac{s}{t_0}\right)}
\end{array}
\end{array}
Initial program 99.4%
Simplified99.4%
*-un-lft-identity99.4%
neg-mul-199.4%
times-frac99.4%
metadata-eval99.4%
metadata-eval99.4%
times-frac99.4%
neg-mul-199.4%
*-un-lft-identity99.4%
distribute-frac-neg99.4%
rec-exp99.4%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt96.7%
Applied egg-rr96.7%
expm1-log1p-u95.4%
expm1-udef94.3%
fma-udef94.3%
+-commutative94.3%
un-div-inv94.3%
add-sqr-sqrt49.4%
fabs-sqr49.4%
add-sqr-sqrt96.6%
Applied egg-rr96.6%
expm1-def97.6%
expm1-log1p99.4%
Simplified99.4%
Final simplification99.4%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ x s)))) (/ (/ 1.0 (+ 1.0 t_0)) (+ s (/ s t_0)))))
float code(float x, float s) {
float t_0 = expf((x / s));
return (1.0f / (1.0f + t_0)) / (s + (s / t_0));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
t_0 = exp((x / s))
code = (1.0e0 / (1.0e0 + t_0)) / (s + (s / t_0))
end function
function code(x, s) t_0 = exp(Float32(x / s)) return Float32(Float32(Float32(1.0) / Float32(Float32(1.0) + t_0)) / Float32(s + Float32(s / t_0))) end
function tmp = code(x, s) t_0 = exp((x / s)); tmp = (single(1.0) / (single(1.0) + t_0)) / (s + (s / t_0)); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{x}{s}}\\
\frac{\frac{1}{1 + t_0}}{s + \frac{s}{t_0}}
\end{array}
\end{array}
Initial program 99.4%
Simplified99.4%
*-un-lft-identity99.4%
neg-mul-199.4%
times-frac99.4%
metadata-eval99.4%
metadata-eval99.4%
times-frac99.4%
neg-mul-199.4%
*-un-lft-identity99.4%
distribute-frac-neg99.4%
rec-exp99.4%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt96.7%
Applied egg-rr96.7%
associate-/r*96.7%
div-inv96.7%
fma-udef96.7%
+-commutative96.7%
un-div-inv96.7%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt99.4%
Applied egg-rr99.4%
associate-*l/99.4%
*-un-lft-identity99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x s) :precision binary32 (let* ((t_0 (exp (/ x s)))) (/ (/ 1.0 (+ s (/ s t_0))) (+ 1.0 t_0))))
float code(float x, float s) {
float t_0 = expf((x / s));
return (1.0f / (s + (s / t_0))) / (1.0f + t_0);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
t_0 = exp((x / s))
code = (1.0e0 / (s + (s / t_0))) / (1.0e0 + t_0)
end function
function code(x, s) t_0 = exp(Float32(x / s)) return Float32(Float32(Float32(1.0) / Float32(s + Float32(s / t_0))) / Float32(Float32(1.0) + t_0)) end
function tmp = code(x, s) t_0 = exp((x / s)); tmp = (single(1.0) / (s + (s / t_0))) / (single(1.0) + t_0); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{\frac{x}{s}}\\
\frac{\frac{1}{s + \frac{s}{t_0}}}{1 + t_0}
\end{array}
\end{array}
Initial program 99.4%
Simplified99.4%
*-un-lft-identity99.4%
neg-mul-199.4%
times-frac99.4%
metadata-eval99.4%
metadata-eval99.4%
times-frac99.4%
neg-mul-199.4%
*-un-lft-identity99.4%
distribute-frac-neg99.4%
rec-exp99.4%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt96.7%
Applied egg-rr96.7%
associate-/r*96.7%
div-inv96.7%
fma-udef96.7%
+-commutative96.7%
un-div-inv96.7%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt99.4%
Applied egg-rr99.4%
un-div-inv99.4%
Applied egg-rr99.4%
Final simplification99.4%
(FPCore (x s) :precision binary32 (* (/ 1.0 (+ 1.0 (exp (/ x s)))) (/ 1.0 (+ s (/ s (+ 1.0 (/ x s)))))))
float code(float x, float s) {
return (1.0f / (1.0f + expf((x / s)))) * (1.0f / (s + (s / (1.0f + (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)))) * (1.0e0 / (s + (s / (1.0e0 + (x / s)))))
end function
function code(x, s) return Float32(Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(x / s)))) * Float32(Float32(1.0) / Float32(s + Float32(s / Float32(Float32(1.0) + Float32(x / s)))))) end
function tmp = code(x, s) tmp = (single(1.0) / (single(1.0) + exp((x / s)))) * (single(1.0) / (s + (s / (single(1.0) + (x / s))))); end
\begin{array}{l}
\\
\frac{1}{1 + e^{\frac{x}{s}}} \cdot \frac{1}{s + \frac{s}{1 + \frac{x}{s}}}
\end{array}
Initial program 99.4%
Simplified99.4%
*-un-lft-identity99.4%
neg-mul-199.4%
times-frac99.4%
metadata-eval99.4%
metadata-eval99.4%
times-frac99.4%
neg-mul-199.4%
*-un-lft-identity99.4%
distribute-frac-neg99.4%
rec-exp99.4%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt96.7%
Applied egg-rr96.7%
associate-/r*96.7%
div-inv96.7%
fma-udef96.7%
+-commutative96.7%
un-div-inv96.7%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt99.4%
Applied egg-rr99.4%
Taylor expanded in x around 0 63.0%
Final simplification63.0%
(FPCore (x s) :precision binary32 (let* ((t_0 (- (* s 2.0) x))) (/ 1.0 (+ t_0 (* (exp (/ x s)) t_0)))))
float code(float x, float s) {
float t_0 = (s * 2.0f) - x;
return 1.0f / (t_0 + (expf((x / s)) * t_0));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
t_0 = (s * 2.0e0) - x
code = 1.0e0 / (t_0 + (exp((x / s)) * t_0))
end function
function code(x, s) t_0 = Float32(Float32(s * Float32(2.0)) - x) return Float32(Float32(1.0) / Float32(t_0 + Float32(exp(Float32(x / s)) * t_0))) end
function tmp = code(x, s) t_0 = (s * single(2.0)) - x; tmp = single(1.0) / (t_0 + (exp((x / s)) * t_0)); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := s \cdot 2 - x\\
\frac{1}{t_0 + e^{\frac{x}{s}} \cdot t_0}
\end{array}
\end{array}
Initial program 99.4%
Simplified99.4%
Taylor expanded in s around inf 95.1%
+-commutative95.1%
mul-1-neg95.1%
unsub-neg95.1%
*-commutative95.1%
Simplified95.1%
distribute-rgt-in95.1%
*-un-lft-identity95.1%
add-sqr-sqrt48.9%
fabs-sqr48.9%
add-sqr-sqrt94.6%
div-inv94.6%
exp-prod80.1%
add-sqr-sqrt42.1%
fabs-sqr42.1%
add-sqr-sqrt56.9%
exp-prod63.2%
div-inv63.2%
add-sqr-sqrt48.9%
fabs-sqr48.9%
add-sqr-sqrt63.8%
Applied egg-rr63.8%
Final simplification63.8%
(FPCore (x s) :precision binary32 (/ (/ 1.0 (+ 1.0 (exp (/ x s)))) (+ s (/ s (+ 1.0 (/ x s))))))
float code(float x, float s) {
return (1.0f / (1.0f + expf((x / s)))) / (s + (s / (1.0f + (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 + (s / (1.0e0 + (x / s))))
end function
function code(x, s) return Float32(Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(x / s)))) / Float32(s + Float32(s / Float32(Float32(1.0) + Float32(x / s))))) end
function tmp = code(x, s) tmp = (single(1.0) / (single(1.0) + exp((x / s)))) / (s + (s / (single(1.0) + (x / s)))); end
\begin{array}{l}
\\
\frac{\frac{1}{1 + e^{\frac{x}{s}}}}{s + \frac{s}{1 + \frac{x}{s}}}
\end{array}
Initial program 99.4%
Simplified99.4%
*-un-lft-identity99.4%
neg-mul-199.4%
times-frac99.4%
metadata-eval99.4%
metadata-eval99.4%
times-frac99.4%
neg-mul-199.4%
*-un-lft-identity99.4%
distribute-frac-neg99.4%
rec-exp99.4%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt96.7%
Applied egg-rr96.7%
associate-/r*96.7%
div-inv96.7%
fma-udef96.7%
+-commutative96.7%
un-div-inv96.7%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt99.4%
Applied egg-rr99.4%
associate-*l/99.4%
*-un-lft-identity99.4%
Applied egg-rr99.4%
Taylor expanded in x around 0 63.0%
Final simplification63.0%
(FPCore (x s) :precision binary32 (* (/ 1.0 (+ 1.0 (exp (/ x s)))) (/ 1.0 (- (* s 2.0) x))))
float code(float x, float s) {
return (1.0f / (1.0f + expf((x / s)))) * (1.0f / ((s * 2.0f) - x));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / (1.0e0 + exp((x / s)))) * (1.0e0 / ((s * 2.0e0) - x))
end function
function code(x, s) return Float32(Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(x / s)))) * Float32(Float32(1.0) / Float32(Float32(s * Float32(2.0)) - x))) end
function tmp = code(x, s) tmp = (single(1.0) / (single(1.0) + exp((x / s)))) * (single(1.0) / ((s * single(2.0)) - x)); end
\begin{array}{l}
\\
\frac{1}{1 + e^{\frac{x}{s}}} \cdot \frac{1}{s \cdot 2 - x}
\end{array}
Initial program 99.4%
Simplified99.4%
Taylor expanded in s around inf 95.1%
+-commutative95.1%
mul-1-neg95.1%
unsub-neg95.1%
*-commutative95.1%
Simplified95.1%
inv-pow95.1%
unpow-prod-down95.1%
inv-pow95.1%
add-sqr-sqrt48.9%
fabs-sqr48.9%
add-sqr-sqrt94.7%
inv-pow94.7%
frac-2neg94.7%
add-log-exp94.5%
neg-log94.5%
exp-sum93.9%
div-inv93.9%
exp-prod79.2%
add-sqr-sqrt41.9%
fabs-sqr41.9%
add-sqr-sqrt56.0%
Applied egg-rr63.8%
Final simplification63.8%
(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(0.5) / Float32(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{0.5}{s \cdot \left(1 + e^{\frac{x}{s}}\right)}
\end{array}
Initial program 99.4%
Simplified99.4%
*-un-lft-identity99.4%
neg-mul-199.4%
times-frac99.4%
metadata-eval99.4%
metadata-eval99.4%
times-frac99.4%
neg-mul-199.4%
*-un-lft-identity99.4%
distribute-frac-neg99.4%
rec-exp99.4%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt96.7%
Applied egg-rr96.7%
Taylor expanded in x around 0 94.7%
associate-/r*94.7%
Simplified94.7%
expm1-log1p-u93.6%
expm1-udef93.4%
associate-/l/93.4%
div-inv93.4%
exp-prod79.6%
add-sqr-sqrt42.4%
fabs-sqr42.4%
add-sqr-sqrt55.0%
exp-prod60.3%
div-inv60.3%
Applied egg-rr60.3%
expm1-def60.5%
expm1-log1p61.6%
*-commutative61.6%
Simplified61.6%
Final simplification61.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.4%
Simplified99.4%
*-un-lft-identity99.4%
neg-mul-199.4%
times-frac99.4%
metadata-eval99.4%
metadata-eval99.4%
times-frac99.4%
neg-mul-199.4%
*-un-lft-identity99.4%
distribute-frac-neg99.4%
rec-exp99.4%
add-sqr-sqrt51.1%
fabs-sqr51.1%
add-sqr-sqrt96.7%
Applied egg-rr96.7%
Taylor expanded in x around 0 94.7%
associate-/r*94.7%
Simplified94.7%
div-inv94.7%
frac-2neg94.7%
add-log-exp94.0%
neg-log94.0%
exp-sum93.4%
div-inv93.4%
exp-prod80.3%
add-sqr-sqrt42.6%
fabs-sqr42.6%
add-sqr-sqrt55.7%
exp-prod60.7%
div-inv60.7%
exp-sum61.2%
Applied egg-rr61.6%
associate-*r/61.6%
*-rgt-identity61.6%
Simplified61.6%
Final simplification61.6%
(FPCore (x s) :precision binary32 (/ 1.0 (+ (* s 4.0) (/ (* x x) s))))
float code(float x, float s) {
return 1.0f / ((s * 4.0f) + ((x * x) / s));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / ((s * 4.0e0) + ((x * x) / s))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(s * Float32(4.0)) + Float32(Float32(x * x) / s))) end
function tmp = code(x, s) tmp = single(1.0) / ((s * single(4.0)) + ((x * x) / s)); end
\begin{array}{l}
\\
\frac{1}{s \cdot 4 + \frac{x \cdot x}{s}}
\end{array}
Initial program 99.4%
Simplified99.4%
Taylor expanded in s around -inf 38.9%
+-commutative38.9%
mul-1-neg38.9%
distribute-lft1-in63.6%
metadata-eval63.6%
associate-*r/63.6%
mul-1-neg63.6%
remove-double-neg63.6%
associate-+r+63.6%
Simplified63.6%
Final simplification63.6%
(FPCore (x s) :precision binary32 (* (/ 1.0 (- (* s 2.0) x)) 0.5))
float code(float x, float s) {
return (1.0f / ((s * 2.0f) - x)) * 0.5f;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (1.0e0 / ((s * 2.0e0) - x)) * 0.5e0
end function
function code(x, s) return Float32(Float32(Float32(1.0) / Float32(Float32(s * Float32(2.0)) - x)) * Float32(0.5)) end
function tmp = code(x, s) tmp = (single(1.0) / ((s * single(2.0)) - x)) * single(0.5); end
\begin{array}{l}
\\
\frac{1}{s \cdot 2 - x} \cdot 0.5
\end{array}
Initial program 99.4%
Simplified99.4%
Taylor expanded in s around inf 95.1%
+-commutative95.1%
mul-1-neg95.1%
unsub-neg95.1%
*-commutative95.1%
Simplified95.1%
inv-pow95.1%
unpow-prod-down95.1%
inv-pow95.1%
add-sqr-sqrt48.9%
fabs-sqr48.9%
add-sqr-sqrt94.7%
inv-pow94.7%
frac-2neg94.7%
add-log-exp94.5%
neg-log94.5%
exp-sum93.9%
div-inv93.9%
exp-prod79.2%
add-sqr-sqrt41.9%
fabs-sqr41.9%
add-sqr-sqrt56.0%
Applied egg-rr63.8%
Taylor expanded in x around 0 25.8%
Final simplification25.8%
(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.4%
fabs-neg99.4%
*-commutative99.4%
fabs-neg99.4%
fabs-neg99.4%
associate-*r*99.4%
/-rgt-identity99.4%
Simplified99.4%
Taylor expanded in s around inf 23.6%
Final simplification23.6%
(FPCore (x s) :precision binary32 1.0)
float code(float x, float s) {
return 1.0f;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0
end function
function code(x, s) return Float32(1.0) end
function tmp = code(x, s) tmp = single(1.0); end
\begin{array}{l}
\\
1
\end{array}
Initial program 99.4%
add-exp-log97.7%
log-div97.7%
add-log-exp97.9%
add-sqr-sqrt-0.0%
sqrt-unprod19.9%
sqr-neg19.9%
sqrt-unprod19.8%
add-sqr-sqrt19.8%
add-sqr-sqrt8.2%
fabs-sqr8.2%
add-sqr-sqrt55.5%
associate-*l*55.5%
Applied egg-rr83.4%
Taylor expanded in x around inf 38.8%
Taylor expanded in x around 0 8.1%
Final simplification8.1%
herbie shell --seed 2023336
(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))))))