
(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))
(t_1 (/ (PI) -4.0))
(t_2 (exp (* t_0 f)))
(t_3 (exp (* t_0 (- f)))))
(if (<= (* (/ 1.0 t_0) (log (/ (+ t_2 t_3) (- t_2 t_3)))) INFINITY)
(* (/ (log (/ (cosh (* t_1 f)) (sinh (* (* (PI) f) 0.25)))) (PI)) -4.0)
(*
(/ -1.0 t_0)
(log (pow (pow (/ 2.0 (* (* (PI) 0.5) f)) 1.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}\\
t_2 := e^{t\_0 \cdot f}\\
t_3 := e^{t\_0 \cdot \left(-f\right)}\\
\mathbf{if}\;\frac{1}{t\_0} \cdot \log \left(\frac{t\_2 + t\_3}{t\_2 - t\_3}\right) \leq \infty:\\
\;\;\;\;\frac{\log \left(\frac{\cosh \left(t\_1 \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}{t\_0} \cdot \log \left({\left({\left(\frac{2}{\left(\mathsf{PI}\left(\right) \cdot 0.5\right) \cdot f}\right)}^{1}\right)}^{\left({\left(e^{f}\right)}^{t\_1}\right)}\right)\\
\end{array}
\end{array}
if (*.f64 (/.f64 #s(literal 1 binary64) (/.f64 (PI.f64) #s(literal 4 binary64))) (log.f64 (/.f64 (+.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f)))) (-.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f))))))) < +inf.0Initial program 6.9%
lift-neg.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
Applied rewrites99.1%
Taylor expanded in f around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6499.1
Applied rewrites99.1%
if +inf.0 < (*.f64 (/.f64 #s(literal 1 binary64) (/.f64 (PI.f64) #s(literal 4 binary64))) (log.f64 (/.f64 (+.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f)))) (-.f64 (exp.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f)) (exp.f64 (neg.f64 (*.f64 (/.f64 (PI.f64) #s(literal 4 binary64)) f))))))) Initial program 0.0%
Applied rewrites100.0%
Taylor expanded in f around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f64N/A
lower-PI.f64100.0
Applied rewrites100.0%
Taylor expanded in f around 0
Applied rewrites100.0%
Final simplification99.1%
(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 6.8%
Applied rewrites99.0%
Final simplification99.0%
(FPCore (f)
:precision binary64
(let* ((t_0 (/ (PI) 4.0)))
(*
(/ -1.0 t_0)
(log
(pow
(pow (/ 2.0 (* (* (PI) 0.5) f)) (pow (exp f) t_0))
(pow (exp f) (/ (PI) -4.0)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{PI}\left(\right)}{4}\\
\frac{-1}{t\_0} \cdot \log \left({\left({\left(\frac{2}{\left(\mathsf{PI}\left(\right) \cdot 0.5\right) \cdot f}\right)}^{\left({\left(e^{f}\right)}^{t\_0}\right)}\right)}^{\left({\left(e^{f}\right)}^{\left(\frac{\mathsf{PI}\left(\right)}{-4}\right)}\right)}\right)
\end{array}
\end{array}
Initial program 6.8%
Applied rewrites99.0%
Taylor expanded in f around 0
lower-/.f64N/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f64N/A
lower-PI.f6498.0
Applied rewrites98.0%
Final simplification98.0%
(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 6.8%
lift-neg.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
Applied rewrites97.2%
Taylor expanded in f around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6497.2
Applied rewrites97.2%
(FPCore (f) :precision binary64 (/ (log (/ (fma (* (* 0.08333333333333333 (PI)) f) f (/ 4.0 (PI))) f)) (/ (- (PI)) 4.0)))
\begin{array}{l}
\\
\frac{\log \left(\frac{\mathsf{fma}\left(\left(0.08333333333333333 \cdot \mathsf{PI}\left(\right)\right) \cdot f, f, \frac{4}{\mathsf{PI}\left(\right)}\right)}{f}\right)}{\frac{-\mathsf{PI}\left(\right)}{4}}
\end{array}
Initial program 6.8%
Taylor expanded in f around 0
Applied rewrites96.7%
Applied rewrites96.8%
Taylor expanded in f around 0
Applied rewrites96.8%
Final simplification96.8%
(FPCore (f) :precision binary64 (* (/ (- 4.0) (PI)) (log (/ (fma (* 0.08333333333333333 (PI)) (* f f) (/ 4.0 (PI))) f))))
\begin{array}{l}
\\
\frac{-4}{\mathsf{PI}\left(\right)} \cdot \log \left(\frac{\mathsf{fma}\left(0.08333333333333333 \cdot \mathsf{PI}\left(\right), f \cdot f, \frac{4}{\mathsf{PI}\left(\right)}\right)}{f}\right)
\end{array}
Initial program 6.8%
Taylor expanded in f around 0
Applied rewrites96.7%
Taylor expanded in f around inf
Applied rewrites50.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
metadata-evalN/A
lift-/.f6450.5
Applied rewrites50.5%
Taylor expanded in f around 0
Applied rewrites96.7%
Final simplification96.7%
(FPCore (f) :precision binary64 (* (/ (log (/ 2.0 (* (* (PI) 0.5) f))) (PI)) -4.0))
\begin{array}{l}
\\
\frac{\log \left(\frac{2}{\left(\mathsf{PI}\left(\right) \cdot 0.5\right) \cdot f}\right)}{\mathsf{PI}\left(\right)} \cdot -4
\end{array}
Initial program 6.8%
lift-neg.f64N/A
lift-*.f64N/A
lift-/.f64N/A
associate-*l/N/A
Applied rewrites97.2%
Taylor expanded in f around 0
*-commutativeN/A
distribute-rgt-out--N/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
distribute-rgt-out--N/A
mul-1-negN/A
lower-/.f64N/A
mul-1-negN/A
distribute-rgt-out--N/A
metadata-evalN/A
distribute-rgt-neg-inN/A
metadata-evalN/A
metadata-evalN/A
distribute-rgt-out--N/A
lower-*.f64N/A
Applied rewrites96.3%
(FPCore (f) :precision binary64 (* (/ (- 4.0) (PI)) (log (/ 4.0 (* f (PI))))))
\begin{array}{l}
\\
\frac{-4}{\mathsf{PI}\left(\right)} \cdot \log \left(\frac{4}{f \cdot \mathsf{PI}\left(\right)}\right)
\end{array}
Initial program 6.8%
Taylor expanded in f around 0
*-commutativeN/A
associate-/r*N/A
metadata-evalN/A
associate-*r/N/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6496.1
Applied rewrites96.1%
lift-neg.f64N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
lower-*.f64N/A
Applied rewrites96.1%
Applied rewrites96.1%
Final simplification96.1%
(FPCore (f) :precision binary64 (* (/ (- 4.0) (PI)) (log (* (* 0.08333333333333333 (PI)) f))))
\begin{array}{l}
\\
\frac{-4}{\mathsf{PI}\left(\right)} \cdot \log \left(\left(0.08333333333333333 \cdot \mathsf{PI}\left(\right)\right) \cdot f\right)
\end{array}
Initial program 6.8%
Taylor expanded in f around 0
Applied rewrites96.7%
Taylor expanded in f around inf
Applied rewrites50.5%
lift-/.f64N/A
lift-/.f64N/A
associate-/r/N/A
associate-*l/N/A
metadata-evalN/A
lift-/.f6450.5
Applied rewrites50.5%
Taylor expanded in f around inf
Applied rewrites1.6%
Final simplification1.6%
herbie shell --seed 2025017
(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)))))))))