-\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{e^{\frac{\pi}{4} \cdot f} + e^{-\frac{\pi}{4} \cdot f}}{e^{\frac{\pi}{4} \cdot f} - e^{-\frac{\pi}{4} \cdot f}} \leq 7856.863052763977:\\
\;\;\;\;\log \left(\frac{e^{\frac{\pi}{4} \cdot f} + {\left(e^{-0.25}\right)}^{\left(\pi \cdot f\right)}}{e^{\frac{\pi}{4} \cdot f} - {\left(\sqrt{e^{-0.25}}\right)}^{\left(\pi \cdot f\right)} \cdot {\left(\sqrt{e^{-0.25}}\right)}^{\left(\pi \cdot f\right)}}\right) \cdot \frac{-4}{\pi}\\
\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
(if (<=
(/
(+ (exp (* (/ PI 4.0) f)) (exp (- (* (/ PI 4.0) f))))
(- (exp (* (/ PI 4.0) f)) (exp (- (* (/ PI 4.0) f)))))
7856.863052763977)
(*
(log
(/
(+ (exp (* (/ PI 4.0) f)) (pow (exp -0.25) (* PI f)))
(-
(exp (* (/ PI 4.0) f))
(*
(pow (sqrt (exp -0.25)) (* PI f))
(pow (sqrt (exp -0.25)) (* PI f))))))
(/ -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 tmp;
if (((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)))) <= 7856.863052763977) {
tmp = log((exp((((double) M_PI) / 4.0) * f) + pow(exp(-0.25), (((double) M_PI) * f))) / (exp((((double) M_PI) / 4.0) * f) - (pow(sqrt(exp(-0.25)), (((double) M_PI) * f)) * pow(sqrt(exp(-0.25)), (((double) M_PI) * f))))) * (-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))))) < 7856.86305276397707Initial program 17.7
Simplified17.7
rmApplied add-sqr-sqrt_binary6417.7
Applied unpow-prod-down_binary6417.7
Applied cancel-sign-sub-inv_binary6417.7
if 7856.86305276397707 < (/.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.6
Simplified62.6
Taylor expanded around 0 1.7
Simplified1.7
Taylor expanded around 0 1.6
Final simplification1.9
herbie shell --seed 2021022
(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)))))))))