
(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}
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ 2.0 (+ (exp (/ (fabs x) (- s))) (pow E (/ (fabs x) s)))))))
float code(float x, float s) {
return 1.0f / (s * (2.0f + (expf((fabsf(x) / -s)) + powf(((float) M_E), (fabsf(x) / s)))));
}
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(exp(Float32(abs(x) / Float32(-s))) + (Float32(exp(1)) ^ Float32(abs(x) / s)))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (single(2.0) + (exp((abs(x) / -s)) + (single(2.71828182845904523536) ^ (abs(x) / s))))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(2 + \left(e^{\frac{\left|x\right|}{-s}} + {e}^{\left(\frac{\left|x\right|}{s}\right)}\right)\right)}
\end{array}
Initial program 99.7%
Simplified99.8%
expm1-log1p-u98.0%
expm1-udef97.7%
Applied egg-rr97.7%
expm1-def98.0%
expm1-log1p99.8%
associate-/l/99.8%
*-commutative99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
Simplified99.8%
*-un-lft-identity99.8%
exp-prod99.9%
exp-1-e99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ 2.0 (+ (exp (/ (fabs x) (- s))) (exp (/ (fabs x) s)))))))
float code(float x, float s) {
return 1.0f / (s * (2.0f + (expf((fabsf(x) / -s)) + expf((fabsf(x) / s)))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (s * (2.0e0 + (exp((abs(x) / -s)) + exp((abs(x) / s)))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(2.0) + Float32(exp(Float32(abs(x) / Float32(-s))) + exp(Float32(abs(x) / s)))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (single(2.0) + (exp((abs(x) / -s)) + exp((abs(x) / s))))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(2 + \left(e^{\frac{\left|x\right|}{-s}} + e^{\frac{\left|x\right|}{s}}\right)\right)}
\end{array}
Initial program 99.7%
Simplified99.8%
expm1-log1p-u98.0%
expm1-udef97.7%
Applied egg-rr97.7%
expm1-def98.0%
expm1-log1p99.8%
associate-/l/99.8%
*-commutative99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x s) :precision binary32 (/ 1.0 (* (+ s (* s (/ 1.0 (exp (/ x s))))) (+ 1.0 (exp (/ (fabs x) s))))))
float code(float x, float s) {
return 1.0f / ((s + (s * (1.0f / expf((x / s))))) * (1.0f + expf((fabsf(x) / s))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / ((s + (s * (1.0e0 / exp((x / s))))) * (1.0e0 + exp((abs(x) / s))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(s + Float32(s * Float32(Float32(1.0) / exp(Float32(x / s))))) * Float32(Float32(1.0) + exp(Float32(abs(x) / s))))) end
function tmp = code(x, s) tmp = single(1.0) / ((s + (s * (single(1.0) / exp((x / s))))) * (single(1.0) + exp((abs(x) / s)))); end
\begin{array}{l}
\\
\frac{1}{\left(s + s \cdot \frac{1}{e^{\frac{x}{s}}}\right) \cdot \left(1 + e^{\frac{\left|x\right|}{s}}\right)}
\end{array}
Initial program 99.7%
*-lft-identity99.7%
associate-*r/99.7%
associate-/l*99.7%
distribute-frac-neg99.7%
exp-neg99.7%
associate-/r/99.7%
/-rgt-identity99.7%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in s around 0 99.8%
associate-*r*99.8%
distribute-lft-in99.8%
rem-exp-log98.8%
exp-sum98.6%
mul-1-neg98.6%
sub-neg98.6%
exp-diff98.8%
rem-exp-log99.8%
*-rgt-identity99.8%
+-commutative99.8%
Simplified99.8%
add-exp-log98.8%
div-exp98.6%
Applied egg-rr98.6%
exp-diff98.8%
add-exp-log99.8%
div-inv99.8%
add-sqr-sqrt99.8%
add-sqr-sqrt99.8%
add-sqr-sqrt56.5%
fabs-sqr56.5%
add-sqr-sqrt97.8%
Applied egg-rr97.8%
Final simplification97.8%
(FPCore (x s) :precision binary32 (/ 1.0 (* (+ 1.0 (exp (/ (fabs x) s))) (+ s (/ s (exp (/ x s)))))))
float code(float x, float s) {
return 1.0f / ((1.0f + expf((fabsf(x) / s))) * (s + (s / 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((abs(x) / s))) * (s + (s / exp((x / s)))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + exp(Float32(abs(x) / s))) * Float32(s + Float32(s / exp(Float32(x / s)))))) end
function tmp = code(x, s) tmp = single(1.0) / ((single(1.0) + exp((abs(x) / s))) * (s + (s / exp((x / s))))); end
\begin{array}{l}
\\
\frac{1}{\left(1 + e^{\frac{\left|x\right|}{s}}\right) \cdot \left(s + \frac{s}{e^{\frac{x}{s}}}\right)}
\end{array}
Initial program 99.7%
*-lft-identity99.7%
associate-*r/99.7%
associate-/l*99.7%
distribute-frac-neg99.7%
exp-neg99.7%
associate-/r/99.7%
/-rgt-identity99.7%
associate-*l*99.8%
Simplified99.8%
Taylor expanded in s around 0 99.8%
associate-*r*99.8%
distribute-lft-in99.8%
rem-exp-log98.8%
exp-sum98.6%
mul-1-neg98.6%
sub-neg98.6%
exp-diff98.8%
rem-exp-log99.8%
*-rgt-identity99.8%
+-commutative99.8%
Simplified99.8%
add-exp-log98.8%
div-exp98.6%
Applied egg-rr98.6%
expm1-log1p-u98.6%
expm1-udef86.3%
exp-diff86.3%
add-exp-log86.3%
add-sqr-sqrt86.3%
add-sqr-sqrt86.3%
add-sqr-sqrt48.3%
fabs-sqr48.3%
add-sqr-sqrt86.2%
Applied egg-rr86.2%
expm1-def97.8%
expm1-log1p97.8%
Simplified97.8%
Final simplification97.8%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ (pow E (/ (fabs x) s)) 3.0))))
float code(float x, float s) {
return 1.0f / (s * (powf(((float) M_E), (fabsf(x) / s)) + 3.0f));
}
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32((Float32(exp(1)) ^ Float32(abs(x) / s)) + Float32(3.0)))) end
function tmp = code(x, s) tmp = single(1.0) / (s * ((single(2.71828182845904523536) ^ (abs(x) / s)) + single(3.0))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left({e}^{\left(\frac{\left|x\right|}{s}\right)} + 3\right)}
\end{array}
Initial program 99.7%
Simplified99.8%
expm1-log1p-u98.0%
expm1-udef97.7%
Applied egg-rr97.7%
expm1-def98.0%
expm1-log1p99.8%
associate-/l/99.8%
*-commutative99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
Simplified99.8%
Taylor expanded in s around inf 97.2%
Taylor expanded in s around 0 97.2%
*-un-lft-identity99.8%
exp-prod99.9%
exp-1-e99.9%
Applied egg-rr97.2%
Final simplification97.2%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ (exp (/ x s)) 3.0))))
float code(float x, float s) {
return 1.0f / (s * (expf((x / s)) + 3.0f));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (s * (exp((x / s)) + 3.0e0))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(exp(Float32(x / s)) + Float32(3.0)))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (exp((x / s)) + single(3.0))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(e^{\frac{x}{s}} + 3\right)}
\end{array}
Initial program 99.7%
Simplified99.8%
expm1-log1p-u98.0%
expm1-udef97.7%
Applied egg-rr97.7%
expm1-def98.0%
expm1-log1p99.8%
associate-/l/99.8%
*-commutative99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
Simplified99.8%
Taylor expanded in s around inf 97.2%
Taylor expanded in s around 0 97.2%
distribute-lft-in97.2%
add-sqr-sqrt97.2%
add-sqr-sqrt97.2%
add-sqr-sqrt55.3%
fabs-sqr55.3%
add-sqr-sqrt66.1%
Applied egg-rr66.1%
distribute-lft-in66.2%
Simplified66.2%
Final simplification66.2%
(FPCore (x s) :precision binary32 (if (<= x 1.9999999996399175e-23) (/ 1.0 (* s (+ 4.0 (/ x (* s (/ s x)))))) (/ 1.0 (* s (+ 4.0 (* (* x x) (/ 1.0 (* s s))))))))
float code(float x, float s) {
float tmp;
if (x <= 1.9999999996399175e-23f) {
tmp = 1.0f / (s * (4.0f + (x / (s * (s / x)))));
} else {
tmp = 1.0f / (s * (4.0f + ((x * x) * (1.0f / (s * s)))));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 1.9999999996399175e-23) then
tmp = 1.0e0 / (s * (4.0e0 + (x / (s * (s / x)))))
else
tmp = 1.0e0 / (s * (4.0e0 + ((x * x) * (1.0e0 / (s * s)))))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(1.9999999996399175e-23)) tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(x / Float32(s * Float32(s / x)))))); else tmp = Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(Float32(x * x) * Float32(Float32(1.0) / Float32(s * s)))))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(1.9999999996399175e-23)) tmp = single(1.0) / (s * (single(4.0) + (x / (s * (s / x))))); else tmp = single(1.0) / (s * (single(4.0) + ((x * x) * (single(1.0) / (s * s))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.9999999996399175 \cdot 10^{-23}:\\
\;\;\;\;\frac{1}{s \cdot \left(4 + \frac{x}{s \cdot \frac{s}{x}}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s \cdot \left(4 + \left(x \cdot x\right) \cdot \frac{1}{s \cdot s}\right)}\\
\end{array}
\end{array}
if x < 2e-23Initial program 99.7%
Simplified99.9%
expm1-log1p-u97.0%
expm1-udef96.9%
Applied egg-rr96.9%
expm1-def97.0%
expm1-log1p99.9%
associate-/l/99.8%
*-commutative99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.9%
Simplified99.9%
Taylor expanded in s around inf 60.4%
associate-+r+60.4%
distribute-lft1-in60.4%
metadata-eval60.4%
mul0-lft80.6%
associate-+r+80.6%
metadata-eval80.6%
+-commutative80.6%
unpow280.6%
sqr-abs80.6%
unpow280.6%
Simplified80.6%
times-frac78.8%
Applied egg-rr78.8%
clear-num78.8%
frac-times82.0%
*-un-lft-identity82.0%
Applied egg-rr82.0%
if 2e-23 < x Initial program 99.7%
Simplified99.8%
expm1-log1p-u99.4%
expm1-udef98.7%
Applied egg-rr98.7%
expm1-def99.4%
expm1-log1p99.8%
associate-/l/99.8%
*-commutative99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
Simplified99.8%
Taylor expanded in s around inf 47.3%
associate-+r+47.3%
distribute-lft1-in47.3%
metadata-eval47.3%
mul0-lft80.3%
associate-+r+80.3%
metadata-eval80.3%
+-commutative80.3%
unpow280.3%
sqr-abs80.3%
unpow280.3%
Simplified80.3%
div-inv81.2%
Applied egg-rr81.2%
Final simplification81.6%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ 4.0 (* (/ x s) (/ x s))))))
float code(float x, float s) {
return 1.0f / (s * (4.0f + ((x / s) * (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 / s) * (x / s))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(Float32(x / s) * Float32(x / s))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (single(4.0) + ((x / s) * (x / s)))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(4 + \frac{x}{s} \cdot \frac{x}{s}\right)}
\end{array}
Initial program 99.7%
Simplified99.8%
expm1-log1p-u98.0%
expm1-udef97.7%
Applied egg-rr97.7%
expm1-def98.0%
expm1-log1p99.8%
associate-/l/99.8%
*-commutative99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
Simplified99.8%
Taylor expanded in s around inf 54.7%
associate-+r+54.7%
distribute-lft1-in54.7%
metadata-eval54.7%
mul0-lft80.5%
associate-+r+80.5%
metadata-eval80.5%
+-commutative80.5%
unpow280.5%
sqr-abs80.5%
unpow280.5%
Simplified80.5%
times-frac73.6%
Applied egg-rr73.6%
Final simplification73.6%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ 4.0 (/ x (* s (/ s x)))))))
float code(float x, float s) {
return 1.0f / (s * (4.0f + (x / (s * (s / x)))));
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (s * (4.0e0 + (x / (s * (s / x)))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(x / Float32(s * Float32(s / x)))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (single(4.0) + (x / (s * (s / x))))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(4 + \frac{x}{s \cdot \frac{s}{x}}\right)}
\end{array}
Initial program 99.7%
Simplified99.8%
expm1-log1p-u98.0%
expm1-udef97.7%
Applied egg-rr97.7%
expm1-def98.0%
expm1-log1p99.8%
associate-/l/99.8%
*-commutative99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
Simplified99.8%
Taylor expanded in s around inf 54.7%
associate-+r+54.7%
distribute-lft1-in54.7%
metadata-eval54.7%
mul0-lft80.5%
associate-+r+80.5%
metadata-eval80.5%
+-commutative80.5%
unpow280.5%
sqr-abs80.5%
unpow280.5%
Simplified80.5%
times-frac73.6%
Applied egg-rr73.6%
clear-num73.6%
frac-times77.2%
*-un-lft-identity77.2%
Applied egg-rr77.2%
Final simplification77.2%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ 4.0 (/ (* x x) (* s s))))))
float code(float x, float s) {
return 1.0f / (s * (4.0f + ((x * x) / (s * 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 * s))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(Float32(x * x) / Float32(s * s))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (single(4.0) + ((x * x) / (s * s)))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(4 + \frac{x \cdot x}{s \cdot s}\right)}
\end{array}
Initial program 99.7%
Simplified99.8%
expm1-log1p-u98.0%
expm1-udef97.7%
Applied egg-rr97.7%
expm1-def98.0%
expm1-log1p99.8%
associate-/l/99.8%
*-commutative99.8%
+-commutative99.8%
+-commutative99.8%
associate-+l+99.8%
Simplified99.8%
Taylor expanded in s around inf 54.7%
associate-+r+54.7%
distribute-lft1-in54.7%
metadata-eval54.7%
mul0-lft80.5%
associate-+r+80.5%
metadata-eval80.5%
+-commutative80.5%
unpow280.5%
sqr-abs80.5%
unpow280.5%
Simplified80.5%
Final simplification80.5%
(FPCore (x s) :precision binary32 (if (<= x 0.00019999999494757503) (/ 0.25 s) (/ 1.0 (* x (/ x s)))))
float code(float x, float s) {
float tmp;
if (x <= 0.00019999999494757503f) {
tmp = 0.25f / s;
} else {
tmp = 1.0f / (x * (x / s));
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 0.00019999999494757503e0) then
tmp = 0.25e0 / s
else
tmp = 1.0e0 / (x * (x / s))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(0.00019999999494757503)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(1.0) / Float32(x * Float32(x / s))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(0.00019999999494757503)) tmp = single(0.25) / s; else tmp = single(1.0) / (x * (x / s)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.00019999999494757503:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \frac{x}{s}}\\
\end{array}
\end{array}
if x < 1.99999995e-4Initial program 99.6%
Simplified99.7%
Taylor expanded in s around inf 38.6%
if 1.99999995e-4 < x Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
associate-/l/100.0%
*-commutative100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
Simplified100.0%
Taylor expanded in s around inf 26.5%
associate-+r+26.5%
distribute-lft1-in26.5%
metadata-eval26.5%
mul0-lft75.9%
associate-+r+75.9%
metadata-eval75.9%
+-commutative75.9%
unpow275.9%
sqr-abs75.9%
unpow275.9%
Simplified75.9%
Taylor expanded in s around 0 66.6%
unpow266.6%
associate-*r/66.6%
Simplified66.6%
Final simplification46.8%
(FPCore (x s) :precision binary32 (if (<= x 0.00019999999494757503) (/ 0.25 s) (/ 1.0 (/ (* x x) s))))
float code(float x, float s) {
float tmp;
if (x <= 0.00019999999494757503f) {
tmp = 0.25f / s;
} else {
tmp = 1.0f / ((x * x) / s);
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 0.00019999999494757503e0) then
tmp = 0.25e0 / s
else
tmp = 1.0e0 / ((x * x) / s)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(0.00019999999494757503)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(1.0) / Float32(Float32(x * x) / s)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(0.00019999999494757503)) tmp = single(0.25) / s; else tmp = single(1.0) / ((x * x) / s); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.00019999999494757503:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{x \cdot x}{s}}\\
\end{array}
\end{array}
if x < 1.99999995e-4Initial program 99.6%
Simplified99.7%
Taylor expanded in s around inf 38.6%
if 1.99999995e-4 < x Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
associate-/l/100.0%
*-commutative100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
Simplified100.0%
Taylor expanded in s around inf 26.5%
associate-+r+26.5%
distribute-lft1-in26.5%
metadata-eval26.5%
mul0-lft75.9%
associate-+r+75.9%
metadata-eval75.9%
+-commutative75.9%
unpow275.9%
sqr-abs75.9%
unpow275.9%
Simplified75.9%
Taylor expanded in s around 0 66.6%
unpow266.6%
Simplified66.6%
Final simplification46.8%
(FPCore (x s) :precision binary32 (if (<= x 0.00019999999494757503) (/ 0.25 s) (/ s (* x x))))
float code(float x, float s) {
float tmp;
if (x <= 0.00019999999494757503f) {
tmp = 0.25f / s;
} else {
tmp = s / (x * x);
}
return tmp;
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (x <= 0.00019999999494757503e0) then
tmp = 0.25e0 / s
else
tmp = s / (x * x)
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (x <= Float32(0.00019999999494757503)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(s / Float32(x * x)); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (x <= single(0.00019999999494757503)) tmp = single(0.25) / s; else tmp = s / (x * x); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.00019999999494757503:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{s}{x \cdot x}\\
\end{array}
\end{array}
if x < 1.99999995e-4Initial program 99.6%
Simplified99.7%
Taylor expanded in s around inf 38.6%
if 1.99999995e-4 < x Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
associate-/l/100.0%
*-commutative100.0%
+-commutative100.0%
+-commutative100.0%
associate-+l+100.0%
Simplified100.0%
Taylor expanded in s around inf 26.5%
associate-+r+26.5%
distribute-lft1-in26.5%
metadata-eval26.5%
mul0-lft75.9%
associate-+r+75.9%
metadata-eval75.9%
+-commutative75.9%
unpow275.9%
sqr-abs75.9%
unpow275.9%
Simplified75.9%
Taylor expanded in s around 0 64.5%
unpow264.5%
Simplified64.5%
Final simplification46.2%
(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.7%
Simplified99.8%
Taylor expanded in s around inf 28.6%
Final simplification28.6%
herbie shell --seed 2023258
(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))))))