
(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 5 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 (/ 2.0 (sqrt (PI))))) (* (* (log (tanh (/ f (/ 4.0 (PI))))) t_0) t_0)))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{2}{\sqrt{\mathsf{PI}\left(\right)}}\\
\left(\log \tanh \left(\frac{f}{\frac{4}{\mathsf{PI}\left(\right)}}\right) \cdot t\_0\right) \cdot t\_0
\end{array}
\end{array}
Initial program 6.5%
lift-neg.f64N/A
lift-*.f64N/A
distribute-rgt-neg-inN/A
lift-/.f64N/A
inv-powN/A
sqr-powN/A
Applied rewrites99.4%
lift-pow.f64N/A
unpow1/2N/A
lift-/.f64N/A
sqrt-divN/A
metadata-evalN/A
lift-PI.f64N/A
lower-/.f64N/A
lift-PI.f64N/A
lower-sqrt.f6499.4
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.4
Applied rewrites99.4%
Final simplification99.4%
(FPCore (f) :precision binary64 (let* ((t_0 (* 0.25 (PI)))) (/ (log (tanh (* t_0 f))) t_0)))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.25 \cdot \mathsf{PI}\left(\right)\\
\frac{\log \tanh \left(t\_0 \cdot f\right)}{t\_0}
\end{array}
\end{array}
Initial program 6.5%
lift-neg.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
Applied rewrites99.4%
Final simplification99.4%
(FPCore (f)
:precision binary64
(*
(/ -1.0 (/ (PI) 4.0))
(log
(/
(fma
(* (fma -2.0 (* 0.020833333333333332 (PI)) (* 0.125 (PI))) 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{fma}\left(-2, 0.020833333333333332 \cdot \mathsf{PI}\left(\right), 0.125 \cdot \mathsf{PI}\left(\right)\right) \cdot f, f, \frac{4}{\mathsf{PI}\left(\right)}\right)}{f}\right)
\end{array}
Initial program 6.5%
Taylor expanded in f around 0
Applied rewrites97.3%
Final simplification97.3%
(FPCore (f) :precision binary64 (/ (log (* (* f (PI)) 0.25)) (* 0.25 (PI))))
\begin{array}{l}
\\
\frac{\log \left(\left(f \cdot \mathsf{PI}\left(\right)\right) \cdot 0.25\right)}{0.25 \cdot \mathsf{PI}\left(\right)}
\end{array}
Initial program 6.5%
lift-neg.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
Applied rewrites99.4%
Taylor expanded in f around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6496.8
Applied rewrites96.8%
Final simplification96.8%
(FPCore (f) :precision binary64 (* (log (* (* 0.25 (PI)) f)) (/ 4.0 (PI))))
\begin{array}{l}
\\
\log \left(\left(0.25 \cdot \mathsf{PI}\left(\right)\right) \cdot f\right) \cdot \frac{4}{\mathsf{PI}\left(\right)}
\end{array}
Initial program 6.5%
lift-neg.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-/.f64N/A
un-div-invN/A
Applied rewrites99.4%
Taylor expanded in f around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-PI.f6496.8
Applied rewrites96.8%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
div-invN/A
associate-*r/N/A
associate-/r*N/A
lift-*.f64N/A
lift-/.f64N/A
*-commutativeN/A
lower-*.f6496.6
Applied rewrites96.6%
Final simplification96.6%
herbie shell --seed 2024308
(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)))))))))