
(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 10 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 (/ (fma alpha alpha -1.0) (* (* (fma (* cosTheta cosTheta) (fma alpha alpha -1.0) 1.0) (PI)) (* 2.0 (log alpha)))))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\alpha, \alpha, -1\right)}{\left(\mathsf{fma}\left(cosTheta \cdot cosTheta, \mathsf{fma}\left(\alpha, \alpha, -1\right), 1\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \left(2 \cdot \log \alpha\right)}
\end{array}
Initial program 98.5%
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.5
Applied rewrites98.5%
Taylor expanded in alpha around 0
unpow2N/A
difference-of-sqr-1-revN/A
difference-of-sqr--1-revN/A
lower-fma.f3298.4
Applied rewrites98.4%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f32N/A
lower-log.f3298.5
Applied rewrites98.5%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3298.6
lift-fma.f32N/A
*-commutativeN/A
lower-fma.f3298.6
Applied rewrites98.6%
(FPCore (cosTheta alpha) :precision binary32 (/ (fma alpha alpha -1.0) (* (* (PI) (* (log alpha) 2.0)) (fma (fma alpha alpha -1.0) (* cosTheta cosTheta) 1.0))))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\alpha, \alpha, -1\right)}{\left(\mathsf{PI}\left(\right) \cdot \left(\log \alpha \cdot 2\right)\right) \cdot \mathsf{fma}\left(\mathsf{fma}\left(\alpha, \alpha, -1\right), cosTheta \cdot cosTheta, 1\right)}
\end{array}
Initial program 98.5%
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.5
Applied rewrites98.5%
Taylor expanded in alpha around 0
unpow2N/A
difference-of-sqr-1-revN/A
difference-of-sqr--1-revN/A
lower-fma.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 (/ (- (* alpha alpha) 1.0) (* (* (- 1.0 (* cosTheta cosTheta)) (* 2.0 (PI))) (log alpha))))
\begin{array}{l}
\\
\frac{\alpha \cdot \alpha - 1}{\left(\left(1 - cosTheta \cdot cosTheta\right) \cdot \left(2 \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \log \alpha}
\end{array}
Initial program 98.5%
lift-*.f32N/A
lift-log.f32N/A
lift-*.f32N/A
log-prodN/A
distribute-rgt-inN/A
lift-PI.f32N/A
add-cube-cbrtN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-log.f32N/A
pow2N/A
lower-pow.f32N/A
lift-PI.f32N/A
lower-cbrt.f32N/A
lift-PI.f32N/A
lower-cbrt.f32N/A
lower-*.f32N/A
lower-log.f3298.5
Applied rewrites98.5%
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%
Applied rewrites97.6%
(FPCore (cosTheta alpha) :precision binary32 (/ (- (* alpha alpha) 1.0) (* (* (log alpha) (PI)) (fma -2.0 (* cosTheta cosTheta) 2.0))))
\begin{array}{l}
\\
\frac{\alpha \cdot \alpha - 1}{\left(\log \alpha \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{fma}\left(-2, cosTheta \cdot cosTheta, 2\right)}
\end{array}
Initial program 98.5%
lift-*.f32N/A
lift-log.f32N/A
lift-*.f32N/A
log-prodN/A
distribute-rgt-inN/A
lift-PI.f32N/A
add-cube-cbrtN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-log.f32N/A
pow2N/A
lower-pow.f32N/A
lift-PI.f32N/A
lower-cbrt.f32N/A
lift-PI.f32N/A
lower-cbrt.f32N/A
lower-*.f32N/A
lower-log.f3298.5
Applied rewrites98.5%
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%
Taylor expanded in cosTheta around 0
Applied rewrites97.6%
(FPCore (cosTheta alpha) :precision binary32 (/ (fma alpha alpha -1.0) (* (* 2.0 (PI)) (* (- 1.0 (* cosTheta cosTheta)) (log alpha)))))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\alpha, \alpha, -1\right)}{\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-*.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.5
Applied rewrites98.5%
Taylor expanded in alpha around 0
unpow2N/A
difference-of-sqr-1-revN/A
difference-of-sqr--1-revN/A
lower-fma.f3298.4
Applied rewrites98.4%
Taylor expanded in alpha around 0
*-commutativeN/A
lower-*.f32N/A
lower-log.f3298.5
Applied rewrites98.5%
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) (* (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.5%
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.5
Applied rewrites98.5%
Taylor expanded in cosTheta around 0
*-commutativeN/A
lower-*.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f3295.3
Applied rewrites95.3%
(FPCore (cosTheta alpha) :precision binary32 (/ (fma alpha alpha -1.0) (* (* (log alpha) 2.0) (PI))))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\alpha, \alpha, -1\right)}{\left(\log \alpha \cdot 2\right) \cdot \mathsf{PI}\left(\right)}
\end{array}
Initial program 98.5%
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.5
Applied rewrites98.5%
Taylor expanded in alpha around 0
unpow2N/A
difference-of-sqr-1-revN/A
difference-of-sqr--1-revN/A
lower-fma.f3298.4
Applied rewrites98.4%
Taylor expanded in cosTheta around 0
*-commutativeN/A
lower-*.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f3295.2
Applied rewrites95.2%
Applied rewrites95.3%
(FPCore (cosTheta alpha) :precision binary32 (/ (fma alpha alpha -1.0) (* (log (* alpha alpha)) (PI))))
\begin{array}{l}
\\
\frac{\mathsf{fma}\left(\alpha, \alpha, -1\right)}{\log \left(\alpha \cdot \alpha\right) \cdot \mathsf{PI}\left(\right)}
\end{array}
Initial program 98.5%
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.5
Applied rewrites98.5%
Taylor expanded in alpha around 0
unpow2N/A
difference-of-sqr-1-revN/A
difference-of-sqr--1-revN/A
lower-fma.f3298.4
Applied rewrites98.4%
Taylor expanded in cosTheta around 0
*-commutativeN/A
lower-*.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f3295.2
Applied rewrites95.2%
(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%
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.5
Applied rewrites98.5%
Taylor expanded in alpha around 0
unpow2N/A
difference-of-sqr-1-revN/A
difference-of-sqr--1-revN/A
lower-fma.f3298.4
Applied rewrites98.4%
Taylor expanded in cosTheta around 0
*-commutativeN/A
lower-*.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f3295.2
Applied rewrites95.2%
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.5%
lift--.f32N/A
lift-*.f32N/A
difference-of-sqr-1N/A
difference-of-sqr--1-revN/A
lower-fma.f3298.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 2024353
(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)))))