-\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{e^{\frac{\pi}{4} \cdot f} + e^{-\frac{\pi}{4} \cdot f}}{e^{\frac{\pi}{4} \cdot f} - e^{-\frac{\pi}{4} \cdot f}}\right)\begin{array}{l}
\mathbf{if}\;\frac{\pi}{4} \cdot f \leq 0.7808300383013007:\\
\;\;\;\;-4 \cdot \frac{\log \left(\frac{4}{\pi}\right) - \log f}{\pi}\\
\mathbf{else}:\\
\;\;\;\;0\\
\end{array}(FPCore (f)
:precision binary64
(-
(*
(/ 1.0 (/ PI 4.0))
(log
(/
(+ (exp (* (/ PI 4.0) f)) (exp (- (* (/ PI 4.0) f))))
(- (exp (* (/ PI 4.0) f)) (exp (- (* (/ PI 4.0) f)))))))))(FPCore (f) :precision binary64 (if (<= (* (/ PI 4.0) f) 0.7808300383013007) (* -4.0 (/ (- (log (/ 4.0 PI)) (log f)) PI)) 0.0))
double code(double f) {
return -((1.0 / (((double) M_PI) / 4.0)) * log((exp((((double) M_PI) / 4.0) * f) + exp(-((((double) M_PI) / 4.0) * f))) / (exp((((double) M_PI) / 4.0) * f) - exp(-((((double) M_PI) / 4.0) * f)))));
}
double code(double f) {
double tmp;
if (((((double) M_PI) / 4.0) * f) <= 0.7808300383013007) {
tmp = -4.0 * ((log(4.0 / ((double) M_PI)) - log(f)) / ((double) M_PI));
} else {
tmp = 0.0;
}
return tmp;
}



Bits error versus f
Results
if (*.f64 (/.f64 PI.f64 4) f) < 0.78083003830130071Initial program 61.6
Simplified61.6
Taylor expanded around 0 1.0
Simplified1.0
Taylor expanded around 0 0.9
if 0.78083003830130071 < (*.f64 (/.f64 PI.f64 4) f) Initial program 18.7
Final simplification1.4
herbie shell --seed 2021113
(FPCore (f)
:name "VandenBroeck and Keller, Equation (20)"
:precision binary64
(- (* (/ 1.0 (/ PI 4.0)) (log (/ (+ (exp (* (/ PI 4.0) f)) (exp (- (* (/ PI 4.0) f)))) (- (exp (* (/ PI 4.0) f)) (exp (- (* (/ PI 4.0) f)))))))))