-\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}
t_0 := \frac{\pi}{4} \cdot f\\
t_1 := e^{t_0}\\
\mathbf{if}\;\begin{array}{l}
t_2 := e^{-t_0}\\
\frac{t_1 + t_2}{t_1 - t_2} \leq 181103.68332153108
\end{array}:\\
\;\;\;\;\begin{array}{l}
t_3 := {\left(e^{-0.25}\right)}^{\left(\pi \cdot f\right)}\\
\log \left(\frac{e^{\frac{1}{\frac{4}{\pi \cdot f}}} + t_3}{t_1 - t_3}\right) \cdot \frac{-4}{\pi}
\end{array}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{\log \left(\frac{4}{\pi}\right) - \log f}{\pi}\\
\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
(let* ((t_0 (* (/ PI 4.0) f)) (t_1 (exp t_0)))
(if (let* ((t_2 (exp (- t_0))))
(<= (/ (+ t_1 t_2) (- t_1 t_2)) 181103.68332153108))
(let* ((t_3 (pow (exp -0.25) (* PI f))))
(*
(log (/ (+ (exp (/ 1.0 (/ 4.0 (* PI f)))) t_3) (- t_1 t_3)))
(/ -4.0 PI)))
(* -4.0 (/ (- (log (/ 4.0 PI)) (log f)) PI)))))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 t_0 = (((double) M_PI) / 4.0) * f;
double t_1 = exp(t_0);
double t_2 = exp(-t_0);
double tmp;
if (((t_1 + t_2) / (t_1 - t_2)) <= 181103.68332153108) {
double t_3_1 = pow(exp(-0.25), (((double) M_PI) * f));
tmp = log((exp(1.0 / (4.0 / (((double) M_PI) * f))) + t_3_1) / (t_1 - t_3_1)) * (-4.0 / ((double) M_PI));
} else {
tmp = -4.0 * ((log(4.0 / ((double) M_PI)) - log(f)) / ((double) M_PI));
}
return tmp;
}



Bits error versus f
Results
if (/.f64 (+.f64 (exp.f64 (*.f64 (/.f64 PI.f64 4) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 PI.f64 4) f)))) (-.f64 (exp.f64 (*.f64 (/.f64 PI.f64 4) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 PI.f64 4) f))))) < 181103.683321531076Initial program 14.2
Simplified14.2
rmApplied associate-*l/_binary6414.2
Applied clear-num_binary6414.2
if 181103.683321531076 < (/.f64 (+.f64 (exp.f64 (*.f64 (/.f64 PI.f64 4) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 PI.f64 4) f)))) (-.f64 (exp.f64 (*.f64 (/.f64 PI.f64 4) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 PI.f64 4) f))))) Initial program 62.7
Simplified62.7
Taylor expanded around 0 1.7
Simplified1.7
rmApplied clear-num_binary641.7
Applied un-div-inv_binary641.6
Applied associate-/r/_binary641.6
Simplified1.6
Taylor expanded around 0 1.5
Final simplification1.9
herbie shell --seed 2021211
(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)))))))))