
(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 13 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.5
Applied rewrites98.5%
(FPCore (cosTheta alpha) :precision binary32 (/ (+ (* (- alpha 1.0) alpha) (* (- alpha 1.0) 1.0)) (* (* (PI) (* (log alpha) 2.0)) (+ 1.0 (* (* (- (* alpha alpha) 1.0) cosTheta) cosTheta)))))
\begin{array}{l}
\\
\frac{\left(\alpha - 1\right) \cdot \alpha + \left(\alpha - 1\right) \cdot 1}{\left(\mathsf{PI}\left(\right) \cdot \left(\log \alpha \cdot 2\right)\right) \cdot \left(1 + \left(\left(\alpha \cdot \alpha - 1\right) \cdot cosTheta\right) \cdot cosTheta\right)}
\end{array}
Initial program 98.5%
lift--.f32N/A
lift-*.f32N/A
difference-of-sqr-1N/A
*-commutativeN/A
distribute-lft-inN/A
lower-+.f32N/A
lower-*.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower--.f3298.4
Applied rewrites98.4%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f32N/A
lower-log.f3298.5
Applied rewrites98.5%
(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.5
Applied rewrites97.5%
(FPCore (cosTheta alpha) :precision binary32 (/ (- (* alpha alpha) 1.0) (* (* (PI) 2.0) (* (- 1.0 (* cosTheta cosTheta)) (log alpha)))))
\begin{array}{l}
\\
\frac{\alpha \cdot \alpha - 1}{\left(\mathsf{PI}\left(\right) \cdot 2\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.5
Applied rewrites98.5%
Taylor expanded in alpha around 0
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/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.4
Applied rewrites97.4%
(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.8%
(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.7
Applied rewrites94.7%
(FPCore (cosTheta alpha) :precision binary32 (/ -1.0 (* (log (* alpha alpha)) (PI))))
\begin{array}{l}
\\
\frac{-1}{\log \left(\alpha \cdot \alpha\right) \cdot \mathsf{PI}\left(\right)}
\end{array}
Initial program 98.5%
Taylor expanded in alpha around 0
Applied rewrites66.7%
Taylor expanded in cosTheta around 0
*-commutativeN/A
lower-*.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f3265.0
Applied rewrites65.0%
(FPCore (cosTheta alpha) :precision binary32 (/ (fma alpha alpha -1.0) (fma (* (NAN) (* cosTheta cosTheta)) (* (PI) (* alpha alpha)) (* (* (- 1.0 (* cosTheta cosTheta)) (PI)) (NAN)))))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\alpha, \alpha, -1\right)}{\mathsf{fma}\left(\mathsf{NAN}\left(\right) \cdot \left(cosTheta \cdot cosTheta\right), \mathsf{PI}\left(\right) \cdot \left(\alpha \cdot \alpha\right), \left(\left(1 - cosTheta \cdot cosTheta\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{NAN}\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.0
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%
Taylor expanded in alpha around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
associate-*l*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-NAN.f32N/A
unpow2N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
unpow2N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites-0.0%
(FPCore (cosTheta alpha) :precision binary32 (/ (+ (* alpha alpha) -1.0) (fma (* (* (* (PI) (- (* alpha alpha) 1.0)) (NAN)) cosTheta) cosTheta (* (NAN) (PI)))))
\begin{array}{l}
\\
\frac{\alpha \cdot \alpha + -1}{\mathsf{fma}\left(\left(\left(\mathsf{PI}\left(\right) \cdot \left(\alpha \cdot \alpha - 1\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.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
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
lower-NAN.f32N/A
lower-*.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.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
+-commutativeN/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
lower-NAN.f32N/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%
(FPCore (cosTheta alpha) :precision binary32 (/ (fma alpha alpha -1.0) (fma (* (* (* (PI) (- (* alpha alpha) 1.0)) (NAN)) cosTheta) cosTheta (* (NAN) (PI)))))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\alpha, \alpha, -1\right)}{\mathsf{fma}\left(\left(\left(\mathsf{PI}\left(\right) \cdot \left(\alpha \cdot \alpha - 1\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.0
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
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
lower-NAN.f32N/A
lower-*.f32N/A
Applied rewrites-0.0%
Taylor expanded in alpha around 0
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.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
lower-*.f32N/A
lower-NAN.f32N/A
lower-PI.f32-0.0
Applied rewrites-0.0%
herbie shell --seed 2024332
(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)))))