
(FPCore (ux uy maxCos) :precision binary32 (let* ((t_0 (+ (- 1.0 ux) (* ux maxCos)))) (* (sin (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* t_0 t_0))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (ux uy maxCos) :precision binary32 (let* ((t_0 (+ (- 1.0 ux) (* ux maxCos)))) (* (sin (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* t_0 t_0))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\end{array}
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (* uy 2.0) (PI)))))
(if (<= maxCos 3.4999999343199306e-8)
(* t_0 (sqrt (+ ux (* (- 1.0 ux) ux))))
(*
t_0
(sqrt
(*
(-
(*
(* ux ux)
(+
(/ (- (/ 2.0 ux) 1.0) (* maxCos maxCos))
(/ (- 2.0 (/ 2.0 ux)) maxCos)))
(* ux ux))
(* maxCos maxCos)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)\\
\mathbf{if}\;maxCos \leq 3.4999999343199306 \cdot 10^{-8}:\\
\;\;\;\;t\_0 \cdot \sqrt{ux + \left(1 - ux\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{\left(\left(ux \cdot ux\right) \cdot \left(\frac{\frac{2}{ux} - 1}{maxCos \cdot maxCos} + \frac{2 - \frac{2}{ux}}{maxCos}\right) - ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)}\\
\end{array}
\end{array}
if maxCos < 3.49999993e-8Initial program 61.2%
lift-*.f32N/A
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
associate-+l+N/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-+.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
neg-mul-1N/A
lift-*.f32N/A
*-commutativeN/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites21.9%
Taylor expanded in maxCos around 0
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3298.4
Applied rewrites98.4%
if 3.49999993e-8 < maxCos Initial program 53.9%
lift-*.f32N/A
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
associate-+l+N/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-+.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
neg-mul-1N/A
lift-*.f32N/A
*-commutativeN/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites18.4%
Taylor expanded in ux around -inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.1%
Taylor expanded in maxCos around inf
Applied rewrites98.3%
Final simplification98.4%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (- (- 2.0 (* (pow (- maxCos 1.0) 2.0) ux)) (* 2.0 maxCos)) ux)) (sin (* (PI) (* uy 2.0)))))
\begin{array}{l}
\\
\sqrt{\left(\left(2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) - 2 \cdot maxCos\right) \cdot ux} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(uy \cdot 2\right)\right)
\end{array}
Initial program 59.9%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites60.8%
lift-*.f32N/A
*-commutativeN/A
lower-*.f3260.8
Applied rewrites62.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
lower-*.f3298.3
Applied rewrites98.3%
Final simplification98.3%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sqrt (PI))))
(if (<= (* uy 2.0) 0.017999999225139618)
(*
(* (* (* uy 2.0) t_0) t_0)
(sqrt
(-
(* (- (/ 2.0 ux) (- (/ maxCos ux) (- maxCos 1.0))) (* ux ux))
(* (* (fma maxCos ux (- 1.0 ux)) ux) maxCos))))
(* (sin (* (* (PI) 2.0) uy)) (sqrt (* (fma -2.0 maxCos 2.0) ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\mathbf{if}\;uy \cdot 2 \leq 0.017999999225139618:\\
\;\;\;\;\left(\left(\left(uy \cdot 2\right) \cdot t\_0\right) \cdot t\_0\right) \cdot \sqrt{\left(\frac{2}{ux} - \left(\frac{maxCos}{ux} - \left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot ux\right) - \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot ux\right) \cdot maxCos}\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.0179999992Initial program 61.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3259.7
Applied rewrites59.7%
Applied rewrites59.7%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
associate--r+N/A
lower--.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
Applied rewrites36.1%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3292.5
Applied rewrites92.1%
if 0.0179999992 < (*.f32 uy #s(literal 2 binary32)) Initial program 53.7%
lift-*.f32N/A
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
associate-+l+N/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-+.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
neg-mul-1N/A
lift-*.f32N/A
*-commutativeN/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites10.6%
Taylor expanded in ux around -inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites97.9%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lower-sin.f32N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f326.4
Applied rewrites6.4%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* (* uy 2.0) (PI))) (sqrt (+ ux (* (- 1.0 ux) ux)))))
\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux + \left(1 - ux\right) \cdot ux}
\end{array}
Initial program 59.9%
lift-*.f32N/A
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
associate-+l+N/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-+.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
neg-mul-1N/A
lift-*.f32N/A
*-commutativeN/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites20.3%
Taylor expanded in maxCos around 0
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3293.0
Applied rewrites93.0%
Final simplification93.0%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sqrt (PI))))
(*
(* (* (* uy 2.0) t_0) t_0)
(sqrt
(-
(* (- (/ 2.0 ux) (- (/ maxCos ux) (- maxCos 1.0))) (* ux ux))
(* (* (fma maxCos ux (- 1.0 ux)) ux) maxCos))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\left(\left(\left(uy \cdot 2\right) \cdot t\_0\right) \cdot t\_0\right) \cdot \sqrt{\left(\frac{2}{ux} - \left(\frac{maxCos}{ux} - \left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot ux\right) - \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot ux\right) \cdot maxCos}
\end{array}
\end{array}
Initial program 59.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.6
Applied rewrites51.6%
Applied rewrites51.6%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
associate--r+N/A
lower--.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
Applied rewrites27.3%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3278.3
Applied rewrites78.3%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sqrt (PI))))
(*
(* (* (* uy 2.0) t_0) t_0)
(sqrt
(*
(-
(/ 2.0 ux)
(- (fma (/ maxCos ux) 2.0 (* (- maxCos 1.0) maxCos)) (- maxCos 1.0)))
(* ux ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\left(\left(\left(uy \cdot 2\right) \cdot t\_0\right) \cdot t\_0\right) \cdot \sqrt{\left(\frac{2}{ux} - \left(\mathsf{fma}\left(\frac{maxCos}{ux}, 2, \left(maxCos - 1\right) \cdot maxCos\right) - \left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot ux\right)}
\end{array}
\end{array}
Initial program 59.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.6
Applied rewrites51.6%
Applied rewrites51.6%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
associate--r+N/A
lower--.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
Applied rewrites28.4%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites75.0%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))) (t_1 (* (* (PI) 2.0) uy)))
(if (<= (- 1.0 (* t_0 t_0)) 0.0005000000237487257)
(* t_1 (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)))
(* t_1 (sqrt (- 1.0 (* (- 1.0 (* (- 1.0 maxCos) ux)) (- 1.0 ux))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
t_1 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
\mathbf{if}\;1 - t\_0 \cdot t\_0 \leq 0.0005000000237487257:\\
\;\;\;\;t\_1 \cdot \sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \sqrt{1 - \left(1 - \left(1 - maxCos\right) \cdot ux\right) \cdot \left(1 - ux\right)}\\
\end{array}
\end{array}
if (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))) < 5.00000024e-4Initial program 38.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3232.9
Applied rewrites32.9%
Taylor expanded in maxCos around 0
lower--.f3232.5
Applied rewrites32.5%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f3268.7
Applied rewrites62.3%
Applied rewrites72.4%
if 5.00000024e-4 < (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))) Initial program 90.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3278.4
Applied rewrites78.4%
Taylor expanded in maxCos around 0
lower--.f3277.0
Applied rewrites77.0%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift--.f32N/A
+-lft-identityN/A
lift-+.f32N/A
lower--.f3277.0
lift-+.f32N/A
+-lft-identity77.0
lift--.f32N/A
lift-*.f32N/A
cancel-sign-sub-invN/A
distribute-rgt1-inN/A
metadata-evalN/A
distribute-neg-inN/A
metadata-evalN/A
sub-negN/A
lift--.f32N/A
lift--.f32N/A
sub-negN/A
metadata-evalN/A
+-commutativeN/A
distribute-neg-inN/A
metadata-evalN/A
sub-negN/A
lift--.f32N/A
lower-*.f3277.0
Applied rewrites77.0%
Final simplification74.3%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))) (t_1 (* (* (PI) 2.0) uy)))
(if (<= (- 1.0 (* t_0 t_0)) 0.0005000000237487257)
(* t_1 (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)))
(* t_1 (sqrt (- 1.0 (* t_0 (- 1.0 ux))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
t_1 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
\mathbf{if}\;1 - t\_0 \cdot t\_0 \leq 0.0005000000237487257:\\
\;\;\;\;t\_1 \cdot \sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \sqrt{1 - t\_0 \cdot \left(1 - ux\right)}\\
\end{array}
\end{array}
if (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))) < 5.00000024e-4Initial program 38.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3232.9
Applied rewrites32.9%
Taylor expanded in maxCos around 0
lower--.f3232.5
Applied rewrites32.5%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f3268.7
Applied rewrites57.0%
Applied rewrites72.4%
if 5.00000024e-4 < (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))) Initial program 90.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3278.4
Applied rewrites78.4%
Taylor expanded in maxCos around 0
lower--.f3277.0
Applied rewrites77.0%
Final simplification74.3%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))) (t_1 (* (* (PI) 2.0) uy)))
(if (<= t_0 0.9999200105667114)
(* t_1 (sqrt (- 1.0 (* (- 1.0 (- ux (* maxCos ux))) t_0))))
(* t_1 (sqrt (* (+ (* -2.0 maxCos) 2.0) ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
t_1 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
\mathbf{if}\;t\_0 \leq 0.9999200105667114:\\
\;\;\;\;t\_1 \cdot \sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux}\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999920011Initial program 89.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3277.4
Applied rewrites77.4%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3277.5
lift-*.f32N/A
*-commutativeN/A
lower-*.f3277.5
Applied rewrites77.5%
if 0.999920011 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 37.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3231.8
Applied rewrites31.8%
Taylor expanded in maxCos around 0
lower--.f3231.3
Applied rewrites31.3%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f3269.1
Applied rewrites69.1%
Applied rewrites72.9%
Final simplification74.9%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))) (t_1 (* (* (PI) 2.0) uy)))
(if (<= t_0 0.9999200105667114)
(* t_1 (sqrt (- 1.0 (* t_0 t_0))))
(* t_1 (sqrt (* (+ (* -2.0 maxCos) 2.0) ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
t_1 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
\mathbf{if}\;t\_0 \leq 0.9999200105667114:\\
\;\;\;\;t\_1 \cdot \sqrt{1 - t\_0 \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux}\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999920011Initial program 89.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3277.4
Applied rewrites77.4%
if 0.999920011 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 37.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3231.8
Applied rewrites31.8%
Taylor expanded in maxCos around 0
lower--.f3231.3
Applied rewrites31.3%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f3269.1
Applied rewrites69.1%
Applied rewrites72.9%
Final simplification74.9%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)))
(if (<= (+ (- 1.0 ux) (* ux maxCos)) 0.9998000264167786)
(* t_0 (sqrt (- 1.0 (* (- 1.0 ux) (- 1.0 ux)))))
(* t_0 (sqrt (* (+ (* -2.0 maxCos) 2.0) ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
\mathbf{if}\;\left(1 - ux\right) + ux \cdot maxCos \leq 0.9998000264167786:\\
\;\;\;\;t\_0 \cdot \sqrt{1 - \left(1 - ux\right) \cdot \left(1 - ux\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux}\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999800026Initial program 90.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3278.4
Applied rewrites78.4%
Taylor expanded in maxCos around 0
lower--.f3277.0
Applied rewrites77.0%
Taylor expanded in maxCos around 0
lower--.f3276.7
Applied rewrites76.7%
if 0.999800026 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 38.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3232.9
Applied rewrites32.9%
Taylor expanded in maxCos around 0
lower--.f3232.5
Applied rewrites32.5%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f3268.7
Applied rewrites60.1%
Applied rewrites72.4%
Final simplification74.2%
(FPCore (ux uy maxCos) :precision binary32 (* (* (* (PI) 2.0) uy) (sqrt (* (+ (* -2.0 maxCos) 2.0) ux))))
\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux}
\end{array}
Initial program 59.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.6
Applied rewrites51.6%
Taylor expanded in maxCos around 0
lower--.f3250.7
Applied rewrites50.7%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f3259.8
Applied rewrites59.6%
Applied rewrites62.0%
Final simplification62.0%
(FPCore (ux uy maxCos) :precision binary32 (* (* (* (PI) 2.0) uy) (sqrt (* 2.0 ux))))
\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{2 \cdot ux}
\end{array}
Initial program 59.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.6
Applied rewrites51.6%
Taylor expanded in maxCos around 0
lower--.f3250.7
Applied rewrites50.7%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f3259.8
Applied rewrites59.6%
Taylor expanded in maxCos around 0
Applied rewrites59.8%
Final simplification59.8%
herbie shell --seed 2024314
(FPCore (ux uy maxCos)
:name "UniformSampleCone, y"
:precision binary32
:pre (and (and (and (<= 2.328306437e-10 ux) (<= ux 1.0)) (and (<= 2.328306437e-10 uy) (<= uy 1.0))) (and (<= 0.0 maxCos) (<= maxCos 1.0)))
(* (sin (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (+ (- 1.0 ux) (* ux maxCos)))))))