Average Error: 61.5 → 0.7
Time: 7.0min
Precision: binary64
Cost: 47041
\[-\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 34.04800377750026:\\ \;\;\;\;-\frac{\log \left(\frac{1}{\sqrt{\sinh \left(\frac{\pi}{4} \cdot f\right)}} \cdot \frac{\cosh \left(\frac{\pi}{4} \cdot f\right)}{\sqrt{\sinh \left(\frac{\pi}{4} \cdot f\right)}}\right) + \log 1}{\frac{\pi}{4}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
-\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 34.04800377750026:\\
\;\;\;\;-\frac{\log \left(\frac{1}{\sqrt{\sinh \left(\frac{\pi}{4} \cdot f\right)}} \cdot \frac{\cosh \left(\frac{\pi}{4} \cdot f\right)}{\sqrt{\sinh \left(\frac{\pi}{4} \cdot f\right)}}\right) + \log 1}{\frac{\pi}{4}}\\

\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) 34.04800377750026)
   (-
    (/
     (+
      (log
       (*
        (/ 1.0 (sqrt (sinh (* (/ PI 4.0) f))))
        (/ (cosh (* (/ PI 4.0) f)) (sqrt (sinh (* (/ PI 4.0) f))))))
      (log 1.0))
     (/ PI 4.0)))
   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) <= 34.04800377750026) {
		tmp = -((log((1.0 / sqrt(sinh((((double) M_PI) / 4.0) * f))) * (cosh((((double) M_PI) / 4.0) * f) / sqrt(sinh((((double) M_PI) / 4.0) * f)))) + log(1.0)) / (((double) M_PI) / 4.0));
	} else {
		tmp = 0.0;
	}
	return tmp;
}

Error

Bits error versus f

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Alternatives

Alternative 1
Error0.7
Cost20737
\[\begin{array}{l} \mathbf{if}\;\frac{\pi}{4} \cdot f \leq 4.121924931745751:\\ \;\;\;\;\frac{\log \left(\frac{\cosh \left(\frac{\pi}{4} \cdot f\right)}{\sinh \left(\frac{\pi}{4} \cdot f\right)}\right)}{\pi} \cdot -4\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 2
Error1.0
Cost14209
\[\begin{array}{l} \mathbf{if}\;f \leq 222.47642858615106:\\ \;\;\;\;\frac{\log \left(\frac{4}{\pi}\right) - \log f}{\pi} \cdot -4 - 0.08333333333333333 \cdot \left(\pi \cdot \left(f \cdot f\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 3
Error1.1
Cost14273
\[\begin{array}{l} \mathbf{if}\;f \leq 227.2691599274196:\\ \;\;\;\;-\frac{\log 1 + \log \left(\frac{4}{\pi \cdot f} + 0.08333333333333333 \cdot \left(\pi \cdot f\right)\right)}{\frac{\pi}{4}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 4
Error1.1
Cost7809
\[\begin{array}{l} \mathbf{if}\;f \leq 222.47642858615106:\\ \;\;\;\;\frac{\log \left(\frac{\frac{4}{\pi}}{f}\right)}{\pi} \cdot -4 - 0.08333333333333333 \cdot \left(\pi \cdot \left(f \cdot f\right)\right)\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 5
Error1.2
Cost7809
\[\begin{array}{l} \mathbf{if}\;f \leq 227.2691599274196:\\ \;\;\;\;\log \left(\frac{4}{\pi \cdot f} + 0.08333333333333333 \cdot \left(\pi \cdot f\right)\right) \cdot \frac{-1}{\frac{\pi}{4}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 6
Error1.4
Cost7297
\[\begin{array}{l} \mathbf{if}\;f \leq 1.2505667317486036:\\ \;\;\;\;\frac{\log \left(\frac{4}{\pi \cdot f}\right) \cdot -4}{\pi}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 7
Error1.5
Cost7297
\[\begin{array}{l} \mathbf{if}\;f \leq 1.2505667317486036:\\ \;\;\;\;\log \left(\frac{4}{\pi \cdot f}\right) \cdot \frac{-4}{\pi}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 8
Error54.0
Cost385
\[\begin{array}{l} \mathbf{if}\;f \leq 227.2691599274196:\\ \;\;\;\;-1\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]
Alternative 9
Error60.8
Cost64
\[0\]
Alternative 10
Error63.0
Cost64
\[1\]

Error

Time

Derivation

  1. Split input into 2 regimes
  2. if (*.f64 (/.f64 PI.f64 4) f) < 34.0480037775002629

    1. Initial program 61.5

      \[-\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. Using strategy rm
    3. Applied sinh-undef_binary640.6

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{e^{\frac{\pi}{4} \cdot f} + e^{-\frac{\pi}{4} \cdot f}}{\color{blue}{2 \cdot \sinh \left(\frac{\pi}{4} \cdot f\right)}}\right)\]
    4. Applied cosh-undef_binary640.6

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \left(\frac{\color{blue}{2 \cdot \cosh \left(\frac{\pi}{4} \cdot f\right)}}{2 \cdot \sinh \left(\frac{\pi}{4} \cdot f\right)}\right)\]
    5. Applied times-frac_binary640.6

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \log \color{blue}{\left(\frac{2}{2} \cdot \frac{\cosh \left(\frac{\pi}{4} \cdot f\right)}{\sinh \left(\frac{\pi}{4} \cdot f\right)}\right)}\]
    6. Applied log-prod_binary640.6

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \color{blue}{\left(\log \left(\frac{2}{2}\right) + \log \left(\frac{\cosh \left(\frac{\pi}{4} \cdot f\right)}{\sinh \left(\frac{\pi}{4} \cdot f\right)}\right)\right)}\]
    7. Simplified0.6

      \[\leadsto -\frac{1}{\frac{\pi}{4}} \cdot \left(\color{blue}{\log 1} + \log \left(\frac{\cosh \left(\frac{\pi}{4} \cdot f\right)}{\sinh \left(\frac{\pi}{4} \cdot f\right)}\right)\right)\]
    8. Using strategy rm
    9. Applied associate-*l/_binary640.5

      \[\leadsto -\color{blue}{\frac{1 \cdot \left(\log 1 + \log \left(\frac{\cosh \left(\frac{\pi}{4} \cdot f\right)}{\sinh \left(\frac{\pi}{4} \cdot f\right)}\right)\right)}{\frac{\pi}{4}}}\]
    10. Simplified0.5

      \[\leadsto -\frac{\color{blue}{\log \left(\frac{\cosh \left(\frac{\pi}{4} \cdot f\right)}{\sinh \left(\frac{\pi}{4} \cdot f\right)}\right) + \log 1}}{\frac{\pi}{4}}\]
    11. Using strategy rm
    12. Applied add-sqr-sqrt_binary640.5

      \[\leadsto -\frac{\log \left(\frac{\cosh \left(\frac{\pi}{4} \cdot f\right)}{\color{blue}{\sqrt{\sinh \left(\frac{\pi}{4} \cdot f\right)} \cdot \sqrt{\sinh \left(\frac{\pi}{4} \cdot f\right)}}}\right) + \log 1}{\frac{\pi}{4}}\]
    13. Applied *-un-lft-identity_binary640.5

      \[\leadsto -\frac{\log \left(\frac{\color{blue}{1 \cdot \cosh \left(\frac{\pi}{4} \cdot f\right)}}{\sqrt{\sinh \left(\frac{\pi}{4} \cdot f\right)} \cdot \sqrt{\sinh \left(\frac{\pi}{4} \cdot f\right)}}\right) + \log 1}{\frac{\pi}{4}}\]
    14. Applied times-frac_binary640.5

      \[\leadsto -\frac{\log \color{blue}{\left(\frac{1}{\sqrt{\sinh \left(\frac{\pi}{4} \cdot f\right)}} \cdot \frac{\cosh \left(\frac{\pi}{4} \cdot f\right)}{\sqrt{\sinh \left(\frac{\pi}{4} \cdot f\right)}}\right)} + \log 1}{\frac{\pi}{4}}\]
    15. Simplified0.5

      \[\leadsto \color{blue}{-\frac{\log \left(\frac{1}{\sqrt{\sinh \left(\frac{\pi}{4} \cdot f\right)}} \cdot \frac{\cosh \left(\frac{\pi}{4} \cdot f\right)}{\sqrt{\sinh \left(\frac{\pi}{4} \cdot f\right)}}\right) + \log 1}{\frac{\pi}{4}}}\]

    if 34.0480037775002629 < (*.f64 (/.f64 PI.f64 4) f)

    1. Initial program 8.8

      \[0\]
    2. Simplified8.8

      \[\leadsto \color{blue}{0}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{\pi}{4} \cdot f \leq 34.04800377750026:\\ \;\;\;\;-\frac{\log \left(\frac{1}{\sqrt{\sinh \left(\frac{\pi}{4} \cdot f\right)}} \cdot \frac{\cosh \left(\frac{\pi}{4} \cdot f\right)}{\sqrt{\sinh \left(\frac{\pi}{4} \cdot f\right)}}\right) + \log 1}{\frac{\pi}{4}}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Reproduce

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