
(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 15 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 (* uy (PI))))
(*
(sqrt (* (- (- 2.0 (* (pow (- maxCos 1.0) 2.0) ux)) (* maxCos 2.0)) ux))
(* (cos t_0) (* 2.0 (sin t_0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := uy \cdot \mathsf{PI}\left(\right)\\
\sqrt{\left(\left(2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) - maxCos \cdot 2\right) \cdot ux} \cdot \left(\cos t\_0 \cdot \left(2 \cdot \sin t\_0\right)\right)
\end{array}
\end{array}
Initial program 55.8%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3255.9
lift-*.f32N/A
*-commutativeN/A
lower-*.f3255.9
Applied rewrites55.9%
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-lft-inN/A
lower-+.f32N/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
lower-neg.f3216.9
Applied rewrites16.9%
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
*-commutativeN/A
lower-*.f3298.3
Applied rewrites98.3%
lift-sin.f32N/A
lift-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f32N/A
2-sinN/A
lift-sin.f32N/A
lift-cos.f32N/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f3298.4
Applied rewrites98.4%
Final simplification98.4%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (- 2.0 (- (* (pow (- maxCos 1.0) 2.0) ux) (* -2.0 maxCos))) ux)) (sin (* (* 2.0 uy) (PI)))))
\begin{array}{l}
\\
\sqrt{\left(2 - \left({\left(maxCos - 1\right)}^{2} \cdot ux - -2 \cdot maxCos\right)\right) \cdot ux} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)
\end{array}
Initial program 55.8%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3255.9
lift-*.f32N/A
*-commutativeN/A
lower-*.f3255.9
Applied rewrites55.9%
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-lft-inN/A
lower-+.f32N/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
lower-neg.f3216.9
Applied rewrites16.9%
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
*-commutativeN/A
lower-*.f3298.3
Applied rewrites98.3%
Applied rewrites98.3%
Final simplification98.3%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* (+ uy uy) (PI))) (sqrt (* (- (- 2.0 (* (pow (- maxCos 1.0) 2.0) ux)) (* maxCos 2.0)) ux))))
\begin{array}{l}
\\
\sin \left(\left(uy + uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) - maxCos \cdot 2\right) \cdot ux}
\end{array}
Initial program 55.8%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3255.9
lift-*.f32N/A
*-commutativeN/A
lower-*.f3255.9
Applied rewrites55.9%
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-lft-inN/A
lower-+.f32N/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
lower-neg.f3216.9
Applied rewrites16.9%
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
*-commutativeN/A
lower-*.f3298.3
Applied rewrites98.3%
lift-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
*-commutativeN/A
lift-*.f32N/A
count-2N/A
lift-*.f32N/A
lift-*.f32N/A
distribute-lft-outN/A
lower-*.f32N/A
lower-+.f3298.3
Applied rewrites98.3%
Final simplification98.3%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sqrt
(-
(- ux (* (- (* (- 1.0 ux) ux) (- (* ux ux) ux)) maxCos))
(* (- ux 1.0) ux)))
(sin (* (* 2.0 uy) (PI)))))\begin{array}{l}
\\
\sqrt{\left(ux - \left(\left(1 - ux\right) \cdot ux - \left(ux \cdot ux - ux\right)\right) \cdot maxCos\right) - \left(ux - 1\right) \cdot ux} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)
\end{array}
Initial program 55.8%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3255.9
lift-*.f32N/A
*-commutativeN/A
lower-*.f3255.9
Applied rewrites55.9%
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-lft-inN/A
lower-+.f32N/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
lower-neg.f3216.9
Applied rewrites16.9%
Taylor expanded in maxCos around 0
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
Applied rewrites97.6%
Final simplification97.6%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sqrt
(-
(* (fma maxCos ux (- 1.0 ux)) (- ux (* ux maxCos)))
(- (* ux maxCos) ux)))
(sin (* (* 2.0 uy) (PI)))))\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot \left(ux - ux \cdot maxCos\right) - \left(ux \cdot maxCos - ux\right)} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)
\end{array}
Initial program 55.8%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3255.9
lift-*.f32N/A
*-commutativeN/A
lower-*.f3255.9
Applied rewrites55.9%
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-lft-inN/A
lower-+.f32N/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
lower-neg.f3216.9
Applied rewrites16.9%
lift--.f32N/A
lift-+.f32N/A
associate--r+N/A
*-rgt-identityN/A
lift-*.f32N/A
lower-*.f32N/A
*-commutativeN/A
lift-neg.f32N/A
cancel-sign-subN/A
*-commutativeN/A
lower-+.f32N/A
Applied rewrites43.7%
Final simplification44.5%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (- (- 2.0 (* (fma -2.0 ux 2.0) maxCos)) ux) ux)) (sin (* (* 2.0 uy) (PI)))))
\begin{array}{l}
\\
\sqrt{\left(\left(2 - \mathsf{fma}\left(-2, ux, 2\right) \cdot maxCos\right) - ux\right) \cdot ux} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)
\end{array}
Initial program 55.8%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3255.9
lift-*.f32N/A
*-commutativeN/A
lower-*.f3255.9
Applied rewrites55.9%
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-lft-inN/A
lower-+.f32N/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
lower-neg.f3216.9
Applied rewrites16.9%
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
*-commutativeN/A
lower-*.f3298.3
Applied rewrites98.3%
Taylor expanded in maxCos around 0
Applied rewrites83.1%
Final simplification83.3%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (- -1.0 (- (* ux maxCos) ux))))
(if (<= ux 0.00026000000070780516)
(* (sqrt (* 2.0 ux)) (sin (* (* 2.0 uy) (PI))))
(* (sqrt (- 1.0 (* t_0 t_0))) (* 2.0 (* uy (PI)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 - \left(ux \cdot maxCos - ux\right)\\
\mathbf{if}\;ux \leq 0.00026000000070780516:\\
\;\;\;\;\sqrt{2 \cdot ux} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - t\_0 \cdot t\_0} \cdot \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\\
\end{array}
\end{array}
if ux < 2.60000001e-4Initial program 38.2%
lift-+.f32N/A
lift--.f32N/A
flip--N/A
metadata-evalN/A
div-subN/A
associate-+l-N/A
lower--.f32N/A
lower-/.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower--.f32N/A
lower-/.f32N/A
lower-*.f32N/A
+-commutativeN/A
lower-+.f3237.9
lift-*.f32N/A
*-commutativeN/A
lower-*.f3237.9
Applied rewrites37.9%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3236.8
Applied rewrites36.8%
Taylor expanded in maxCos around 0
Applied rewrites87.9%
if 2.60000001e-4 < ux Initial program 92.0%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3292.2
lift-*.f32N/A
*-commutativeN/A
lower-*.f3292.2
Applied rewrites92.2%
lift-+.f32N/A
lift--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate--r-N/A
lift--.f32N/A
lift--.f3292.2
Applied rewrites92.2%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3275.0
Applied rewrites75.0%
Final simplification83.6%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (- 2.0 ux) ux)) (sin (* (* 2.0 uy) (PI)))))
\begin{array}{l}
\\
\sqrt{\left(2 - ux\right) \cdot ux} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)
\end{array}
Initial program 55.8%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3255.9
lift-*.f32N/A
*-commutativeN/A
lower-*.f3255.9
Applied rewrites55.9%
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-lft-inN/A
lower-+.f32N/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
lower-neg.f3216.9
Applied rewrites16.9%
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
*-commutativeN/A
lower-*.f3298.3
Applied rewrites98.3%
Taylor expanded in maxCos around 0
Applied rewrites92.7%
Final simplification92.7%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (- -1.0 (- (* ux maxCos) ux))))
(if (<= (- (* ux maxCos) (- ux 1.0)) 0.9997950196266174)
(* (sqrt (- 1.0 (* t_0 t_0))) (* 2.0 (* uy (PI))))
(* (sqrt (* (* (- (/ 2.0 maxCos) 2.0) maxCos) ux)) (* (* 2.0 (PI)) uy)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := -1 - \left(ux \cdot maxCos - ux\right)\\
\mathbf{if}\;ux \cdot maxCos - \left(ux - 1\right) \leq 0.9997950196266174:\\
\;\;\;\;\sqrt{1 - t\_0 \cdot t\_0} \cdot \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(\frac{2}{maxCos} - 2\right) \cdot maxCos\right) \cdot ux} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.99979502Initial program 91.1%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3291.3
lift-*.f32N/A
*-commutativeN/A
lower-*.f3291.3
Applied rewrites91.3%
lift-+.f32N/A
lift--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate--r-N/A
lift--.f32N/A
lift--.f3291.3
Applied rewrites91.3%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3273.4
Applied rewrites73.4%
if 0.99979502 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 37.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3234.2
Applied rewrites34.2%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3276.2
Applied rewrites76.2%
Taylor expanded in maxCos around inf
Applied rewrites78.7%
Final simplification76.9%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* 2.0 (PI)) uy)) (t_1 (- (* ux maxCos) (- ux 1.0))))
(if (<= t_1 0.9997950196266174)
(* (sqrt (+ (* (- -1.0 (- (* ux maxCos) ux)) t_1) 1.0)) t_0)
(* (sqrt (* (* (- (/ 2.0 maxCos) 2.0) maxCos) ux)) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
t_1 := ux \cdot maxCos - \left(ux - 1\right)\\
\mathbf{if}\;t\_1 \leq 0.9997950196266174:\\
\;\;\;\;\sqrt{\left(-1 - \left(ux \cdot maxCos - ux\right)\right) \cdot t\_1 + 1} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(\frac{2}{maxCos} - 2\right) \cdot maxCos\right) \cdot ux} \cdot t\_0\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.99979502Initial program 91.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3273.3
Applied rewrites73.3%
lift-+.f32N/A
lift--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate--r-N/A
lift--.f32N/A
lift--.f3273.4
Applied rewrites73.4%
if 0.99979502 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 37.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3234.2
Applied rewrites34.2%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3276.2
Applied rewrites76.2%
Taylor expanded in maxCos around inf
Applied rewrites78.7%
Final simplification76.9%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (- (- ux 1.0) (* ux maxCos))) (t_1 (* (* 2.0 (PI)) uy)))
(if (<= (- (* ux maxCos) (- ux 1.0)) 0.9997950196266174)
(* (sqrt (- 1.0 (* t_0 t_0))) t_1)
(* (sqrt (* (* (- (/ 2.0 maxCos) 2.0) maxCos) ux)) t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(ux - 1\right) - ux \cdot maxCos\\
t_1 := \left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
\mathbf{if}\;ux \cdot maxCos - \left(ux - 1\right) \leq 0.9997950196266174:\\
\;\;\;\;\sqrt{1 - t\_0 \cdot t\_0} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(\frac{2}{maxCos} - 2\right) \cdot maxCos\right) \cdot ux} \cdot t\_1\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.99979502Initial program 91.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3273.3
Applied rewrites73.3%
if 0.99979502 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 37.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3234.2
Applied rewrites34.2%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3276.2
Applied rewrites76.2%
Taylor expanded in maxCos around inf
Applied rewrites78.7%
Final simplification76.8%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* 2.0 (PI)) uy)) (t_1 (- (* ux maxCos) (- ux 1.0))))
(if (<= t_1 0.999750018119812)
(* (sqrt (- 1.0 (* (- 1.0 ux) t_1))) t_0)
(* (sqrt (* (* (- (/ 2.0 maxCos) 2.0) maxCos) ux)) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
t_1 := ux \cdot maxCos - \left(ux - 1\right)\\
\mathbf{if}\;t\_1 \leq 0.999750018119812:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot t\_1} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(\frac{2}{maxCos} - 2\right) \cdot maxCos\right) \cdot ux} \cdot t\_0\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999750018Initial program 92.0%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3274.2
Applied rewrites74.2%
Taylor expanded in maxCos around 0
lower--.f3269.7
Applied rewrites69.7%
if 0.999750018 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 38.2%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3234.6
Applied rewrites34.6%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3275.4
Applied rewrites75.4%
Taylor expanded in maxCos around inf
Applied rewrites78.0%
Final simplification75.3%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* 2.0 (PI)) uy)) (t_1 (- (* ux maxCos) (- ux 1.0))))
(if (<= t_1 0.999750018119812)
(* (sqrt (- 1.0 (* (- 1.0 ux) t_1))) t_0)
(* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
t_1 := ux \cdot maxCos - \left(ux - 1\right)\\
\mathbf{if}\;t\_1 \leq 0.999750018119812:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot t\_1} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot t\_0\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999750018Initial program 92.0%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3274.2
Applied rewrites74.2%
Taylor expanded in maxCos around 0
lower--.f3269.7
Applied rewrites69.7%
if 0.999750018 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 38.2%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3234.6
Applied rewrites34.6%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3275.4
Applied rewrites75.4%
Applied rewrites78.0%
Final simplification75.3%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) (* (* 2.0 (PI)) uy)))
\begin{array}{l}
\\
\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)
\end{array}
Initial program 55.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3247.6
Applied rewrites47.6%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3265.3
Applied rewrites65.3%
Applied rewrites67.3%
Final simplification67.3%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* 2.0 ux)) (* (+ uy uy) (PI))))
\begin{array}{l}
\\
\sqrt{2 \cdot ux} \cdot \left(\left(uy + uy\right) \cdot \mathsf{PI}\left(\right)\right)
\end{array}
Initial program 55.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3247.6
Applied rewrites47.6%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3265.3
Applied rewrites65.3%
Taylor expanded in maxCos around 0
Applied rewrites65.3%
Applied rewrites65.3%
Final simplification65.3%
herbie shell --seed 2024244
(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)))))))