
(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 6 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 (* (* f (PI)) 0.25))) (* (/ (log (/ (cosh t_0) (sinh t_0))) (PI)) -4.0)))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(f \cdot \mathsf{PI}\left(\right)\right) \cdot 0.25\\
\frac{\log \left(\frac{\cosh t\_0}{\sinh t\_0}\right)}{\mathsf{PI}\left(\right)} \cdot -4
\end{array}
\end{array}
Initial program 7.0%
Taylor expanded in f around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.3%
Applied rewrites98.3%
(FPCore (f)
:precision binary64
(let* ((t_0 (* 0.25 (PI))))
(*
(/ -1.0 (/ (PI) 4.0))
(log
(/
(fma (fma -0.25 (PI) (fma (* (* (PI) (PI)) f) 0.0625 t_0)) f 2.0)
(*
(-
(fma (* f f) (* (pow (PI) 3.0) 0.005208333333333333) t_0)
(* -0.25 (PI)))
f))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.25 \cdot \mathsf{PI}\left(\right)\\
\frac{-1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.25, \mathsf{PI}\left(\right), \mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot f, 0.0625, t\_0\right)\right), f, 2\right)}{\left(\mathsf{fma}\left(f \cdot f, {\mathsf{PI}\left(\right)}^{3} \cdot 0.005208333333333333, t\_0\right) - -0.25 \cdot \mathsf{PI}\left(\right)\right) \cdot f}\right)
\end{array}
\end{array}
Initial program 7.0%
Taylor expanded in f around 0
Applied rewrites4.5%
Taylor expanded in f around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites4.1%
Taylor expanded in f around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites97.2%
Final simplification97.2%
(FPCore (f)
:precision binary64
(*
(/ -1.0 (/ (PI) 4.0))
(log
(/
(fma (fma -0.25 (PI) (fma (* (* (PI) (PI)) f) 0.0625 (* 0.25 (PI)))) f 2.0)
(* (sinh (* (* f (PI)) 0.25)) 2.0)))))\begin{array}{l}
\\
\frac{-1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(-0.25, \mathsf{PI}\left(\right), \mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot f, 0.0625, 0.25 \cdot \mathsf{PI}\left(\right)\right)\right), f, 2\right)}{\sinh \left(\left(f \cdot \mathsf{PI}\left(\right)\right) \cdot 0.25\right) \cdot 2}\right)
\end{array}
Initial program 7.0%
Taylor expanded in f around 0
Applied rewrites4.5%
Taylor expanded in f around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites4.1%
Taylor expanded in f around inf
sinh-undefN/A
*-commutativeN/A
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f64N/A
lift-sinh.f64N/A
lift-*.f6497.1
Applied rewrites97.1%
Final simplification97.1%
(FPCore (f)
:precision binary64
(let* ((t_0 (* f (PI))))
(*
(/ -1.0 (/ (PI) 4.0))
(log (/ (+ (exp (* t_0 0.25)) (fma t_0 -0.25 1.0)) (* (* (PI) 0.5) f))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := f \cdot \mathsf{PI}\left(\right)\\
\frac{-1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{e^{t\_0 \cdot 0.25} + \mathsf{fma}\left(t\_0, -0.25, 1\right)}{\left(\mathsf{PI}\left(\right) \cdot 0.5\right) \cdot f}\right)
\end{array}
\end{array}
Initial program 7.0%
Taylor expanded in f around 0
*-commutativeN/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f64N/A
lift-PI.f6496.7
Applied rewrites96.7%
Taylor expanded in f around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lift-PI.f6496.8
Applied rewrites96.8%
Taylor expanded in f around 0
*-commutativeN/A
lift-*.f64N/A
lift-PI.f64N/A
lift-*.f6496.8
Applied rewrites96.8%
Final simplification96.8%
(FPCore (f)
:precision binary64
(*
(/ -1.0 (/ (PI) 4.0))
(log
(/
(+
(fma (fma (* (* (PI) (PI)) f) 0.03125 (* 0.25 (PI))) f 1.0)
(fma (* f (PI)) -0.25 1.0))
(* (* (PI) 0.5) f)))))\begin{array}{l}
\\
\frac{-1}{\frac{\mathsf{PI}\left(\right)}{4}} \cdot \log \left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot f, 0.03125, 0.25 \cdot \mathsf{PI}\left(\right)\right), f, 1\right) + \mathsf{fma}\left(f \cdot \mathsf{PI}\left(\right), -0.25, 1\right)}{\left(\mathsf{PI}\left(\right) \cdot 0.5\right) \cdot f}\right)
\end{array}
Initial program 7.0%
Taylor expanded in f around 0
*-commutativeN/A
lower-*.f64N/A
distribute-rgt-out--N/A
metadata-evalN/A
lower-*.f64N/A
lift-PI.f6496.7
Applied rewrites96.7%
Taylor expanded in f around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
lift-PI.f6496.8
Applied rewrites96.8%
Taylor expanded in f around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
lift-PI.f64N/A
lift-PI.f64N/A
lower-*.f64N/A
lift-PI.f6496.8
Applied rewrites96.8%
Final simplification96.8%
(FPCore (f) :precision binary64 (* (/ (log (/ 4.0 (* f (PI)))) (PI)) -4.0))
\begin{array}{l}
\\
\frac{\log \left(\frac{4}{f \cdot \mathsf{PI}\left(\right)}\right)}{\mathsf{PI}\left(\right)} \cdot -4
\end{array}
Initial program 7.0%
Taylor expanded in f around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites96.7%
Taylor expanded in f around 0
lower-/.f64N/A
lower-*.f64N/A
lift-PI.f6496.7
Applied rewrites96.7%
Final simplification96.7%
herbie shell --seed 2025051
(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)))))))))