
(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.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
distribute-lft-in99.4%
*-rgt-identity99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.4%
Simplified63.4%
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(Float32(t_0 / 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{\frac{t\_0}{s}}{{\left(t\_0 + 1\right)}^{2}}
\end{array}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-/r*99.3%
exp-prod99.3%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt62.1%
exp-prod62.1%
neg-mul-162.1%
distribute-neg-frac262.1%
+-commutative62.1%
exp-prod62.1%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt63.2%
exp-prod63.3%
neg-mul-163.3%
distribute-neg-frac263.3%
Simplified63.3%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (pow (+ (exp (/ x_m (- s))) 1.0) -2.0) (* s (exp (/ x_m s)))))
x_m = fabs(x);
float code(float x_m, float s) {
return powf((expf((x_m / -s)) + 1.0f), -2.0f) / (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
code = ((exp((x_m / -s)) + 1.0e0) ** (-2.0e0)) / (s * exp((x_m / s)))
end function
x_m = abs(x) function code(x_m, s) return Float32((Float32(exp(Float32(x_m / Float32(-s))) + Float32(1.0)) ^ Float32(-2.0)) / Float32(s * exp(Float32(x_m / s)))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = ((exp((x_m / -s)) + single(1.0)) ^ single(-2.0)) / (s * exp((x_m / s))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{{\left(e^{\frac{x\_m}{-s}} + 1\right)}^{-2}}{s \cdot e^{\frac{x\_m}{s}}}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-/r*99.3%
exp-prod99.3%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt62.1%
exp-prod62.1%
neg-mul-162.1%
distribute-neg-frac262.1%
+-commutative62.1%
exp-prod62.1%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt63.2%
exp-prod63.3%
neg-mul-163.3%
distribute-neg-frac263.3%
Simplified63.3%
clear-num63.3%
inv-pow63.3%
add-exp-log61.4%
div-exp61.7%
add-sqr-sqrt-0.0%
sqrt-unprod52.9%
sqr-neg52.9%
sqrt-unprod55.6%
add-sqr-sqrt55.6%
add-log-exp55.6%
log-div55.5%
add-exp-log56.7%
div-inv56.7%
rec-exp56.8%
distribute-frac-neg256.8%
add-sqr-sqrt-0.0%
sqrt-unprod57.9%
sqr-neg57.9%
sqrt-unprod63.2%
add-sqr-sqrt63.3%
Applied egg-rr63.3%
unpow-163.3%
Simplified63.3%
*-commutative63.3%
add-exp-log61.4%
prod-exp61.7%
Applied egg-rr61.7%
*-un-lft-identity61.7%
div-inv61.7%
+-commutative61.7%
exp-sum61.4%
add-exp-log63.3%
pow-flip63.3%
+-commutative63.3%
distribute-frac-neg263.3%
div-inv63.3%
distribute-lft-neg-out63.3%
un-div-inv63.3%
metadata-eval63.3%
Applied egg-rr63.3%
*-lft-identity63.3%
associate-*l/63.3%
*-lft-identity63.3%
distribute-frac-neg63.3%
distribute-frac-neg263.3%
Simplified63.3%
Final simplification63.3%
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.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
distribute-lft-in99.4%
*-rgt-identity99.4%
+-commutative99.4%
Simplified99.4%
Taylor expanded in x around 0 99.4%
associate-/r*99.4%
Simplified63.4%
Taylor expanded in x around 0 60.3%
+-commutative60.3%
Simplified60.3%
Final simplification60.3%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (/ (exp (/ x_m (- s))) s) (pow (+ 1.0 (- 1.0 (/ x_m s))) 2.0)))
x_m = fabs(x);
float code(float x_m, float s) {
return (expf((x_m / -s)) / s) / powf((1.0f + (1.0f - (x_m / s))), 2.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) / ((1.0e0 + (1.0e0 - (x_m / s))) ** 2.0e0)
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(exp(Float32(x_m / Float32(-s))) / s) / (Float32(Float32(1.0) + Float32(Float32(1.0) - Float32(x_m / s))) ^ Float32(2.0))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = (exp((x_m / -s)) / s) / ((single(1.0) + (single(1.0) - (x_m / s))) ^ single(2.0)); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\frac{e^{\frac{x\_m}{-s}}}{s}}{{\left(1 + \left(1 - \frac{x\_m}{s}\right)\right)}^{2}}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-/r*99.3%
exp-prod99.3%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt62.1%
exp-prod62.1%
neg-mul-162.1%
distribute-neg-frac262.1%
+-commutative62.1%
exp-prod62.1%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt63.2%
exp-prod63.3%
neg-mul-163.3%
distribute-neg-frac263.3%
Simplified63.3%
Taylor expanded in x around 0 60.2%
neg-mul-160.2%
unsub-neg60.2%
Simplified60.2%
Final simplification60.2%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (/ (exp (/ x_m (- s))) s) (+ 4.0 (* (/ x_m s) -4.0))))
x_m = fabs(x);
float code(float x_m, float s) {
return (expf((x_m / -s)) / s) / (4.0f + ((x_m / 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 + ((x_m / s) * (-4.0e0)))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(exp(Float32(x_m / Float32(-s))) / s) / Float32(Float32(4.0) + Float32(Float32(x_m / s) * Float32(-4.0)))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = (exp((x_m / -s)) / s) / (single(4.0) + ((x_m / s) * single(-4.0))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\frac{e^{\frac{x\_m}{-s}}}{s}}{4 + \frac{x\_m}{s} \cdot -4}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-/r*99.3%
exp-prod99.3%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt62.1%
exp-prod62.1%
neg-mul-162.1%
distribute-neg-frac262.1%
+-commutative62.1%
exp-prod62.1%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt63.2%
exp-prod63.3%
neg-mul-163.3%
distribute-neg-frac263.3%
Simplified63.3%
Taylor expanded in x around 0 60.3%
*-commutative60.3%
Simplified60.3%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (/ 0.5 s) (+ 1.0 (exp (/ x_m s)))))
x_m = fabs(x);
float code(float x_m, float s) {
return (0.5f / s) / (1.0f + 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
code = (0.5e0 / s) / (1.0e0 + exp((x_m / s)))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(Float32(0.5) / s) / Float32(Float32(1.0) + exp(Float32(x_m / s)))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = (single(0.5) / s) / (single(1.0) + exp((x_m / s))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\frac{0.5}{s}}{1 + e^{\frac{x\_m}{s}}}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Applied egg-rr61.0%
*-lft-identity61.0%
rem-exp-log59.1%
exp-to-pow59.0%
log1p-undefine59.0%
*-commutative59.0%
exp-sum58.7%
+-commutative58.7%
exp-diff85.0%
associate--r+84.9%
exp-diff85.2%
Simplified87.2%
Applied egg-rr60.7%
associate-*l/60.7%
*-lft-identity60.7%
+-commutative60.7%
+-commutative60.7%
Simplified60.7%
Taylor expanded in x around 0 60.3%
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(Float32(exp(Float32(x_m / Float32(-s))) / 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{\frac{e^{\frac{x\_m}{-s}}}{s}}{4}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-/r*99.3%
exp-prod99.3%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt62.1%
exp-prod62.1%
neg-mul-162.1%
distribute-neg-frac262.1%
+-commutative62.1%
exp-prod62.1%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt63.2%
exp-prod63.3%
neg-mul-163.3%
distribute-neg-frac263.3%
Simplified63.3%
Taylor expanded in x around 0 60.3%
*-commutative60.3%
Simplified60.3%
Taylor expanded in x around 0 59.5%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (/ 1.0 s) (+ 4.0 (/ (* x_m 4.0) s))))
x_m = fabs(x);
float code(float x_m, float s) {
return (1.0f / s) / (4.0f + ((x_m * 4.0f) / 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 / s) / (4.0e0 + ((x_m * 4.0e0) / s))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(Float32(x_m * Float32(4.0)) / s))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = (single(1.0) / s) / (single(4.0) + ((x_m * single(4.0)) / s)); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\frac{1}{s}}{4 + \frac{x\_m \cdot 4}{s}}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-/r*99.3%
exp-prod99.3%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt62.1%
exp-prod62.1%
neg-mul-162.1%
distribute-neg-frac262.1%
+-commutative62.1%
exp-prod62.1%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt63.2%
exp-prod63.3%
neg-mul-163.3%
distribute-neg-frac263.3%
Simplified63.3%
Taylor expanded in x around 0 60.3%
*-commutative60.3%
Simplified60.3%
Taylor expanded in x around 0 46.8%
associate-*l/46.8%
frac-2neg46.8%
add-sqr-sqrt-0.0%
sqrt-unprod63.8%
sqr-neg63.8%
sqrt-unprod46.9%
add-sqr-sqrt46.9%
Applied egg-rr46.9%
distribute-rgt-neg-in46.9%
metadata-eval46.9%
Simplified46.9%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ (/ 1.0 s) (+ 4.0 (* x_m (/ -4.0 s)))))
x_m = fabs(x);
float code(float x_m, float s) {
return (1.0f / s) / (4.0f + (x_m * (-4.0f / 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 / s) / (4.0e0 + (x_m * ((-4.0e0) / s)))
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(Float32(1.0) / s) / Float32(Float32(4.0) + Float32(x_m * Float32(Float32(-4.0) / s)))) end
x_m = abs(x); function tmp = code(x_m, s) tmp = (single(1.0) / s) / (single(4.0) + (x_m * (single(-4.0) / s))); end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{\frac{1}{s}}{4 + x\_m \cdot \frac{-4}{s}}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-/r*99.3%
exp-prod99.3%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt62.1%
exp-prod62.1%
neg-mul-162.1%
distribute-neg-frac262.1%
+-commutative62.1%
exp-prod62.1%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt63.2%
exp-prod63.3%
neg-mul-163.3%
distribute-neg-frac263.3%
Simplified63.3%
Taylor expanded in x around 0 60.3%
*-commutative60.3%
Simplified60.3%
Taylor expanded in x around 0 46.8%
Taylor expanded in x around 0 46.8%
*-commutative46.8%
associate-*l/46.8%
associate-/l*47.2%
Simplified47.2%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (if (<= x_m 0.009999999776482582) (/ 0.25 s) (/ -0.25 x_m)))
x_m = fabs(x);
float code(float x_m, float s) {
float tmp;
if (x_m <= 0.009999999776482582f) {
tmp = 0.25f / s;
} else {
tmp = -0.25f / x_m;
}
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 <= 0.009999999776482582e0) then
tmp = 0.25e0 / s
else
tmp = (-0.25e0) / x_m
end if
code = tmp
end function
x_m = abs(x) function code(x_m, s) tmp = Float32(0.0) if (x_m <= Float32(0.009999999776482582)) tmp = Float32(Float32(0.25) / s); else tmp = Float32(Float32(-0.25) / x_m); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, s) tmp = single(0.0); if (x_m <= single(0.009999999776482582)) tmp = single(0.25) / s; else tmp = single(-0.25) / x_m; end tmp_2 = tmp; end
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;x\_m \leq 0.009999999776482582:\\
\;\;\;\;\frac{0.25}{s}\\
\mathbf{else}:\\
\;\;\;\;\frac{-0.25}{x\_m}\\
\end{array}
\end{array}
if x < 0.00999999978Initial program 99.0%
fabs-neg99.0%
distribute-frac-neg99.0%
distribute-frac-neg299.0%
fabs-neg99.0%
*-commutative99.0%
fabs-neg99.0%
+-commutative99.0%
fabs-neg99.0%
Simplified99.1%
Taylor expanded in s around inf 33.5%
if 0.00999999978 < x Initial program 100.0%
fabs-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
fabs-neg100.0%
*-commutative100.0%
fabs-neg100.0%
+-commutative100.0%
fabs-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
associate-/r*100.0%
exp-prod100.0%
rem-square-sqrt100.0%
fabs-sqr100.0%
rem-square-sqrt100.0%
exp-prod100.0%
neg-mul-1100.0%
distribute-neg-frac2100.0%
+-commutative100.0%
exp-prod100.0%
rem-square-sqrt100.0%
fabs-sqr100.0%
rem-square-sqrt100.0%
exp-prod100.0%
neg-mul-1100.0%
distribute-neg-frac2100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 49.5%
Taylor expanded in s around 0 12.0%
x_m = (fabs.f32 x) (FPCore (x_m s) :precision binary32 (/ -0.25 x_m))
x_m = fabs(x);
float code(float x_m, float s) {
return -0.25f / 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.25e0) / x_m
end function
x_m = abs(x) function code(x_m, s) return Float32(Float32(-0.25) / x_m) end
x_m = abs(x); function tmp = code(x_m, s) tmp = single(-0.25) / x_m; end
\begin{array}{l}
x_m = \left|x\right|
\\
\frac{-0.25}{x\_m}
\end{array}
Initial program 99.3%
fabs-neg99.3%
distribute-frac-neg99.3%
distribute-frac-neg299.3%
fabs-neg99.3%
*-commutative99.3%
fabs-neg99.3%
+-commutative99.3%
fabs-neg99.3%
Simplified99.3%
Taylor expanded in x around 0 99.3%
associate-/r*99.3%
exp-prod99.3%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt62.1%
exp-prod62.1%
neg-mul-162.1%
distribute-neg-frac262.1%
+-commutative62.1%
exp-prod62.1%
rem-square-sqrt51.0%
fabs-sqr51.0%
rem-square-sqrt63.2%
exp-prod63.3%
neg-mul-163.3%
distribute-neg-frac263.3%
Simplified63.3%
Taylor expanded in x around 0 60.3%
*-commutative60.3%
Simplified60.3%
Taylor expanded in x around 0 46.8%
Taylor expanded in s around 0 9.0%
herbie shell --seed 2024146
(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))))))