
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (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)
use fmin_fmax_functions
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}
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}
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (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)
use fmin_fmax_functions
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}
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}
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (/ 1.0 (* (+ 1.0 (exp (/ (- (fabs x)) s))) (fma (exp (/ (fabs x) s)) s s))))
float code(float x, float s) {
return 1.0f / ((1.0f + expf((-fabsf(x) / s))) * fmaf(expf((fabsf(x) / s)), s, s));
}
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(Float32(1.0) + exp(Float32(Float32(-abs(x)) / s))) * fma(exp(Float32(abs(x) / s)), s, s))) end
\frac{1}{\left(1 + e^{\frac{-\left|x\right|}{s}}\right) \cdot \mathsf{fma}\left(e^{\frac{\left|x\right|}{s}}, s, s\right)}
Initial program 99.6%
Applied rewrites99.6%
Applied rewrites99.6%
Applied rewrites99.6%
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (let* ((t_0 (/ (fabs x) s))) (/ -1.0 (* (* (- t_0 2.0) s) (- (exp t_0) -1.0)))))
float code(float x, float s) {
float t_0 = fabsf(x) / s;
return -1.0f / (((t_0 - 2.0f) * s) * (expf(t_0) - -1.0f));
}
real(4) function code(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
t_0 = abs(x) / s
code = (-1.0e0) / (((t_0 - 2.0e0) * s) * (exp(t_0) - (-1.0e0)))
end function
function code(x, s) t_0 = Float32(abs(x) / s) return Float32(Float32(-1.0) / Float32(Float32(Float32(t_0 - Float32(2.0)) * s) * Float32(exp(t_0) - Float32(-1.0)))) end
function tmp = code(x, s) t_0 = abs(x) / s; tmp = single(-1.0) / (((t_0 - single(2.0)) * s) * (exp(t_0) - single(-1.0))); end
\begin{array}{l}
t_0 := \frac{\left|x\right|}{s}\\
\frac{-1}{\left(\left(t\_0 - 2\right) \cdot s\right) \cdot \left(e^{t\_0} - -1\right)}
\end{array}
Initial program 99.6%
Applied rewrites99.6%
Applied rewrites99.6%
Taylor expanded in s around inf
Applied rewrites96.0%
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (/ (exp (/ (- (fabs x)) s)) (* s (+ 4.0 (* -4.0 (/ (fabs x) s))))))
float code(float x, float s) {
return expf((-fabsf(x) / s)) / (s * (4.0f + (-4.0f * (fabsf(x) / s))));
}
real(4) function code(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
code = exp((-abs(x) / s)) / (s * (4.0e0 + ((-4.0e0) * (abs(x) / s))))
end function
function code(x, s) return Float32(exp(Float32(Float32(-abs(x)) / s)) / Float32(s * Float32(Float32(4.0) + Float32(Float32(-4.0) * Float32(abs(x) / s))))) end
function tmp = code(x, s) tmp = exp((-abs(x) / s)) / (s * (single(4.0) + (single(-4.0) * (abs(x) / s)))); end
\frac{e^{\frac{-\left|x\right|}{s}}}{s \cdot \left(4 + -4 \cdot \frac{\left|x\right|}{s}\right)}
Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites95.7%
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (/ (exp (/ (- (fabs x)) s)) (fma -4.0 (fabs x) (* 4.0 s))))
float code(float x, float s) {
return expf((-fabsf(x) / s)) / fmaf(-4.0f, fabsf(x), (4.0f * s));
}
function code(x, s) return Float32(exp(Float32(Float32(-abs(x)) / s)) / fma(Float32(-4.0), abs(x), Float32(Float32(4.0) * s))) end
\frac{e^{\frac{-\left|x\right|}{s}}}{\mathsf{fma}\left(-4, \left|x\right|, 4 \cdot s\right)}
Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites95.7%
Taylor expanded in s around 0
Applied rewrites95.6%
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (/ 1.0 (* 2.0 (fma (exp (/ (fabs x) s)) s s))))
float code(float x, float s) {
return 1.0f / (2.0f * fmaf(expf((fabsf(x) / s)), s, s));
}
function code(x, s) return Float32(Float32(1.0) / Float32(Float32(2.0) * fma(exp(Float32(abs(x) / s)), s, s))) end
\frac{1}{2 \cdot \mathsf{fma}\left(e^{\frac{\left|x\right|}{s}}, s, s\right)}
Initial program 99.6%
Applied rewrites99.6%
Applied rewrites99.6%
Applied rewrites99.6%
Taylor expanded in s around inf
Applied rewrites95.1%
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (/ (/ 0.25 s) (exp (/ (fabs x) s))))
float code(float x, float s) {
return (0.25f / s) / expf((fabsf(x) / s));
}
real(4) function code(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (0.25e0 / s) / exp((abs(x) / s))
end function
function code(x, s) return Float32(Float32(Float32(0.25) / s) / exp(Float32(abs(x) / s))) end
function tmp = code(x, s) tmp = (single(0.25) / s) / exp((abs(x) / s)); end
\frac{\frac{0.25}{s}}{e^{\frac{\left|x\right|}{s}}}
Initial program 99.6%
Applied rewrites99.3%
Taylor expanded in s around inf
Applied rewrites94.6%
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (/ 0.25 (* (exp (/ (fabs x) s)) s)))
float code(float x, float s) {
return 0.25f / (expf((fabsf(x) / s)) * s);
}
real(4) function code(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 0.25e0 / (exp((abs(x) / s)) * s)
end function
function code(x, s) return Float32(Float32(0.25) / Float32(exp(Float32(abs(x) / s)) * s)) end
function tmp = code(x, s) tmp = single(0.25) / (exp((abs(x) / s)) * s); end
\frac{0.25}{e^{\frac{\left|x\right|}{s}} \cdot s}
Initial program 99.6%
Applied rewrites99.3%
Taylor expanded in s around inf
Applied rewrites94.6%
Applied rewrites94.7%
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (/ 1.0 (* s (+ 4.0 (* -4.0 (/ (sqrt (* x x)) s))))))
float code(float x, float s) {
return 1.0f / (s * (4.0f + (-4.0f * (sqrtf((x * x)) / s))));
}
real(4) function code(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
code = 1.0e0 / (s * (4.0e0 + ((-4.0e0) * (sqrt((x * x)) / s))))
end function
function code(x, s) return Float32(Float32(1.0) / Float32(s * Float32(Float32(4.0) + Float32(Float32(-4.0) * Float32(sqrt(Float32(x * x)) / s))))) end
function tmp = code(x, s) tmp = single(1.0) / (s * (single(4.0) + (single(-4.0) * (sqrt((x * x)) / s)))); end
\frac{1}{s \cdot \left(4 + -4 \cdot \frac{\sqrt{x \cdot x}}{s}\right)}
Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites95.7%
Taylor expanded in s around inf
Applied rewrites50.9%
Applied rewrites57.0%
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (if (<= (fabs x) 7999999874453996000.0) (/ 1.0 (* s (fma (fabs x) (/ -4.0 s) 4.0))) (/ 1.0 (* (* 4.0 (* x x)) (/ 1.0 (fabs x))))))
float code(float x, float s) {
float tmp;
if (fabsf(x) <= 7999999874453996000.0f) {
tmp = 1.0f / (s * fmaf(fabsf(x), (-4.0f / s), 4.0f));
} else {
tmp = 1.0f / ((4.0f * (x * x)) * (1.0f / fabsf(x)));
}
return tmp;
}
function code(x, s) tmp = Float32(0.0) if (abs(x) <= Float32(7999999874453996000.0)) tmp = Float32(Float32(1.0) / Float32(s * fma(abs(x), Float32(Float32(-4.0) / s), Float32(4.0)))); else tmp = Float32(Float32(1.0) / Float32(Float32(Float32(4.0) * Float32(x * x)) * Float32(Float32(1.0) / abs(x)))); end return tmp end
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 7999999874453996000:\\
\;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\left|x\right|, \frac{-4}{s}, 4\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\left(4 \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{\left|x\right|}}\\
\end{array}
if (fabs.f32 x) < 7.99999987e18Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites95.7%
Taylor expanded in s around inf
Applied rewrites50.9%
Applied rewrites51.3%
if 7.99999987e18 < (fabs.f32 x) Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites95.7%
Taylor expanded in s around inf
Applied rewrites50.9%
Taylor expanded in x around -inf
Applied rewrites31.0%
Applied rewrites31.2%
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (if (<= (fabs x) 7999999874453996000.0) (/ 1.0 (* s (fma (fabs x) (/ -4.0 s) 4.0))) (/ 1.0 (/ (* 4.0 (* x x)) (fabs x)))))
float code(float x, float s) {
float tmp;
if (fabsf(x) <= 7999999874453996000.0f) {
tmp = 1.0f / (s * fmaf(fabsf(x), (-4.0f / s), 4.0f));
} else {
tmp = 1.0f / ((4.0f * (x * x)) / fabsf(x));
}
return tmp;
}
function code(x, s) tmp = Float32(0.0) if (abs(x) <= Float32(7999999874453996000.0)) tmp = Float32(Float32(1.0) / Float32(s * fma(abs(x), Float32(Float32(-4.0) / s), Float32(4.0)))); else tmp = Float32(Float32(1.0) / Float32(Float32(Float32(4.0) * Float32(x * x)) / abs(x))); end return tmp end
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 7999999874453996000:\\
\;\;\;\;\frac{1}{s \cdot \mathsf{fma}\left(\left|x\right|, \frac{-4}{s}, 4\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{4 \cdot \left(x \cdot x\right)}{\left|x\right|}}\\
\end{array}
if (fabs.f32 x) < 7.99999987e18Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites95.7%
Taylor expanded in s around inf
Applied rewrites50.9%
Applied rewrites51.3%
if 7.99999987e18 < (fabs.f32 x) Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites95.7%
Taylor expanded in s around inf
Applied rewrites50.9%
Taylor expanded in x around -inf
Applied rewrites31.0%
Applied rewrites31.3%
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (/ (/ 0.25 s) (+ 1.0 (/ (sqrt (* x x)) s))))
float code(float x, float s) {
return (0.25f / s) / (1.0f + (sqrtf((x * x)) / s));
}
real(4) function code(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
code = (0.25e0 / s) / (1.0e0 + (sqrt((x * x)) / s))
end function
function code(x, s) return Float32(Float32(Float32(0.25) / s) / Float32(Float32(1.0) + Float32(sqrt(Float32(x * x)) / s))) end
function tmp = code(x, s) tmp = (single(0.25) / s) / (single(1.0) + (sqrt((x * x)) / s)); end
\frac{\frac{0.25}{s}}{1 + \frac{\sqrt{x \cdot x}}{s}}
Initial program 99.6%
Applied rewrites99.3%
Taylor expanded in s around inf
Applied rewrites94.6%
Taylor expanded in s around inf
Applied rewrites50.7%
Applied rewrites57.0%
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (if (<= (fabs x) 9999999980506448000.0) (/ (/ 0.25 s) (+ 1.0 (/ (fabs x) s))) (/ 1.0 (/ (* 4.0 (* x x)) (fabs x)))))
float code(float x, float s) {
float tmp;
if (fabsf(x) <= 9999999980506448000.0f) {
tmp = (0.25f / s) / (1.0f + (fabsf(x) / s));
} else {
tmp = 1.0f / ((4.0f * (x * x)) / fabsf(x));
}
return tmp;
}
real(4) function code(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (abs(x) <= 9999999980506448000.0e0) then
tmp = (0.25e0 / s) / (1.0e0 + (abs(x) / s))
else
tmp = 1.0e0 / ((4.0e0 * (x * x)) / abs(x))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (abs(x) <= Float32(9999999980506448000.0)) tmp = Float32(Float32(Float32(0.25) / s) / Float32(Float32(1.0) + Float32(abs(x) / s))); else tmp = Float32(Float32(1.0) / Float32(Float32(Float32(4.0) * Float32(x * x)) / abs(x))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (abs(x) <= single(9999999980506448000.0)) tmp = (single(0.25) / s) / (single(1.0) + (abs(x) / s)); else tmp = single(1.0) / ((single(4.0) * (x * x)) / abs(x)); end tmp_2 = tmp; end
\begin{array}{l}
\mathbf{if}\;\left|x\right| \leq 9999999980506448000:\\
\;\;\;\;\frac{\frac{0.25}{s}}{1 + \frac{\left|x\right|}{s}}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{4 \cdot \left(x \cdot x\right)}{\left|x\right|}}\\
\end{array}
if (fabs.f32 x) < 9.99999998e18Initial program 99.6%
Applied rewrites99.3%
Taylor expanded in s around inf
Applied rewrites94.6%
Taylor expanded in s around inf
Applied rewrites50.7%
if 9.99999998e18 < (fabs.f32 x) Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites95.7%
Taylor expanded in s around inf
Applied rewrites50.9%
Taylor expanded in x around -inf
Applied rewrites31.0%
Applied rewrites31.3%
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (if (<= (- (fabs x)) -9999999980506448000.0) (/ 1.0 (/ (* 4.0 (* x x)) (fabs x))) (/ 0.25 (* s (- (/ (fabs x) s) -1.0)))))
float code(float x, float s) {
float tmp;
if (-fabsf(x) <= -9999999980506448000.0f) {
tmp = 1.0f / ((4.0f * (x * x)) / fabsf(x));
} else {
tmp = 0.25f / (s * ((fabsf(x) / s) - -1.0f));
}
return tmp;
}
real(4) function code(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (-abs(x) <= (-9999999980506448000.0e0)) then
tmp = 1.0e0 / ((4.0e0 * (x * x)) / abs(x))
else
tmp = 0.25e0 / (s * ((abs(x) / s) - (-1.0e0)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-abs(x)) <= Float32(-9999999980506448000.0)) tmp = Float32(Float32(1.0) / Float32(Float32(Float32(4.0) * Float32(x * x)) / abs(x))); else tmp = Float32(Float32(0.25) / Float32(s * Float32(Float32(abs(x) / s) - Float32(-1.0)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-abs(x) <= single(-9999999980506448000.0)) tmp = single(1.0) / ((single(4.0) * (x * x)) / abs(x)); else tmp = single(0.25) / (s * ((abs(x) / s) - single(-1.0))); end tmp_2 = tmp; end
\begin{array}{l}
\mathbf{if}\;-\left|x\right| \leq -9999999980506448000:\\
\;\;\;\;\frac{1}{\frac{4 \cdot \left(x \cdot x\right)}{\left|x\right|}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s \cdot \left(\frac{\left|x\right|}{s} - -1\right)}\\
\end{array}
if (neg.f32 (fabs.f32 x)) < -9.99999998e18Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites95.7%
Taylor expanded in s around inf
Applied rewrites50.9%
Taylor expanded in x around -inf
Applied rewrites31.0%
Applied rewrites31.3%
if -9.99999998e18 < (neg.f32 (fabs.f32 x)) Initial program 99.6%
Applied rewrites99.3%
Taylor expanded in s around inf
Applied rewrites94.6%
Taylor expanded in s around inf
Applied rewrites50.7%
Applied rewrites50.8%
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (if (<= (- (fabs x)) -2.0000000400817547e+20) (/ 1.0 (* -4.0 (sqrt (* x x)))) (/ 0.25 (* s (- (/ (fabs x) s) -1.0)))))
float code(float x, float s) {
float tmp;
if (-fabsf(x) <= -2.0000000400817547e+20f) {
tmp = 1.0f / (-4.0f * sqrtf((x * x)));
} else {
tmp = 0.25f / (s * ((fabsf(x) / s) - -1.0f));
}
return tmp;
}
real(4) function code(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: tmp
if (-abs(x) <= (-2.0000000400817547e+20)) then
tmp = 1.0e0 / ((-4.0e0) * sqrt((x * x)))
else
tmp = 0.25e0 / (s * ((abs(x) / s) - (-1.0e0)))
end if
code = tmp
end function
function code(x, s) tmp = Float32(0.0) if (Float32(-abs(x)) <= Float32(-2.0000000400817547e+20)) tmp = Float32(Float32(1.0) / Float32(Float32(-4.0) * sqrt(Float32(x * x)))); else tmp = Float32(Float32(0.25) / Float32(s * Float32(Float32(abs(x) / s) - Float32(-1.0)))); end return tmp end
function tmp_2 = code(x, s) tmp = single(0.0); if (-abs(x) <= single(-2.0000000400817547e+20)) tmp = single(1.0) / (single(-4.0) * sqrt((x * x))); else tmp = single(0.25) / (s * ((abs(x) / s) - single(-1.0))); end tmp_2 = tmp; end
\begin{array}{l}
\mathbf{if}\;-\left|x\right| \leq -2.0000000400817547 \cdot 10^{+20}:\\
\;\;\;\;\frac{1}{-4 \cdot \sqrt{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s \cdot \left(\frac{\left|x\right|}{s} - -1\right)}\\
\end{array}
if (neg.f32 (fabs.f32 x)) < -2.00000004e20Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites95.7%
Taylor expanded in s around inf
Applied rewrites50.9%
Taylor expanded in s around 0
Applied rewrites7.7%
Applied rewrites28.0%
if -2.00000004e20 < (neg.f32 (fabs.f32 x)) Initial program 99.6%
Applied rewrites99.3%
Taylor expanded in s around inf
Applied rewrites94.6%
Taylor expanded in s around inf
Applied rewrites50.7%
Applied rewrites50.8%
(FPCore (x s)
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(let* ((t_0 (exp (/ (- (fabs x)) s))) (t_1 (+ 1.0 t_0)))
(if (<= (/ t_0 (* (* s t_1) t_1)) 0.0)
(/ 1.0 (* -4.0 (sqrt (* x x))))
(/ 0.25 s))))float code(float x, float s) {
float t_0 = expf((-fabsf(x) / s));
float t_1 = 1.0f + t_0;
float tmp;
if ((t_0 / ((s * t_1) * t_1)) <= 0.0f) {
tmp = 1.0f / (-4.0f * sqrtf((x * x)));
} else {
tmp = 0.25f / s;
}
return tmp;
}
real(4) function code(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: t_1
real(4) :: tmp
t_0 = exp((-abs(x) / s))
t_1 = 1.0e0 + t_0
if ((t_0 / ((s * t_1) * t_1)) <= 0.0e0) then
tmp = 1.0e0 / ((-4.0e0) * sqrt((x * x)))
else
tmp = 0.25e0 / s
end if
code = tmp
end function
function code(x, s) t_0 = exp(Float32(Float32(-abs(x)) / s)) t_1 = Float32(Float32(1.0) + t_0) tmp = Float32(0.0) if (Float32(t_0 / Float32(Float32(s * t_1) * t_1)) <= Float32(0.0)) tmp = Float32(Float32(1.0) / Float32(Float32(-4.0) * sqrt(Float32(x * x)))); else tmp = Float32(Float32(0.25) / s); end return tmp end
function tmp_2 = code(x, s) t_0 = exp((-abs(x) / s)); t_1 = single(1.0) + t_0; tmp = single(0.0); if ((t_0 / ((s * t_1) * t_1)) <= single(0.0)) tmp = single(1.0) / (single(-4.0) * sqrt((x * x))); else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
t_1 := 1 + t\_0\\
\mathbf{if}\;\frac{t\_0}{\left(s \cdot t\_1\right) \cdot t\_1} \leq 0:\\
\;\;\;\;\frac{1}{-4 \cdot \sqrt{x \cdot x}}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 0.0Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites95.7%
Taylor expanded in s around inf
Applied rewrites50.9%
Taylor expanded in s around 0
Applied rewrites7.7%
Applied rewrites28.0%
if 0.0 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites27.9%
(FPCore (x s)
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(let* ((t_0 (exp (/ (- (fabs (fabs x))) s))) (t_1 (+ 1.0 t_0)))
(if (<= (/ t_0 (* (* s t_1) t_1)) 2.000000033724767e-16)
(/ 1.0 (* 4.0 (fabs x)))
(/ 0.25 s))))float code(float x, float s) {
float t_0 = expf((-fabsf(fabsf(x)) / s));
float t_1 = 1.0f + t_0;
float tmp;
if ((t_0 / ((s * t_1) * t_1)) <= 2.000000033724767e-16f) {
tmp = 1.0f / (4.0f * fabsf(x));
} else {
tmp = 0.25f / s;
}
return tmp;
}
real(4) function code(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: t_1
real(4) :: tmp
t_0 = exp((-abs(abs(x)) / s))
t_1 = 1.0e0 + t_0
if ((t_0 / ((s * t_1) * t_1)) <= 2.000000033724767e-16) then
tmp = 1.0e0 / (4.0e0 * abs(x))
else
tmp = 0.25e0 / s
end if
code = tmp
end function
function code(x, s) t_0 = exp(Float32(Float32(-abs(abs(x))) / s)) t_1 = Float32(Float32(1.0) + t_0) tmp = Float32(0.0) if (Float32(t_0 / Float32(Float32(s * t_1) * t_1)) <= Float32(2.000000033724767e-16)) tmp = Float32(Float32(1.0) / Float32(Float32(4.0) * abs(x))); else tmp = Float32(Float32(0.25) / s); end return tmp end
function tmp_2 = code(x, s) t_0 = exp((-abs(abs(x)) / s)); t_1 = single(1.0) + t_0; tmp = single(0.0); if ((t_0 / ((s * t_1) * t_1)) <= single(2.000000033724767e-16)) tmp = single(1.0) / (single(4.0) * abs(x)); else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
t_0 := e^{\frac{-\left|\left|x\right|\right|}{s}}\\
t_1 := 1 + t\_0\\
\mathbf{if}\;\frac{t\_0}{\left(s \cdot t\_1\right) \cdot t\_1} \leq 2.000000033724767 \cdot 10^{-16}:\\
\;\;\;\;\frac{1}{4 \cdot \left|x\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 2.00000003e-16Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites95.7%
Taylor expanded in s around inf
Applied rewrites50.9%
Applied rewrites57.0%
Taylor expanded in x around -inf
Applied rewrites9.3%
if 2.00000003e-16 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites27.9%
(FPCore (x s)
:precision binary32
:pre (and (<= 0.0 s) (<= s 1.0651631))
(let* ((t_0 (exp (/ (- (fabs x)) s))) (t_1 (+ 1.0 t_0)))
(if (<= (/ t_0 (* (* s t_1) t_1)) 0.0)
(/ 1.0 (* -4.0 x))
(/ 0.25 s))))float code(float x, float s) {
float t_0 = expf((-fabsf(x) / s));
float t_1 = 1.0f + t_0;
float tmp;
if ((t_0 / ((s * t_1) * t_1)) <= 0.0f) {
tmp = 1.0f / (-4.0f * x);
} else {
tmp = 0.25f / s;
}
return tmp;
}
real(4) function code(x, s)
use fmin_fmax_functions
real(4), intent (in) :: x
real(4), intent (in) :: s
real(4) :: t_0
real(4) :: t_1
real(4) :: tmp
t_0 = exp((-abs(x) / s))
t_1 = 1.0e0 + t_0
if ((t_0 / ((s * t_1) * t_1)) <= 0.0e0) then
tmp = 1.0e0 / ((-4.0e0) * x)
else
tmp = 0.25e0 / s
end if
code = tmp
end function
function code(x, s) t_0 = exp(Float32(Float32(-abs(x)) / s)) t_1 = Float32(Float32(1.0) + t_0) tmp = Float32(0.0) if (Float32(t_0 / Float32(Float32(s * t_1) * t_1)) <= Float32(0.0)) tmp = Float32(Float32(1.0) / Float32(Float32(-4.0) * x)); else tmp = Float32(Float32(0.25) / s); end return tmp end
function tmp_2 = code(x, s) t_0 = exp((-abs(x) / s)); t_1 = single(1.0) + t_0; tmp = single(0.0); if ((t_0 / ((s * t_1) * t_1)) <= single(0.0)) tmp = single(1.0) / (single(-4.0) * x); else tmp = single(0.25) / s; end tmp_2 = tmp; end
\begin{array}{l}
t_0 := e^{\frac{-\left|x\right|}{s}}\\
t_1 := 1 + t\_0\\
\mathbf{if}\;\frac{t\_0}{\left(s \cdot t\_1\right) \cdot t\_1} \leq 0:\\
\;\;\;\;\frac{1}{-4 \cdot x}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.25}{s}\\
\end{array}
if (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) < 0.0Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites95.7%
Taylor expanded in s around inf
Applied rewrites50.9%
Applied rewrites57.0%
Taylor expanded in x around inf
Applied rewrites9.5%
if 0.0 < (/.f32 (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)) (*.f32 (*.f32 s (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s)))) (+.f32 #s(literal 1 binary32) (exp.f32 (/.f32 (neg.f32 (fabs.f32 x)) s))))) Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites27.9%
(FPCore (x s) :precision binary32 :pre (and (<= 0.0 s) (<= s 1.0651631)) (/ 0.25 s))
float code(float x, float s) {
return 0.25f / s;
}
real(4) function code(x, s)
use fmin_fmax_functions
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
\frac{0.25}{s}
Initial program 99.6%
Taylor expanded in s around inf
Applied rewrites27.9%
herbie shell --seed 2026084
(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))))))