
(FPCore (f) :precision binary64 (let* ((t_0 (/ (PI) 4.0)) (t_1 (* t_0 f)) (t_2 (exp t_1)) (t_3 (exp (- t_1)))) (- (* (/ 1.0 t_0) (log (/ (+ t_2 t_3) (- t_2 t_3)))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{4}\\
t_1 := t\_0 \cdot f\\
t_2 := e^{t\_1}\\
t_3 := e^{-t\_1}\\
-\frac{1}{t\_0} \cdot \log \left(\frac{t\_2 + t\_3}{t\_2 - t\_3}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (f) :precision binary64 (let* ((t_0 (/ (PI) 4.0)) (t_1 (* t_0 f)) (t_2 (exp t_1)) (t_3 (exp (- t_1)))) (- (* (/ 1.0 t_0) (log (/ (+ t_2 t_3) (- t_2 t_3)))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{4}\\
t_1 := t\_0 \cdot f\\
t_2 := e^{t\_1}\\
t_3 := e^{-t\_1}\\
-\frac{1}{t\_0} \cdot \log \left(\frac{t\_2 + t\_3}{t\_2 - t\_3}\right)
\end{array}
\end{array}
(FPCore (f)
:precision binary64
(let* ((t_0 (/ (PI) -4.0)))
(if (<= f 20.0)
(* (/ (log (/ (cosh (* t_0 f)) (sinh (* (* (PI) f) 0.25)))) (PI)) -4.0)
(*
(/ -1.0 (/ (PI) 4.0))
(log (pow (* (pow f -1.0) (/ 4.0 (PI))) (pow (exp f) t_0)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{-4}\\
\mathbf{if}\;f \leq 20:\\
\;\;\;\;\frac{\log \left(\frac{\cosh \left(t\_0 \cdot f\right)}{\sinh \left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot 0.25\right)}\right)}{\mathsf{PI}\left(\right)} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left({\left({f}^{-1} \cdot \frac{4}{\mathsf{PI}\left(\right)}\right)}^{\left({\left(e^{f}\right)}^{t\_0}\right)}\right)\\
\end{array}
\end{array}
if f < 20Initial program 8.1%
lift-neg.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
Applied rewrites99.4%
Taylor expanded in f around 0
Applied rewrites99.4%
if 20 < f Initial program 0.0%
Applied rewrites100.0%
Taylor expanded in f around 0
Applied rewrites100.0%
Final simplification99.4%
(FPCore (f)
:precision binary64
(let* ((t_0 (/ (PI) 4.0))
(t_1 (/ (PI) -4.0))
(t_2
(log
(pow
(pow (/ (cosh (* f t_1)) (sinh (* f t_0))) (pow (exp f) t_0))
(/ (pow (exp f) t_1) 2.0)))))
(* (/ -1.0 t_0) (+ t_2 t_2))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{4}\\
t_1 := \frac{\mathsf{PI}\left(\right)}{-4}\\
t_2 := \log \left({\left({\left(\frac{\cosh \left(f \cdot t\_1\right)}{\sinh \left(f \cdot t\_0\right)}\right)}^{\left({\left(e^{f}\right)}^{t\_0}\right)}\right)}^{\left(\frac{{\left(e^{f}\right)}^{t\_1}}{2}\right)}\right)\\
\frac{-1}{t\_0} \cdot \left(t\_2 + t\_2\right)
\end{array}
\end{array}
Initial program 7.9%
Applied rewrites99.2%
Applied rewrites99.2%
Final simplification99.2%
(FPCore (f)
:precision binary64
(let* ((t_0 (/ (PI) 4.0))
(t_1 (* f t_0))
(t_2 (/ (PI) -4.0))
(t_3 (/ (cosh (* f t_2)) (sinh t_1))))
(*
(/ -1.0 t_0)
(+
(log (pow (pow t_3 (pow (exp f) t_0)) (/ (pow (exp f) t_2) 2.0)))
(log (pow (pow t_3 (exp t_1)) (/ (exp (* t_2 f)) 2.0)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{4}\\
t_1 := f \cdot t\_0\\
t_2 := \frac{\mathsf{PI}\left(\right)}{-4}\\
t_3 := \frac{\cosh \left(f \cdot t\_2\right)}{\sinh t\_1}\\
\frac{-1}{t\_0} \cdot \left(\log \left({\left({t\_3}^{\left({\left(e^{f}\right)}^{t\_0}\right)}\right)}^{\left(\frac{{\left(e^{f}\right)}^{t\_2}}{2}\right)}\right) + \log \left({\left({t\_3}^{\left(e^{t\_1}\right)}\right)}^{\left(\frac{e^{t\_2 \cdot f}}{2}\right)}\right)\right)
\end{array}
\end{array}
Initial program 7.9%
Applied rewrites99.2%
Applied rewrites99.2%
lift-pow.f64N/A
lift-exp.f64N/A
pow-expN/A
lift-*.f64N/A
lower-exp.f6499.2
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.2
Applied rewrites99.2%
lift-pow.f64N/A
lift-exp.f64N/A
pow-expN/A
lift-*.f64N/A
lower-exp.f6499.2
Applied rewrites99.2%
Final simplification99.2%
(FPCore (f)
:precision binary64
(let* ((t_0 (/ (PI) 4.0)) (t_1 (/ (PI) -4.0)))
(*
(/ -1.0 t_0)
(log
(pow
(pow (/ (cosh (* t_1 f)) (sinh (* f t_0))) (pow (exp f) t_0))
(pow (exp f) t_1))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{4}\\
t_1 := \frac{\mathsf{PI}\left(\right)}{-4}\\
\frac{-1}{t\_0} \cdot \log \left({\left({\left(\frac{\cosh \left(t\_1 \cdot f\right)}{\sinh \left(f \cdot t\_0\right)}\right)}^{\left({\left(e^{f}\right)}^{t\_0}\right)}\right)}^{\left({\left(e^{f}\right)}^{t\_1}\right)}\right)
\end{array}
\end{array}
Initial program 7.9%
Applied rewrites99.2%
Final simplification99.2%
(FPCore (f) :precision binary64 (* (/ (log (/ (cosh (* (/ (PI) -4.0) f)) (sinh (* (* (PI) f) 0.25)))) (PI)) -4.0))
\begin{array}{l}
\\
\frac{\log \left(\frac{\cosh \left(\frac{\mathsf{PI}\left(\right)}{-4} \cdot f\right)}{\sinh \left(\left(\mathsf{PI}\left(\right) \cdot f\right) \cdot 0.25\right)}\right)}{\mathsf{PI}\left(\right)} \cdot -4
\end{array}
Initial program 7.9%
lift-neg.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
Applied rewrites97.0%
Taylor expanded in f around 0
Applied rewrites97.0%
(FPCore (f) :precision binary64 (fma (* (PI) -0.08333333333333333) (* f f) (* (/ (fma (log f) -1.0 (log (/ 4.0 (PI)))) (PI)) -4.0)))
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{PI}\left(\right) \cdot -0.08333333333333333, f \cdot f, \frac{\mathsf{fma}\left(\log f, -1, \log \left(\frac{4}{\mathsf{PI}\left(\right)}\right)\right)}{\mathsf{PI}\left(\right)} \cdot -4\right)
\end{array}
Initial program 7.9%
Applied rewrites96.9%
Taylor expanded in f around 0
Applied rewrites96.2%
(FPCore (f) :precision binary64 (* (/ -1.0 (/ (PI) 4.0)) (log (/ (fma (* (PI) 0.08333333333333333) (* f f) (/ 4.0 (PI))) f))))
\begin{array}{l}
\\
\frac{-1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\mathsf{fma}\left(\mathsf{PI}\left(\right) \cdot 0.08333333333333333, f \cdot f, \frac{4}{\mathsf{PI}\left(\right)}\right)}{f}\right)
\end{array}
Initial program 7.9%
Applied rewrites96.9%
Taylor expanded in f around 0
Applied rewrites96.1%
Final simplification96.1%
(FPCore (f) :precision binary64 (* (/ (log (/ (/ 4.0 (PI)) f)) (PI)) -4.0))
\begin{array}{l}
\\
\frac{\log \left(\frac{\frac{4}{\mathsf{PI}\left(\right)}}{f}\right)}{\mathsf{PI}\left(\right)} \cdot -4
\end{array}
Initial program 7.9%
lift-neg.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
Applied rewrites97.0%
Taylor expanded in f around 0
Applied rewrites95.6%
(FPCore (f) :precision binary64 (* (/ -4.0 (PI)) (log (/ 4.0 (* (PI) f)))))
\begin{array}{l}
\\
\frac{-4}{\mathsf{PI}\left(\right)} \cdot \log \left(\frac{4}{\mathsf{PI}\left(\right) \cdot f}\right)
\end{array}
Initial program 7.9%
Taylor expanded in f around 0
Applied rewrites95.4%
lift-neg.f64N/A
lift-*.f64N/A
distribute-lft-neg-inN/A
lower-*.f64N/A
Applied rewrites95.4%
Applied rewrites95.4%
herbie shell --seed 2025018
(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)))))))))