
(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 12 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(x_m / Float32(-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.8%
*-commutative99.8%
fabs-neg99.8%
+-commutative99.8%
fabs-neg99.8%
distribute-lft-in99.9%
*-rgt-identity99.9%
+-commutative99.9%
Simplified99.8%
Taylor expanded in x around 0 99.8%
associate-/r*99.8%
Simplified63.2%
Final simplification63.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(x_m / Float32(-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.8%
fabs-neg99.8%
distribute-frac-neg99.8%
distribute-frac-neg299.8%
fabs-neg99.8%
*-commutative99.8%
fabs-neg99.8%
+-commutative99.8%
fabs-neg99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
unpow299.8%
distribute-rgt-in99.9%
mul-1-neg99.9%
rec-exp99.8%
distribute-rgt-in99.8%
Simplified63.1%
Final simplification63.1%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (exp (- (* (log1p (exp (/ x_m (- s)))) -2.0) (/ x_m s))) s))
x_m = fabs(x);
float code(float x_m, float s) {
return expf(((log1pf(expf((x_m / -s))) * -2.0f) - (x_m / s))) / s;
}
x_m = abs(x) function code(x_m, s) return Float32(exp(Float32(Float32(log1p(exp(Float32(x_m / Float32(-s)))) * Float32(-2.0)) - Float32(x_m / s))) / s) end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{e^{\mathsf{log1p}\left(e^{\frac{x\_m}{-s}}\right) \cdot -2 - \frac{x\_m}{s}}}{s}
\end{array}
Initial program 99.8%
*-commutative99.8%
fabs-neg99.8%
+-commutative99.8%
fabs-neg99.8%
distribute-lft-in99.9%
*-rgt-identity99.9%
+-commutative99.9%
Simplified99.8%
Taylor expanded in x around 0 99.8%
associate-/r*99.8%
Simplified63.2%
Taylor expanded in x around inf 63.2%
Simplified86.9%
Taylor expanded in x around inf 86.8%
distribute-neg-in86.8%
unsub-neg86.8%
*-commutative86.8%
distribute-rgt-neg-in86.8%
log1p-define86.9%
neg-mul-186.9%
distribute-neg-frac86.9%
metadata-eval86.9%
Simplified86.9%
Final simplification86.9%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (/ (/ 1.0 (exp (/ x_m s))) (+ (exp (/ x_m (- s))) 1.0)) (+ s (/ s (+ 1.0 (/ x_m s))))))
x_m = fabs(x);
float code(float x_m, float s) {
return ((1.0f / expf((x_m / s))) / (expf((x_m / -s)) + 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
code = ((1.0e0 / exp((x_m / s))) / (exp((x_m / -s)) + 1.0e0)) / (s + (s / (1.0e0 + (x_m / s))))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(Float32(Float32(1.0) / exp(Float32(x_m / s))) / Float32(exp(Float32(x_m / Float32(-s))) + 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) tmp = ((single(1.0) / exp((x_m / s))) / (exp((x_m / -s)) + single(1.0))) / (s + (s / (single(1.0) + (x_m / s)))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\frac{\frac{1}{e^{\frac{x\_m}{s}}}}{e^{\frac{x\_m}{-s}} + 1}}{s + \frac{s}{1 + \frac{x\_m}{s}}}
\end{array}
Initial program 99.8%
*-commutative99.8%
fabs-neg99.8%
+-commutative99.8%
fabs-neg99.8%
distribute-lft-in99.9%
*-rgt-identity99.9%
+-commutative99.9%
Simplified99.8%
Taylor expanded in x around 0 99.8%
associate-/r*99.8%
Simplified63.2%
Taylor expanded in x around 0 60.6%
+-commutative60.6%
Simplified60.6%
distribute-frac-neg260.6%
rec-exp60.6%
Applied egg-rr60.6%
Final simplification60.6%
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(x_m / Float32(-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.8%
*-commutative99.8%
fabs-neg99.8%
+-commutative99.8%
fabs-neg99.8%
distribute-lft-in99.9%
*-rgt-identity99.9%
+-commutative99.9%
Simplified99.8%
Taylor expanded in x around 0 99.8%
associate-/r*99.8%
Simplified63.2%
Taylor expanded in x around 0 60.6%
+-commutative60.6%
Simplified60.6%
Final simplification60.6%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (/ 1.0 (+ 1.0 (exp (/ x_m s)))) (+ s (/ s (+ 1.0 (/ x_m s))))))
x_m = fabs(x);
float code(float x_m, float s) {
return (1.0f / (1.0f + expf((x_m / s)))) / (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
code = (1.0e0 / (1.0e0 + exp((x_m / s)))) / (s + (s / (1.0e0 + (x_m / s))))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(Float32(1.0) / Float32(Float32(1.0) + exp(Float32(x_m / s)))) / Float32(s + Float32(s / Float32(Float32(1.0) + Float32(x_m / s))))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = (single(1.0) / (single(1.0) + exp((x_m / s)))) / (s + (s / (single(1.0) + (x_m / s)))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\frac{1}{1 + e^{\frac{x\_m}{s}}}}{s + \frac{s}{1 + \frac{x\_m}{s}}}
\end{array}
Initial program 99.8%
*-commutative99.8%
fabs-neg99.8%
+-commutative99.8%
fabs-neg99.8%
distribute-lft-in99.9%
*-rgt-identity99.9%
+-commutative99.9%
Simplified99.8%
Taylor expanded in x around 0 99.8%
associate-/r*99.8%
Simplified63.2%
Taylor expanded in x around 0 60.6%
+-commutative60.6%
Simplified60.6%
distribute-frac-neg260.6%
rec-exp60.6%
Applied egg-rr60.6%
Taylor expanded in x around inf 60.6%
+-commutative60.6%
mul-1-neg60.6%
distribute-frac-neg260.6%
distribute-lft-in22.3%
distribute-frac-neg222.3%
rec-exp22.3%
rgt-mult-inverse62.2%
*-rgt-identity62.2%
Simplified62.2%
Final simplification62.2%
x_m = (fabs.f32 x)
(FPCore (x_m s)
:precision binary32
(if (<= x_m 1.5000000601271012e-26)
(/
(- 0.5 (/ (* x_m 0.25) s))
(+ s (+ s (* x_m (+ (* (/ x_m s) 0.5) -1.0)))))
(/ (exp (/ x_m (- s))) s)))x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 1.5000000601271012e-26f) {
tmp = (0.5f - ((x_m * 0.25f) / s)) / (s + (s + (x_m * (((x_m / s) * 0.5f) + -1.0f))));
} else {
tmp = expf((x_m / -s)) / 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 <= 1.5000000601271012e-26) then
tmp = (0.5e0 - ((x_m * 0.25e0) / s)) / (s + (s + (x_m * (((x_m / s) * 0.5e0) + (-1.0e0)))))
else
tmp = exp((x_m / -s)) / s
end if
code = tmp
end function
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (x_m <= Float32(1.5000000601271012e-26)) 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)))))); else tmp = Float32(exp(Float32(x_m / Float32(-s))) / s); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, s) tmp = single(0.0); if (x_m <= single(1.5000000601271012e-26)) tmp = (single(0.5) - ((x_m * single(0.25)) / s)) / (s + (s + (x_m * (((x_m / s) * single(0.5)) + single(-1.0))))); else tmp = exp((x_m / -s)) / s; end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 1.5000000601271012 \cdot 10^{-26}:\\
\;\;\;\;\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)}\\
\mathbf{else}:\\
\;\;\;\;\frac{e^{\frac{x\_m}{-s}}}{s}\\
\end{array}
\end{array}
if x < 1.50000006e-26Initial program 99.7%
*-commutative99.7%
fabs-neg99.7%
+-commutative99.7%
fabs-neg99.7%
distribute-lft-in99.8%
*-rgt-identity99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
associate-/r*99.8%
Simplified37.2%
Taylor expanded in s around -inf 74.3%
mul-1-neg74.3%
distribute-rgt-out--74.3%
metadata-eval74.3%
*-commutative74.3%
associate-*r/74.3%
unsub-neg74.3%
associate-*r/74.3%
*-commutative74.3%
Simplified74.3%
Taylor expanded in x around 0 48.9%
if 1.50000006e-26 < x Initial program 100.0%
*-commutative100.0%
fabs-neg100.0%
+-commutative100.0%
fabs-neg100.0%
distribute-lft-in99.9%
*-rgt-identity99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in x around 0 99.9%
associate-/r*99.9%
Simplified99.9%
Taylor expanded in x around inf 99.9%
Simplified99.9%
Taylor expanded in x around inf 93.0%
neg-mul-193.0%
distribute-neg-frac93.0%
Simplified93.0%
Final simplification67.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(exp(Float32(x_m / Float32(-s))) / Float32(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{e^{\frac{x\_m}{-s}}}{s \cdot 4}
\end{array}
Initial program 99.8%
fabs-neg99.8%
distribute-frac-neg99.8%
distribute-frac-neg299.8%
fabs-neg99.8%
*-commutative99.8%
fabs-neg99.8%
+-commutative99.8%
fabs-neg99.8%
Simplified99.8%
Taylor expanded in x around 0 99.8%
unpow299.8%
distribute-rgt-in99.9%
mul-1-neg99.9%
rec-exp99.8%
distribute-rgt-in99.8%
Simplified63.1%
Taylor expanded in x around 0 59.9%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (- 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) {
return (0.5f - ((x_m * 0.25f) / s)) / (s + (s + (x_m * (((x_m / s) * 0.5f) + -1.0f))));
}
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 - ((x_m * 0.25e0) / s)) / (s + (s + (x_m * (((x_m / s) * 0.5e0) + (-1.0e0)))))
end function
x_m = abs(x) function code(x_m, s) return 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
x_m = abs(x); function tmp = code(x_m, s) tmp = (single(0.5) - ((x_m * single(0.25)) / s)) / (s + (s + (x_m * (((x_m / s) * single(0.5)) + single(-1.0))))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\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}
Initial program 99.8%
*-commutative99.8%
fabs-neg99.8%
+-commutative99.8%
fabs-neg99.8%
distribute-lft-in99.9%
*-rgt-identity99.9%
+-commutative99.9%
Simplified99.8%
Taylor expanded in x around 0 99.8%
associate-/r*99.8%
Simplified63.2%
Taylor expanded in s around -inf 48.3%
mul-1-neg48.3%
distribute-rgt-out--48.3%
metadata-eval48.3%
*-commutative48.3%
associate-*r/48.3%
unsub-neg48.3%
associate-*r/48.3%
*-commutative48.3%
Simplified48.3%
Taylor expanded in x around 0 39.9%
Final simplification39.9%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (- 0.5 (/ (* x_m 0.25) s)) (+ (* s 2.0) (* x_m (+ (/ x_m s) -1.0)))))
x_m = fabs(x);
float code(float x_m, float s) {
return (0.5f - ((x_m * 0.25f) / s)) / ((s * 2.0f) + (x_m * ((x_m / s) + -1.0f)));
}
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 - ((x_m * 0.25e0) / s)) / ((s * 2.0e0) + (x_m * ((x_m / s) + (-1.0e0))))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(Float32(0.5) - Float32(Float32(x_m * Float32(0.25)) / s)) / Float32(Float32(s * Float32(2.0)) + Float32(x_m * Float32(Float32(x_m / s) + Float32(-1.0))))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = (single(0.5) - ((x_m * single(0.25)) / s)) / ((s * single(2.0)) + (x_m * ((x_m / s) + single(-1.0)))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{0.5 - \frac{x\_m \cdot 0.25}{s}}{s \cdot 2 + x\_m \cdot \left(\frac{x\_m}{s} + -1\right)}
\end{array}
Initial program 99.8%
*-commutative99.8%
fabs-neg99.8%
+-commutative99.8%
fabs-neg99.8%
distribute-lft-in99.9%
*-rgt-identity99.9%
+-commutative99.9%
Simplified99.8%
Taylor expanded in x around 0 99.8%
associate-/r*99.8%
Simplified63.2%
Taylor expanded in s around -inf 48.3%
mul-1-neg48.3%
distribute-rgt-out--48.3%
metadata-eval48.3%
*-commutative48.3%
associate-*r/48.3%
unsub-neg48.3%
associate-*r/48.3%
*-commutative48.3%
Simplified48.3%
Taylor expanded in x around 0 24.9%
+-commutative60.6%
Simplified24.9%
Taylor expanded in x around 0 39.8%
Final simplification39.8%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 0.5 (+ s (- s x_m))))
x_m = fabs(x);
float code(float x_m, float s) {
return 0.5f / (s + (s - 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.5e0 / (s + (s - x_m))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(0.5) / Float32(s + Float32(s - x_m))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(0.5) / (s + (s - x_m)); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{0.5}{s + \left(s - x\_m\right)}
\end{array}
Initial program 99.8%
*-commutative99.8%
fabs-neg99.8%
+-commutative99.8%
fabs-neg99.8%
distribute-lft-in99.9%
*-rgt-identity99.9%
+-commutative99.9%
Simplified99.8%
Taylor expanded in x around 0 99.8%
associate-/r*99.8%
Simplified63.2%
Taylor expanded in s around -inf 48.3%
mul-1-neg48.3%
distribute-rgt-out--48.3%
metadata-eval48.3%
*-commutative48.3%
associate-*r/48.3%
unsub-neg48.3%
associate-*r/48.3%
*-commutative48.3%
Simplified48.3%
Taylor expanded in x around 0 25.5%
neg-mul-125.5%
unsub-neg25.5%
Simplified25.5%
Taylor expanded in x around 0 27.7%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ 0.25 s))
x_m = fabs(x);
float code(float x_m, float s) {
return 0.25f / 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.25e0 / s
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(0.25) / s) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(0.25) / s; end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{0.25}{s}
\end{array}
Initial program 99.8%
fabs-neg99.8%
distribute-frac-neg99.8%
distribute-frac-neg299.8%
fabs-neg99.8%
*-commutative99.8%
fabs-neg99.8%
+-commutative99.8%
fabs-neg99.8%
Simplified99.8%
Taylor expanded in s around inf 25.7%
herbie shell --seed 2024139
(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))))))