
(FPCore (cosTheta alpha)
:precision binary32
(let* ((t_0 (- (* alpha alpha) 1.0)))
(/
t_0
(* (* (PI) (log (* alpha alpha))) (+ 1.0 (* (* t_0 cosTheta) cosTheta))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \alpha \cdot \alpha - 1\\
\frac{t\_0}{\left(\mathsf{PI}\left(\right) \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(t\_0 \cdot cosTheta\right) \cdot cosTheta\right)}
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (cosTheta alpha)
:precision binary32
(let* ((t_0 (- (* alpha alpha) 1.0)))
(/
t_0
(* (* (PI) (log (* alpha alpha))) (+ 1.0 (* (* t_0 cosTheta) cosTheta))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \alpha \cdot \alpha - 1\\
\frac{t\_0}{\left(\mathsf{PI}\left(\right) \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(t\_0 \cdot cosTheta\right) \cdot cosTheta\right)}
\end{array}
\end{array}
(FPCore (cosTheta alpha)
:precision binary32
(let* ((t_0 (- (* alpha alpha) 1.0)))
(/
t_0
(*
(log (pow (* alpha alpha) (PI)))
(+ 1.0 (* (* t_0 cosTheta) cosTheta))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \alpha \cdot \alpha - 1\\
\frac{t\_0}{\log \left({\left(\alpha \cdot \alpha\right)}^{\mathsf{PI}\left(\right)}\right) \cdot \left(1 + \left(t\_0 \cdot cosTheta\right) \cdot cosTheta\right)}
\end{array}
\end{array}
Initial program 98.5%
lift-*.f32N/A
*-commutativeN/A
lift-PI.f32N/A
add-log-expN/A
log-pow-revN/A
lower-log.f32N/A
lift-PI.f32N/A
pow-expN/A
*-commutativeN/A
lift-log.f32N/A
pow-to-expN/A
lower-pow.f3298.6
Applied rewrites98.6%
(FPCore (cosTheta alpha)
:precision binary32
(let* ((t_0 (- (* alpha alpha) 1.0)))
(/
t_0
(* (* (PI) (log (* alpha alpha))) (+ 1.0 (* (* t_0 cosTheta) cosTheta))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \alpha \cdot \alpha - 1\\
\frac{t\_0}{\left(\mathsf{PI}\left(\right) \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 + \left(t\_0 \cdot cosTheta\right) \cdot cosTheta\right)}
\end{array}
\end{array}
Initial program 98.5%
(FPCore (cosTheta alpha) :precision binary32 (/ (- (* alpha alpha) 1.0) (* (* (PI) (log (* alpha alpha))) (- 1.0 (* cosTheta cosTheta)))))
\begin{array}{l}
\\
\frac{\alpha \cdot \alpha - 1}{\left(\mathsf{PI}\left(\right) \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \left(1 - cosTheta \cdot cosTheta\right)}
\end{array}
Initial program 98.5%
Taylor expanded in alpha around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f32N/A
unpow2N/A
lower-*.f3297.6
Applied rewrites97.6%
(FPCore (cosTheta alpha) :precision binary32 (/ (- (* alpha alpha) 1.0) (* (* 2.0 (PI)) (* (- 1.0 (* cosTheta cosTheta)) (log alpha)))))
\begin{array}{l}
\\
\frac{\alpha \cdot \alpha - 1}{\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\left(1 - cosTheta \cdot cosTheta\right) \cdot \log \alpha\right)}
\end{array}
Initial program 98.5%
lift-*.f32N/A
*-commutativeN/A
lift-PI.f32N/A
add-log-expN/A
log-pow-revN/A
lower-log.f32N/A
lift-PI.f32N/A
pow-expN/A
*-commutativeN/A
lift-log.f32N/A
pow-to-expN/A
lower-pow.f3298.6
Applied rewrites98.6%
Taylor expanded in alpha around 0
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f32N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
lower-log.f3297.6
Applied rewrites97.6%
(FPCore (cosTheta alpha) :precision binary32 (/ (/ (- (* alpha alpha) 1.0) (PI)) (log (* alpha alpha))))
\begin{array}{l}
\\
\frac{\frac{\alpha \cdot \alpha - 1}{\mathsf{PI}\left(\right)}}{\log \left(\alpha \cdot \alpha\right)}
\end{array}
Initial program 98.5%
Taylor expanded in cosTheta around 0
associate-/r*N/A
lower-/.f32N/A
lower-/.f32N/A
unpow2N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f32N/A
lower-PI.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f328.9
Applied rewrites9.0%
Taylor expanded in cosTheta around 0
associate-/r*N/A
lower-/.f32N/A
lower-/.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f3294.6
Applied rewrites94.6%
(FPCore (cosTheta alpha) :precision binary32 (/ (- (* alpha alpha) 1.0) (* (* (PI) (log (* alpha alpha))) 1.0)))
\begin{array}{l}
\\
\frac{\alpha \cdot \alpha - 1}{\left(\mathsf{PI}\left(\right) \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot 1}
\end{array}
Initial program 98.5%
Taylor expanded in cosTheta around 0
Applied rewrites94.5%
(FPCore (cosTheta alpha) :precision binary32 (/ (- (* alpha alpha) 1.0) (* (* (log alpha) (PI)) 2.0)))
\begin{array}{l}
\\
\frac{\alpha \cdot \alpha - 1}{\left(\log \alpha \cdot \mathsf{PI}\left(\right)\right) \cdot 2}
\end{array}
Initial program 98.5%
lift-*.f32N/A
lift-log.f32N/A
lift-*.f32N/A
pow2N/A
log-powN/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-log.f3298.4
Applied rewrites98.4%
Taylor expanded in cosTheta around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-log.f32N/A
lower-PI.f3294.5
Applied rewrites94.5%
(FPCore (cosTheta alpha) :precision binary32 (/ (/ -1.0 (PI)) (log (* alpha alpha))))
\begin{array}{l}
\\
\frac{\frac{-1}{\mathsf{PI}\left(\right)}}{\log \left(\alpha \cdot \alpha\right)}
\end{array}
Initial program 98.5%
Taylor expanded in cosTheta around 0
associate-/r*N/A
lower-/.f32N/A
lower-/.f32N/A
unpow2N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f32N/A
lower-PI.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f3210.7
Applied rewrites9.6%
Taylor expanded in alpha around 0
Applied rewrites65.3%
(FPCore (cosTheta alpha) :precision binary32 (/ -0.5 (* (log alpha) (PI))))
\begin{array}{l}
\\
\frac{-0.5}{\log \alpha \cdot \mathsf{PI}\left(\right)}
\end{array}
Initial program 98.5%
Taylor expanded in cosTheta around 0
associate-/r*N/A
lower-/.f32N/A
lower-/.f32N/A
unpow2N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f32N/A
lower-PI.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f329.8
Applied rewrites9.4%
Taylor expanded in alpha around 0
Applied rewrites65.3%
(FPCore (cosTheta alpha)
:precision binary32
(fma
(/ -1.0 (* (* cosTheta cosTheta) alpha))
(/ (- alpha) (* (/ 0.0 0.0) (PI)))
(/
-1.0
(fma
(* (* (* (- (* alpha alpha) 1.0) (PI)) (NAN)) cosTheta)
cosTheta
(* (NAN) (PI))))))\begin{array}{l}
\\
\mathsf{fma}\left(\frac{-1}{\left(cosTheta \cdot cosTheta\right) \cdot \alpha}, \frac{-\alpha}{\frac{0}{0} \cdot \mathsf{PI}\left(\right)}, \frac{-1}{\mathsf{fma}\left(\left(\left(\left(\alpha \cdot \alpha - 1\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{NAN}\left(\right)\right) \cdot cosTheta, cosTheta, \mathsf{NAN}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}\right)
\end{array}
Initial program 98.5%
Applied rewrites-0.0%
Taylor expanded in cosTheta around 0
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f32N/A
Applied rewrites-0.0%
Taylor expanded in alpha around inf
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32-0.0
Applied rewrites-0.0%
(FPCore (cosTheta alpha) :precision binary32 (fma (/ 1.0 (PI)) (/ (* alpha alpha) (/ 0.0 0.0)) (/ -1.0 (* (* (PI) 1.0) (/ 0.0 0.0)))))
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{1}{\mathsf{PI}\left(\right)}, \frac{\alpha \cdot \alpha}{\frac{0}{0}}, \frac{-1}{\left(\mathsf{PI}\left(\right) \cdot 1\right) \cdot \frac{0}{0}}\right)
\end{array}
Initial program 98.5%
Applied rewrites-0.0%
Taylor expanded in cosTheta around 0
Applied rewrites-0.0%
Taylor expanded in cosTheta around 0
lower-PI.f32-0.0
Applied rewrites-0.0%
(FPCore (cosTheta alpha) :precision binary32 (/ (+ (* alpha alpha) -1.0) (fma (* (* (* (- (* alpha alpha) 1.0) (PI)) (NAN)) cosTheta) cosTheta (* (NAN) (PI)))))
\begin{array}{l}
\\
\frac{\alpha \cdot \alpha + -1}{\mathsf{fma}\left(\left(\left(\left(\alpha \cdot \alpha - 1\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{NAN}\left(\right)\right) \cdot cosTheta, cosTheta, \mathsf{NAN}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}
\end{array}
Initial program 98.5%
lift--.f32N/A
lift-*.f32N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f3211.6
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
Applied rewrites-0.0%
Taylor expanded in cosTheta around 0
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f32N/A
Applied rewrites-0.0%
lift-fma.f32N/A
lift-*.f32N/A
lower-+.f32-0.0
Applied rewrites-0.0%
(FPCore (cosTheta alpha) :precision binary32 (/ (fma alpha alpha -1.0) (fma (* (* (* (- (* alpha alpha) 1.0) (PI)) (NAN)) cosTheta) cosTheta (* (NAN) (PI)))))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\alpha, \alpha, -1\right)}{\mathsf{fma}\left(\left(\left(\left(\alpha \cdot \alpha - 1\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{NAN}\left(\right)\right) \cdot cosTheta, cosTheta, \mathsf{NAN}\left(\right) \cdot \mathsf{PI}\left(\right)\right)}
\end{array}
Initial program 98.5%
lift--.f32N/A
lift-*.f32N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f3210.8
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
Applied rewrites-0.0%
Taylor expanded in cosTheta around 0
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f32N/A
Applied rewrites-0.0%
Taylor expanded in cosTheta around 0
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f32N/A
Applied rewrites-0.0%
(FPCore (cosTheta alpha) :precision binary32 (/ (fma alpha alpha -1.0) (* (NAN) (PI))))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\alpha, \alpha, -1\right)}{\mathsf{NAN}\left(\right) \cdot \mathsf{PI}\left(\right)}
\end{array}
Initial program 98.5%
lift--.f32N/A
lift-*.f32N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f3211.4
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
Applied rewrites-0.0%
Taylor expanded in cosTheta around 0
lower-*.f32N/A
lower-NAN.f32N/A
lower-PI.f32-0.0
Applied rewrites-0.0%
herbie shell --seed 2024337
(FPCore (cosTheta alpha)
:name "GTR1 distribution"
:precision binary32
:pre (and (and (<= 0.0 cosTheta) (<= cosTheta 1.0)) (and (<= 0.0001 alpha) (<= alpha 1.0)))
(/ (- (* alpha alpha) 1.0) (* (* (PI) (log (* alpha alpha))) (+ 1.0 (* (* (- (* alpha alpha) 1.0) cosTheta) cosTheta)))))