\left(-s\right) \cdot \log \left(\frac{1}{u \cdot \left(\frac{1}{1 + e^{\frac{-\pi}{s}}} - \frac{1}{1 + e^{\frac{\pi}{s}}}\right) + \frac{1}{1 + e^{\frac{\pi}{s}}}} - 1\right)
\begin{array}{l}
t_0 := \frac{u}{1 + e^{\frac{-\pi}{s}}}\\
\left(-s\right) \cdot \left(\log \left(\sqrt{\frac{1}{t_0 + \frac{1 - u}{1 + e^{\frac{\sqrt[3]{\pi} \cdot \sqrt[3]{\pi}}{\frac{s}{\sqrt[3]{\pi}}}}}} + -1}\right) + \log \left(\sqrt{-1 + \frac{1}{t_0 + \frac{1 - u}{1 + e^{\frac{\pi}{s}}}}}\right)\right)
\end{array}
(FPCore (u s)
:precision binary32
(*
(- s)
(log
(-
(/
1.0
(+
(*
u
(- (/ 1.0 (+ 1.0 (exp (/ (- PI) s)))) (/ 1.0 (+ 1.0 (exp (/ PI s))))))
(/ 1.0 (+ 1.0 (exp (/ PI s))))))
1.0))))(FPCore (u s)
:precision binary32
(let* ((t_0 (/ u (+ 1.0 (exp (/ (- PI) s))))))
(*
(- s)
(+
(log
(sqrt
(+
(/
1.0
(+
t_0
(/
(- 1.0 u)
(+ 1.0 (exp (/ (* (cbrt PI) (cbrt PI)) (/ s (cbrt PI))))))))
-1.0)))
(log
(sqrt (+ -1.0 (/ 1.0 (+ t_0 (/ (- 1.0 u) (+ 1.0 (exp (/ PI s)))))))))))))float code(float u, float s) {
return -s * logf(((1.0f / ((u * ((1.0f / (1.0f + expf((-((float) M_PI) / s)))) - (1.0f / (1.0f + expf((((float) M_PI) / s)))))) + (1.0f / (1.0f + expf((((float) M_PI) / s)))))) - 1.0f));
}
float code(float u, float s) {
float t_0 = u / (1.0f + expf((-((float) M_PI) / s)));
return -s * (logf(sqrtf(((1.0f / (t_0 + ((1.0f - u) / (1.0f + expf(((cbrtf(((float) M_PI)) * cbrtf(((float) M_PI))) / (s / cbrtf(((float) M_PI))))))))) + -1.0f))) + logf(sqrtf((-1.0f + (1.0f / (t_0 + ((1.0f - u) / (1.0f + expf((((float) M_PI) / s))))))))));
}



Bits error versus u



Bits error versus s
Results
Initial program 0.3
Simplified0.3
Applied add-sqr-sqrt_binary320.4
Applied log-prod_binary320.4
Applied add-cube-cbrt_binary320.4
Applied associate-/l*_binary320.4
Final simplification0.4
herbie shell --seed 2022125
(FPCore (u s)
:name "Sample trimmed logistic on [-pi, pi]"
:precision binary32
:pre (and (and (<= 2.328306437e-10 u) (<= u 1.0)) (and (<= 0.0 s) (<= s 1.0651631)))
(* (- s) (log (- (/ 1.0 (+ (* u (- (/ 1.0 (+ 1.0 (exp (/ (- PI) s)))) (/ 1.0 (+ 1.0 (exp (/ PI s)))))) (/ 1.0 (+ 1.0 (exp (/ PI s)))))) 1.0))))