
(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 9 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
(/
(- (* alpha alpha) 1.0)
(log
(pow
(* alpha alpha)
(* (fma (* (fma alpha alpha -1.0) cosTheta) cosTheta 1.0) (PI))))))\begin{array}{l}
\\
\frac{\alpha \cdot \alpha - 1}{\log \left({\left(\alpha \cdot \alpha\right)}^{\left(\mathsf{fma}\left(\mathsf{fma}\left(\alpha, \alpha, -1\right) \cdot cosTheta, cosTheta, 1\right) \cdot \mathsf{PI}\left(\right)\right)}\right)}
\end{array}
Initial program 98.7%
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-fma.f32N/A
lift--.f32N/A
lift-*.f32N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f32N/A
lower-*.f3298.7
Applied rewrites98.7%
Taylor expanded in cosTheta around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-*.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
Applied rewrites98.7%
Taylor expanded in cosTheta around 0
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
unpow2N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f32N/A
Applied rewrites98.7%
Applied rewrites98.8%
(FPCore (cosTheta alpha) :precision binary32 (/ (- (* alpha alpha) 1.0) (* (* (PI) (log (* alpha alpha))) (fma (fma alpha alpha -1.0) (* cosTheta cosTheta) 1.0))))
\begin{array}{l}
\\
\frac{\alpha \cdot \alpha - 1}{\left(\mathsf{PI}\left(\right) \cdot \log \left(\alpha \cdot \alpha\right)\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\alpha, \alpha, -1\right), cosTheta \cdot cosTheta, 1\right)}
\end{array}
Initial program 98.7%
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-fma.f32N/A
lift--.f32N/A
lift-*.f32N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f32N/A
lower-*.f3298.7
Applied rewrites98.7%
(FPCore (cosTheta alpha) :precision binary32 (/ (fma alpha alpha -1.0) (* (* (fma (* (fma alpha alpha -1.0) cosTheta) cosTheta 1.0) (PI)) (log (* alpha alpha)))))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\alpha, \alpha, -1\right)}{\left(\mathsf{fma}\left(\mathsf{fma}\left(\alpha, \alpha, -1\right) \cdot cosTheta, cosTheta, 1\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \log \left(\alpha \cdot \alpha\right)}
\end{array}
Initial program 98.7%
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-fma.f32N/A
lift--.f32N/A
lift-*.f32N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f32N/A
lower-*.f3298.7
Applied rewrites98.7%
Taylor expanded in cosTheta around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-*.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
Applied rewrites98.7%
Taylor expanded in cosTheta around 0
+-commutativeN/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
unpow2N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f32N/A
Applied rewrites98.7%
Applied rewrites98.6%
(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.7%
Taylor expanded in alpha around 0
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f32N/A
unpow2N/A
lower-*.f3298.1
Applied rewrites98.1%
(FPCore (cosTheta alpha) :precision binary32 (/ (fma alpha alpha -1.0) (* (* -2.0 (PI)) (* (fma cosTheta cosTheta -1.0) (log alpha)))))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\alpha, \alpha, -1\right)}{\left(-2 \cdot \mathsf{PI}\left(\right)\right) \cdot \left(\mathsf{fma}\left(cosTheta, cosTheta, -1\right) \cdot \log \alpha\right)}
\end{array}
Initial program 98.7%
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.7
Applied rewrites98.7%
Taylor expanded in alpha around inf
distribute-lft-outN/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
Applied rewrites98.2%
Taylor expanded in alpha around 0
unpow2N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f3298.3
Applied rewrites98.3%
Taylor expanded in alpha around 0
Applied rewrites98.0%
(FPCore (cosTheta alpha) :precision binary32 (/ (- (* alpha alpha) 1.0) (* (log (* alpha alpha)) (PI))))
\begin{array}{l}
\\
\frac{\alpha \cdot \alpha - 1}{\log \left(\alpha \cdot \alpha\right) \cdot \mathsf{PI}\left(\right)}
\end{array}
Initial program 98.7%
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-fma.f32N/A
lift--.f32N/A
lift-*.f32N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f32N/A
lower-*.f3298.7
Applied rewrites98.7%
Taylor expanded in cosTheta around 0
*-commutativeN/A
lower-*.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f3296.1
Applied rewrites96.1%
(FPCore (cosTheta alpha) :precision binary32 (/ (fma alpha alpha -1.0) (* (* (log alpha) (PI)) 2.0)))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\alpha, \alpha, -1\right)}{\left(\log \alpha \cdot \mathsf{PI}\left(\right)\right) \cdot 2}
\end{array}
Initial program 98.7%
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.7
Applied rewrites98.7%
Taylor expanded in alpha around inf
distribute-lft-outN/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
Applied rewrites98.2%
Taylor expanded in alpha around 0
unpow2N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f3298.3
Applied rewrites98.3%
Taylor expanded in cosTheta around 0
Applied rewrites96.0%
(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.7%
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-fma.f32N/A
lift--.f32N/A
lift-*.f32N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f32N/A
lower-*.f3298.7
Applied rewrites98.7%
Taylor expanded in cosTheta around 0
*-commutativeN/A
lower-*.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f3296.1
Applied rewrites96.1%
Taylor expanded in alpha around 0
Applied rewrites66.6%
(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.7%
lift--.f32N/A
lift-*.f32N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f3298.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
lower-*.f32N/A
lower-NAN.f32N/A
lower-PI.f32-0.0
Applied rewrites-0.0%
herbie shell --seed 2024360
(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)))))