
(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
(* (* (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.3%
(FPCore (cosTheta alpha)
:precision binary32
(let* ((t_0 (- (* alpha alpha) 1.0)))
(/
t_0
(* (* (log alpha) (+ (PI) (PI))) (+ 1.0 (* (* t_0 cosTheta) cosTheta))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \alpha \cdot \alpha - 1\\
\frac{t\_0}{\left(\log \alpha \cdot \left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right)\right) \cdot \left(1 + \left(t\_0 \cdot cosTheta\right) \cdot cosTheta\right)}
\end{array}
\end{array}
Initial program 98.3%
lift-*.f32N/A
lift-log.f32N/A
lift-*.f32N/A
log-prodN/A
distribute-rgt-inN/A
distribute-lft-outN/A
lower-*.f32N/A
lower-log.f32N/A
lower-+.f3298.2
Applied rewrites98.2%
(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.3%
Taylor expanded in alpha around 0
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
unpow2N/A
lower-*.f3296.1
Applied rewrites96.1%
(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.3%
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
lift-*.f32N/A
difference-of-sqr-1N/A
associate-*r*N/A
sub-negN/A
distribute-rgt-inN/A
lower-fma.f32N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f32N/A
lower-*.f32N/A
metadata-evalN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f3268.7
Applied rewrites68.7%
Taylor expanded in cosTheta around 0
*-commutativeN/A
lower-*.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f3293.2
Applied rewrites93.2%
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
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
lower-log.f3296.0
Applied rewrites96.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.3%
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
lift-*.f32N/A
difference-of-sqr-1N/A
associate-*r*N/A
sub-negN/A
distribute-rgt-inN/A
lower-fma.f32N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f32N/A
lower-*.f32N/A
metadata-evalN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f3267.8
Applied rewrites68.5%
Taylor expanded in cosTheta around 0
*-commutativeN/A
lower-*.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f3293.2
Applied rewrites93.2%
(FPCore (cosTheta alpha) :precision binary32 (/ (- (* alpha alpha) 1.0) (* (* (log alpha) 2.0) (PI))))
\begin{array}{l}
\\
\frac{\alpha \cdot \alpha - 1}{\left(\log \alpha \cdot 2\right) \cdot \mathsf{PI}\left(\right)}
\end{array}
Initial program 98.3%
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
lift-*.f32N/A
difference-of-sqr-1N/A
associate-*r*N/A
sub-negN/A
distribute-rgt-inN/A
lower-fma.f32N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f32N/A
lower-*.f32N/A
metadata-evalN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f3268.7
Applied rewrites68.6%
Taylor expanded in cosTheta around 0
*-commutativeN/A
lower-*.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f3293.2
Applied rewrites93.2%
Taylor expanded in alpha around 0
Applied rewrites93.1%
(FPCore (cosTheta alpha) :precision binary32 (/ (/ -0.5 (PI)) (log alpha)))
\begin{array}{l}
\\
\frac{\frac{-0.5}{\mathsf{PI}\left(\right)}}{\log \alpha}
\end{array}
Initial program 98.3%
Taylor expanded in alpha around 0
*-commutativeN/A
associate-*r*N/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
lower-log.f3264.3
Applied rewrites64.3%
Taylor expanded in cosTheta around 0
Applied rewrites62.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.3%
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
lift-*.f32N/A
difference-of-sqr-1N/A
associate-*r*N/A
sub-negN/A
distribute-rgt-inN/A
lower-fma.f32N/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f32N/A
lower-*.f32N/A
metadata-evalN/A
distribute-rgt-inN/A
*-lft-identityN/A
lower-fma.f3268.1
Applied rewrites68.1%
Taylor expanded in cosTheta around 0
*-commutativeN/A
lower-*.f32N/A
lower-log.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f3293.2
Applied rewrites93.2%
Taylor expanded in alpha around 0
Applied rewrites62.2%
(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.3%
Taylor expanded in alpha around 0
*-commutativeN/A
associate-*r*N/A
associate-/r*N/A
lower-/.f32N/A
lower-/.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
lower-log.f3264.3
Applied rewrites64.3%
Taylor expanded in cosTheta around 0
Applied rewrites62.2%
(FPCore (cosTheta alpha)
:precision binary32
(fma
(* (- alpha) alpha)
(/ -1.0 (* (* (- 1.0 (* cosTheta cosTheta)) (PI)) (/ 0.0 0.0)))
(/
-1.0
(*
(* (PI) (fma (* cosTheta (fma alpha alpha -1.0)) cosTheta 1.0))
(/ 0.0 0.0)))))\begin{array}{l}
\\
\mathsf{fma}\left(\left(-\alpha\right) \cdot \alpha, \frac{-1}{\left(\left(1 - cosTheta \cdot cosTheta\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \frac{0}{0}}, \frac{-1}{\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(cosTheta \cdot \mathsf{fma}\left(\alpha, \alpha, -1\right), cosTheta, 1\right)\right) \cdot \frac{0}{0}}\right)
\end{array}
Initial program 98.3%
lift-/.f32N/A
lift--.f32N/A
div-subN/A
sub-negN/A
frac-2negN/A
div-invN/A
distribute-frac-neg2N/A
Applied rewrites-0.0%
Taylor expanded in cosTheta around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
sub-negN/A
unpow2N/A
metadata-evalN/A
lower-fma.f32N/A
lower-PI.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32-0.0
Applied rewrites-0.0%
Taylor expanded in alpha around 0
Applied rewrites-0.0%
(FPCore (cosTheta alpha) :precision binary32 (fma (* (- alpha) alpha) (/ -1.0 (* (* (PI) (* (* (* cosTheta cosTheta) alpha) alpha)) (/ 0.0 0.0))) (/ -1.0 (* (* (PI) 1.0) (/ 0.0 0.0)))))
\begin{array}{l}
\\
\mathsf{fma}\left(\left(-\alpha\right) \cdot \alpha, \frac{-1}{\left(\mathsf{PI}\left(\right) \cdot \left(\left(\left(cosTheta \cdot cosTheta\right) \cdot \alpha\right) \cdot \alpha\right)\right) \cdot \frac{0}{0}}, \frac{-1}{\left(\mathsf{PI}\left(\right) \cdot 1\right) \cdot \frac{0}{0}}\right)
\end{array}
Initial program 98.3%
lift-/.f32N/A
lift--.f32N/A
div-subN/A
sub-negN/A
frac-2negN/A
div-invN/A
distribute-frac-neg2N/A
Applied rewrites-0.0%
Taylor expanded in alpha around inf
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32-0.0
Applied rewrites-0.0%
Taylor expanded in cosTheta around 0
Applied rewrites-0.0%
(FPCore (cosTheta alpha)
:precision binary32
(fma
(* (- alpha) alpha)
(/ -1.0 (* (PI) (/ 0.0 0.0)))
(/
-1.0
(*
(* (PI) (fma (* cosTheta (fma alpha alpha -1.0)) cosTheta 1.0))
(/ 0.0 0.0)))))\begin{array}{l}
\\
\mathsf{fma}\left(\left(-\alpha\right) \cdot \alpha, \frac{-1}{\mathsf{PI}\left(\right) \cdot \frac{0}{0}}, \frac{-1}{\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(cosTheta \cdot \mathsf{fma}\left(\alpha, \alpha, -1\right), cosTheta, 1\right)\right) \cdot \frac{0}{0}}\right)
\end{array}
Initial program 98.3%
lift-/.f32N/A
lift--.f32N/A
div-subN/A
sub-negN/A
frac-2negN/A
div-invN/A
distribute-frac-neg2N/A
Applied rewrites-0.0%
Taylor expanded in cosTheta around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
sub-negN/A
unpow2N/A
metadata-evalN/A
lower-fma.f32N/A
lower-PI.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32-0.0
Applied rewrites-0.0%
Taylor expanded in cosTheta around 0
Applied rewrites-0.0%
(FPCore (cosTheta alpha) :precision binary32 (fma (* (- alpha) alpha) (/ -1.0 (* (* (PI) 1.0) (/ 0.0 0.0))) (/ -1.0 (* (* (PI) (fma (* cosTheta -1.0) cosTheta 1.0)) (/ 0.0 0.0)))))
\begin{array}{l}
\\
\mathsf{fma}\left(\left(-\alpha\right) \cdot \alpha, \frac{-1}{\left(\mathsf{PI}\left(\right) \cdot 1\right) \cdot \frac{0}{0}}, \frac{-1}{\left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(cosTheta \cdot -1, cosTheta, 1\right)\right) \cdot \frac{0}{0}}\right)
\end{array}
Initial program 98.3%
lift-/.f32N/A
lift--.f32N/A
div-subN/A
sub-negN/A
frac-2negN/A
div-invN/A
distribute-frac-neg2N/A
Applied rewrites-0.0%
Taylor expanded in alpha around 0
Applied rewrites-0.0%
Taylor expanded in cosTheta around 0
Applied rewrites-0.0%
(FPCore (cosTheta alpha) :precision binary32 (/ -1.0 (* (PI) (/ 0.0 0.0))))
\begin{array}{l}
\\
\frac{-1}{\mathsf{PI}\left(\right) \cdot \frac{0}{0}}
\end{array}
Initial program 98.3%
lift--.f32N/A
sub-negN/A
lift-*.f32N/A
lower-fma.f32N/A
metadata-eval12.1
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-PI.f32-0.0
Applied rewrites-0.0%
Taylor expanded in alpha around 0
Applied rewrites-0.0%
herbie shell --seed 2024271
(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)))))