
(FPCore (f) :precision binary32 (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 binary32 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (f) :precision binary32 (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 binary32
(let* ((t_0 (* f (PI)))
(t_1 (sinh (* t_0 0.25)))
(t_2 (log t_1))
(t_3 (* 0.25 t_0))
(t_4 (log (cosh (* t_0 -0.25)))))
(if (<= f 10.0)
(/ (* (log (/ (cosh t_3) (sinh t_3))) -4.0) (PI))
(/
(*
(/
(- (pow (log (* f (* 0.5 (* (PI) 0.5)))) 3.0))
(fma t_4 t_4 (fma t_2 t_2 (log (pow t_1 t_4)))))
-4.0)
(PI)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := f \cdot \mathsf{PI}\left(\right)\\
t_1 := \sinh \left(t\_0 \cdot 0.25\right)\\
t_2 := \log t\_1\\
t_3 := 0.25 \cdot t\_0\\
t_4 := \log \cosh \left(t\_0 \cdot -0.25\right)\\
\mathbf{if}\;f \leq 10:\\
\;\;\;\;\frac{\log \left(\frac{\cosh t\_3}{\sinh t\_3}\right) \cdot -4}{\mathsf{PI}\left(\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{-{\log \left(f \cdot \left(0.5 \cdot \left(\mathsf{PI}\left(\right) \cdot 0.5\right)\right)\right)}^{3}}{\mathsf{fma}\left(t\_4, t\_4, \mathsf{fma}\left(t\_2, t\_2, \log \left({t\_1}^{t\_4}\right)\right)\right)} \cdot -4}{\mathsf{PI}\left(\right)}\\
\end{array}
\end{array}
if f < 10Initial program 22.9%
Taylor expanded in f around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites97.9%
Applied rewrites97.9%
if 10 < f Initial program 5.2%
Taylor expanded in f around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites5.2%
Applied rewrites5.2%
lift-log.f32N/A
lift-/.f32N/A
lift-cosh.f32N/A
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
lift-sinh.f32N/A
lift-*.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
diff-logN/A
Applied rewrites5.2%
Taylor expanded in f around 0
mul-1-negN/A
lower-neg.f32N/A
lower-pow.f32N/A
Applied rewrites95.6%
(FPCore (f) :precision binary32 (let* ((t_0 (* 0.25 (* f (PI))))) (/ (* (log (/ (cosh t_0) (sinh t_0))) -4.0) (PI))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.25 \cdot \left(f \cdot \mathsf{PI}\left(\right)\right)\\
\frac{\log \left(\frac{\cosh t\_0}{\sinh t\_0}\right) \cdot -4}{\mathsf{PI}\left(\right)}
\end{array}
\end{array}
Initial program 20.0%
Taylor expanded in f around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites82.7%
Applied rewrites82.7%
(FPCore (f) :precision binary32 (let* ((t_0 (* f (PI)))) (* (log (/ (cosh (* t_0 -0.25)) (sinh (* t_0 0.25)))) (/ -4.0 (PI)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := f \cdot \mathsf{PI}\left(\right)\\
\log \left(\frac{\cosh \left(t\_0 \cdot -0.25\right)}{\sinh \left(t\_0 \cdot 0.25\right)}\right) \cdot \frac{-4}{\mathsf{PI}\left(\right)}
\end{array}
\end{array}
Initial program 20.0%
Taylor expanded in f around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites82.7%
Applied rewrites82.7%
Applied rewrites82.4%
(FPCore (f) :precision binary32 (* (/ -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 20.0%
Taylor expanded in f around 0
Applied rewrites80.2%
Taylor expanded in f around 0
*-commutativeN/A
lower-fma.f32N/A
distribute-rgt-outN/A
lower-*.f32N/A
lift-PI.f32N/A
metadata-evalN/A
unpow2N/A
lower-*.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
lift-PI.f3280.2
Applied rewrites80.2%
Final simplification80.2%
(FPCore (f) :precision binary32 (* (/ (- (log (* 0.25 (* f (PI))))) (PI)) -4.0))
\begin{array}{l}
\\
\frac{-\log \left(0.25 \cdot \left(f \cdot \mathsf{PI}\left(\right)\right)\right)}{\mathsf{PI}\left(\right)} \cdot -4
\end{array}
Initial program 20.0%
Taylor expanded in f around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites82.7%
Applied rewrites82.6%
Taylor expanded in f around 0
mul-1-negN/A
lower-neg.f32N/A
+-commutativeN/A
sum-logN/A
lower-log.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
distribute-rgt-out--N/A
metadata-evalN/A
*-commutativeN/A
lift-*.f32N/A
lift-PI.f3278.3
Applied rewrites78.3%
Taylor expanded in f around 0
lower-*.f32N/A
lift-*.f32N/A
lift-PI.f3278.3
Applied rewrites78.3%
herbie shell --seed 2025054
(FPCore (f)
:name "VandenBroeck and Keller, Equation (20)"
:precision binary32
(- (* (/ 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)))))))))