Average Error: 61.6 → 2.3
Time: 18.5s
Precision: binary64
\[-\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) \]
\[0.0012152777777777778 \cdot \left({f}^{4} \cdot {\pi}^{3}\right) - \mathsf{fma}\left(\pi, 0.08333333333333333 \cdot \left(f \cdot f\right), 4 \cdot \frac{\log \left(\frac{4}{\pi}\right) - \log f}{\pi}\right) \]
-\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)
0.0012152777777777778 \cdot \left({f}^{4} \cdot {\pi}^{3}\right) - \mathsf{fma}\left(\pi, 0.08333333333333333 \cdot \left(f \cdot f\right), 4 \cdot \frac{\log \left(\frac{4}{\pi}\right) - \log f}{\pi}\right)
(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
 (-
  (* 0.0012152777777777778 (* (pow f 4.0) (pow PI 3.0)))
  (fma
   PI
   (* 0.08333333333333333 (* f f))
   (* 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) {
	return (0.0012152777777777778 * (pow(f, 4.0) * pow(((double) M_PI), 3.0))) - fma(((double) M_PI), (0.08333333333333333 * (f * f)), (4.0 * ((log(4.0 / ((double) M_PI)) - log(f)) / ((double) M_PI))));
}

Error

Bits error versus f

Derivation

  1. Initial program 61.6

    \[-\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) \]
  2. Simplified61.6

    \[\leadsto \color{blue}{\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(e^{-0.25}\right)}^{\left(\pi \cdot f\right)}}\right) \cdot \frac{-4}{\pi}} \]
  3. Taylor expanded in f around 0 2.4

    \[\leadsto \color{blue}{\left(\left(0.020833333333333332 \cdot \left({f}^{2} \cdot {\pi}^{2}\right) + \log \left(\frac{4}{\pi}\right)\right) - \left(0.00030381944444444445 \cdot \left({f}^{4} \cdot {\pi}^{4}\right) + \log f\right)\right)} \cdot \frac{-4}{\pi} \]
  4. Simplified2.4

    \[\leadsto \color{blue}{\left(\mathsf{fma}\left(0.020833333333333332, \left(f \cdot f\right) \cdot {\pi}^{2}, \log \left(\frac{4}{\pi}\right)\right) - \mathsf{fma}\left(0.00030381944444444445, {f}^{4} \cdot {\pi}^{4}, \log f\right)\right)} \cdot \frac{-4}{\pi} \]
  5. Taylor expanded in f around 0 2.4

    \[\leadsto \color{blue}{\left(4 \cdot \frac{\log f}{\pi} + 0.0012152777777777778 \cdot \left({f}^{4} \cdot {\pi}^{3}\right)\right) - \left(0.08333333333333333 \cdot \left({f}^{2} \cdot \pi\right) + 4 \cdot \frac{\log \left(\frac{4}{\pi}\right)}{\pi}\right)} \]
  6. Simplified2.3

    \[\leadsto \color{blue}{0.0012152777777777778 \cdot \left({f}^{4} \cdot {\pi}^{3}\right) - \mathsf{fma}\left(\pi, 0.08333333333333333 \cdot \left(f \cdot f\right), 4 \cdot \frac{\log \left(\frac{4}{\pi}\right) - \log f}{\pi}\right)} \]
  7. Applied sub-neg_binary642.3

    \[\leadsto 0.0012152777777777778 \cdot \left({f}^{4} \cdot {\pi}^{3}\right) - \mathsf{fma}\left(\pi, 0.08333333333333333 \cdot \left(f \cdot f\right), 4 \cdot \frac{\color{blue}{\log \left(\frac{4}{\pi}\right) + \left(-\log f\right)}}{\pi}\right) \]
  8. Final simplification2.3

    \[\leadsto 0.0012152777777777778 \cdot \left({f}^{4} \cdot {\pi}^{3}\right) - \mathsf{fma}\left(\pi, 0.08333333333333333 \cdot \left(f \cdot f\right), 4 \cdot \frac{\log \left(\frac{4}{\pi}\right) - \log f}{\pi}\right) \]

Reproduce

herbie shell --seed 2022072 
(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)))))))))