
(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 13 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)) (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) / s)) + exp(Float32(abs(x) / Float32(-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.6%
Simplified99.7%
expm1-log1p-u97.9%
expm1-udef97.9%
associate-/l/97.9%
Applied egg-rr97.9%
expm1-def97.9%
expm1-log1p99.7%
*-commutative99.7%
+-commutative99.7%
associate-+r+99.7%
+-commutative99.7%
associate-+l+99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x s) :precision binary32 (/ 1.0 (* (+ 1.0 (exp (/ x s))) (+ s (* s (exp (/ (fabs x) s)))))))
float code(float x, float s) {
return 1.0f / ((1.0f + expf((x / s))) * (s + (s * expf((fabsf(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 * exp((abs(x) / s)))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + exp(Float32(x / s))) * Float32(s + Float32(s * exp(Float32(abs(x) / s)))))) end
function tmp = code(x, s) tmp = single(1.0) / ((single(1.0) + exp((x / s))) * (s + (s * exp((abs(x) / s))))); end
\begin{array}{l}
\\
\frac{1}{\left(1 + e^{\frac{x}{s}}\right) \cdot \left(s + s \cdot e^{\frac{\left|x\right|}{s}}\right)}
\end{array}
Initial program 99.6%
*-lft-identity99.6%
associate-*r/99.6%
associate-/l*99.6%
distribute-frac-neg99.6%
exp-neg99.6%
associate-/r/99.6%
/-rgt-identity99.6%
associate-*l*99.7%
Simplified99.7%
Taylor expanded in x around 0 99.7%
add-sqr-sqrt-0.0%
sqrt-unprod94.1%
mul-1-neg94.1%
mul-1-neg94.1%
sqr-neg94.1%
sqrt-unprod94.1%
add-sqr-sqrt94.1%
add-sqr-sqrt43.4%
fabs-sqr43.4%
add-sqr-sqrt97.9%
add-sqr-sqrt43.4%
fabs-sqr43.4%
add-sqr-sqrt94.1%
expm1-log1p-u94.1%
expm1-udef94.0%
Applied egg-rr97.9%
associate--l+97.9%
metadata-eval97.9%
+-rgt-identity97.9%
Simplified97.9%
Final simplification97.9%
(FPCore (x s) :precision binary32 (/ (/ 1.0 s) (+ 1.0 (+ 2.0 (exp (/ (fabs x) s))))))
float code(float x, float s) {
return (1.0f / s) / (1.0f + (2.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) / (1.0e0 + (2.0e0 + exp((abs(x) / s))))
end function
function code(x, s) return Float32(Float32(Float32(1.0) / s) / Float32(Float32(1.0) + Float32(Float32(2.0) + exp(Float32(abs(x) / s))))) end
function tmp = code(x, s) tmp = (single(1.0) / s) / (single(1.0) + (single(2.0) + exp((abs(x) / s)))); end
\begin{array}{l}
\\
\frac{\frac{1}{s}}{1 + \left(2 + e^{\frac{\left|x\right|}{s}}\right)}
\end{array}
Initial program 99.6%
Simplified99.7%
Taylor expanded in s around inf 96.4%
Final simplification96.4%
(FPCore (x s) :precision binary32 (/ 1.0 (* s (+ (exp (/ (fabs x) s)) 3.0))))
float code(float x, float s) {
return 1.0f / (s * (expf((fabsf(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((abs(x) / s)) + 3.0e0))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(exp(Float32(abs(x) / s)) + Float32(3.0)))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (exp((abs(x) / s)) + single(3.0))); end
\begin{array}{l}
\\
\frac{1}{s \cdot \left(e^{\frac{\left|x\right|}{s}} + 3\right)}
\end{array}
Initial program 99.6%
Simplified99.7%
Taylor expanded in s around inf 96.4%
Taylor expanded in s around 0 96.4%
+-commutative96.4%
Simplified96.4%
Final simplification96.4%
(FPCore (x s) :precision binary32 (/ (exp (/ (- (fabs x)) s)) (* s 4.0)))
float code(float x, float s) {
return expf((-fabsf(x) / s)) / (s * 4.0f);
}
real(4) function code(x, s)
real(4), intent (in) :: x
real(4), intent (in) :: s
code = exp((-abs(x) / s)) / (s * 4.0e0)
end function
function code(x, s) return Float32(exp(Float32(Float32(-abs(x)) / s)) / Float32(s * Float32(4.0))) end
function tmp = code(x, s) tmp = exp((-abs(x) / s)) / (s * single(4.0)); end
\begin{array}{l}
\\
\frac{e^{\frac{-\left|x\right|}{s}}}{s \cdot 4}
\end{array}
Initial program 99.6%
associate-*l*99.7%
+-commutative99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in s around inf 94.4%
Final simplification94.4%
(FPCore (x s) :precision binary32 (if (<= x -1.9999999996399175e-23) (/ 1.0 (* s (+ 4.0 (/ (* x x) (* s s))))) (* (/ 1.0 s) (/ 1.0 (+ (exp (/ x s)) 3.0)))))
float code(float x, float s) {
float tmp;
if (x <= -1.9999999996399175e-23f) {
tmp = 1.0f / (s * (4.0f + ((x * x) / (s * s))));
} else {
tmp = (1.0f / s) * (1.0f / (expf((x / s)) + 3.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.9999999996399175e-23)) then
tmp = 1.0e0 / (s * (4.0e0 + ((x * x) / (s * s))))
else
tmp = (1.0e0 / s) * (1.0e0 / (exp((x / s)) + 3.0e0))
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(Float32(x * x) / Float32(s * s))))); else tmp = Float32(Float32(Float32(1.0) / s) * Float32(Float32(1.0) / Float32(exp(Float32(x / s)) + Float32(3.0)))); 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 * x) / (s * s)))); else tmp = (single(1.0) / s) * (single(1.0) / (exp((x / s)) + single(3.0))); 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 \cdot x}{s \cdot s}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{s} \cdot \frac{1}{e^{\frac{x}{s}} + 3}\\
\end{array}
\end{array}
if x < -2e-23Initial program 99.7%
Simplified99.8%
expm1-log1p-u98.9%
expm1-udef99.0%
associate-/l/99.0%
Applied egg-rr99.0%
expm1-def98.9%
expm1-log1p99.9%
*-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
+-commutative99.9%
associate-+l+99.9%
Simplified99.9%
Taylor expanded in s around inf 51.9%
associate-+r+51.9%
distribute-lft1-in51.9%
metadata-eval51.9%
mul0-lft83.4%
associate-+r+83.4%
metadata-eval83.4%
+-commutative83.4%
unpow283.4%
sqr-abs83.4%
unpow283.4%
times-frac77.5%
Simplified77.5%
frac-times83.4%
Applied egg-rr83.4%
if -2e-23 < x Initial program 99.6%
Simplified99.6%
Taylor expanded in s around inf 96.6%
Taylor expanded in s around 0 96.6%
+-commutative96.6%
Simplified96.6%
+-commutative96.6%
associate-/l/96.6%
div-inv96.6%
+-commutative96.6%
add-sqr-sqrt96.6%
add-sqr-sqrt96.6%
add-sqr-sqrt76.4%
fabs-sqr76.4%
add-sqr-sqrt91.6%
Applied egg-rr91.6%
Final simplification88.2%
(FPCore (x s) :precision binary32 (if (<= x -1.9999999996399175e-23) (/ 1.0 (* s (+ 4.0 (/ (* x x) (* s s))))) (/ (/ 1.0 (+ (exp (/ x s)) 3.0)) s)))
float code(float x, float s) {
float tmp;
if (x <= -1.9999999996399175e-23f) {
tmp = 1.0f / (s * (4.0f + ((x * x) / (s * s))));
} else {
tmp = (1.0f / (expf((x / s)) + 3.0f)) / 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 * x) / (s * s))))
else
tmp = (1.0e0 / (exp((x / s)) + 3.0e0)) / 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(Float32(x * x) / Float32(s * s))))); else tmp = Float32(Float32(Float32(1.0) / Float32(exp(Float32(x / s)) + Float32(3.0))) / 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 * x) / (s * s)))); else tmp = (single(1.0) / (exp((x / s)) + single(3.0))) / 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 \cdot x}{s \cdot s}\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{e^{\frac{x}{s}} + 3}}{s}\\
\end{array}
\end{array}
if x < -2e-23Initial program 99.7%
Simplified99.8%
expm1-log1p-u98.9%
expm1-udef99.0%
associate-/l/99.0%
Applied egg-rr99.0%
expm1-def98.9%
expm1-log1p99.9%
*-commutative99.9%
+-commutative99.9%
associate-+r+99.9%
+-commutative99.9%
associate-+l+99.9%
Simplified99.9%
Taylor expanded in s around inf 51.9%
associate-+r+51.9%
distribute-lft1-in51.9%
metadata-eval51.9%
mul0-lft83.4%
associate-+r+83.4%
metadata-eval83.4%
+-commutative83.4%
unpow283.4%
sqr-abs83.4%
unpow283.4%
times-frac77.5%
Simplified77.5%
frac-times83.4%
Applied egg-rr83.4%
if -2e-23 < x Initial program 99.6%
Simplified99.6%
Taylor expanded in s around inf 96.6%
expm1-log1p-u96.6%
+-commutative96.6%
Applied egg-rr96.6%
add-exp-log94.7%
associate-/l/94.7%
expm1-log1p-u94.7%
associate-+r+94.7%
metadata-eval94.7%
Applied egg-rr94.7%
add-exp-log96.6%
associate-/r*96.6%
+-commutative96.6%
add-sqr-sqrt96.6%
add-sqr-sqrt96.6%
add-sqr-sqrt76.4%
fabs-sqr76.4%
add-sqr-sqrt91.6%
Applied egg-rr91.6%
Final simplification88.2%
(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.6%
Simplified99.7%
expm1-log1p-u97.9%
expm1-udef97.9%
associate-/l/97.9%
Applied egg-rr97.9%
expm1-def97.9%
expm1-log1p99.7%
*-commutative99.7%
+-commutative99.7%
associate-+r+99.7%
+-commutative99.7%
associate-+l+99.7%
Simplified99.7%
Taylor expanded in s around inf 54.8%
associate-+r+54.8%
distribute-lft1-in54.8%
metadata-eval54.8%
mul0-lft75.8%
associate-+r+75.8%
metadata-eval75.8%
+-commutative75.8%
unpow275.8%
sqr-abs75.8%
unpow275.8%
times-frac73.5%
Simplified73.5%
Final simplification73.5%
(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.6%
Simplified99.7%
expm1-log1p-u97.9%
expm1-udef97.9%
associate-/l/97.9%
Applied egg-rr97.9%
expm1-def97.9%
expm1-log1p99.7%
*-commutative99.7%
+-commutative99.7%
associate-+r+99.7%
+-commutative99.7%
associate-+l+99.7%
Simplified99.7%
Taylor expanded in s around inf 54.8%
associate-+r+54.8%
distribute-lft1-in54.8%
metadata-eval54.8%
mul0-lft75.8%
associate-+r+75.8%
metadata-eval75.8%
+-commutative75.8%
unpow275.8%
sqr-abs75.8%
unpow275.8%
times-frac73.5%
Simplified73.5%
frac-times75.8%
Applied egg-rr75.8%
Final simplification75.8%
(FPCore (x s) :precision binary32 (if (or (<= x -0.0001500000071246177) (not (<= x 0.0009500000160187483))) (/ 1.0 (* x (/ x s))) (/ 0.25 s)))
float code(float x, float s) {
float tmp;
if ((x <= -0.0001500000071246177f) || !(x <= 0.0009500000160187483f)) {
tmp = 1.0f / (x * (x / s));
} else {
tmp = 0.25f / 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.0001500000071246177e0)) .or. (.not. (x <= 0.0009500000160187483e0))) then
tmp = 1.0e0 / (x * (x / s))
else
tmp = 0.25e0 / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if ((x <= Float32(-0.0001500000071246177)) || !(x <= Float32(0.0009500000160187483))) tmp = Float32(Float32(1.0) / Float32(x * Float32(x / s))); else tmp = Float32(Float32(0.25) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((x <= single(-0.0001500000071246177)) || ~((x <= single(0.0009500000160187483)))) tmp = single(1.0) / (x * (x / s)); else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0001500000071246177 \lor \neg \left(x \leq 0.0009500000160187483\right):\\
\;\;\;\;\frac{1}{x \cdot \frac{x}{s}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
\end{array}
if x < -1.50000007e-4 or 9.50000016e-4 < x Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
associate-/l/100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
Simplified100.0%
Taylor expanded in s around inf 45.1%
associate-+r+45.1%
distribute-lft1-in45.1%
metadata-eval45.1%
mul0-lft85.7%
associate-+r+85.7%
metadata-eval85.7%
+-commutative85.7%
unpow285.7%
sqr-abs85.7%
unpow285.7%
times-frac85.7%
Simplified85.7%
Taylor expanded in s around 0 68.3%
unpow268.3%
associate-*r/68.3%
Simplified68.3%
if -1.50000007e-4 < x < 9.50000016e-4Initial program 99.3%
Simplified99.4%
Taylor expanded in s around inf 54.0%
Final simplification61.4%
(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(x * Float32(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 + x \cdot \frac{x}{s}}
\end{array}
Initial program 99.6%
Simplified99.7%
expm1-log1p-u97.9%
expm1-udef97.9%
associate-/l/97.9%
Applied egg-rr97.9%
expm1-def97.9%
expm1-log1p99.7%
*-commutative99.7%
+-commutative99.7%
associate-+r+99.7%
+-commutative99.7%
associate-+l+99.7%
Simplified99.7%
Taylor expanded in s around inf 54.8%
associate-+r+54.8%
distribute-lft1-in54.8%
metadata-eval54.8%
mul0-lft75.8%
associate-+r+75.8%
metadata-eval75.8%
+-commutative75.8%
unpow275.8%
sqr-abs75.8%
unpow275.8%
times-frac73.5%
Simplified73.5%
Taylor expanded in s around 0 62.4%
unpow262.4%
associate-*r/62.7%
+-commutative62.7%
fma-def62.7%
*-commutative62.7%
Simplified62.7%
fma-udef62.7%
Applied egg-rr62.7%
Final simplification62.7%
(FPCore (x s) :precision binary32 (if (or (<= x -0.0001500000071246177) (not (<= x 0.0009500000160187483))) (/ s (* x x)) (/ 0.25 s)))
float code(float x, float s) {
float tmp;
if ((x <= -0.0001500000071246177f) || !(x <= 0.0009500000160187483f)) {
tmp = s / (x * x);
} else {
tmp = 0.25f / 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.0001500000071246177e0)) .or. (.not. (x <= 0.0009500000160187483e0))) then
tmp = s / (x * x)
else
tmp = 0.25e0 / s
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if ((x <= Float32(-0.0001500000071246177)) || !(x <= Float32(0.0009500000160187483))) tmp = Float32(s / Float32(x * x)); else tmp = Float32(Float32(0.25) / s); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if ((x <= single(-0.0001500000071246177)) || ~((x <= single(0.0009500000160187483)))) tmp = s / (x * x); else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -0.0001500000071246177 \lor \neg \left(x \leq 0.0009500000160187483\right):\\
\;\;\;\;\frac{s}{x \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
\end{array}
if x < -1.50000007e-4 or 9.50000016e-4 < x Initial program 100.0%
Simplified100.0%
expm1-log1p-u100.0%
expm1-udef100.0%
associate-/l/100.0%
Applied egg-rr100.0%
expm1-def100.0%
expm1-log1p100.0%
*-commutative100.0%
+-commutative100.0%
associate-+r+100.0%
+-commutative100.0%
associate-+l+100.0%
Simplified100.0%
Taylor expanded in s around inf 45.1%
associate-+r+45.1%
distribute-lft1-in45.1%
metadata-eval45.1%
mul0-lft85.7%
associate-+r+85.7%
metadata-eval85.7%
+-commutative85.7%
unpow285.7%
sqr-abs85.7%
unpow285.7%
times-frac85.7%
Simplified85.7%
Taylor expanded in s around 0 67.0%
unpow267.0%
Simplified67.0%
if -1.50000007e-4 < x < 9.50000016e-4Initial program 99.3%
Simplified99.4%
Taylor expanded in s around inf 54.0%
Final simplification60.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.6%
Simplified99.7%
Taylor expanded in s around inf 28.3%
Final simplification28.3%
herbie shell --seed 2023195
(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))))))