
(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 16 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
(*
(sqrt
(*
(* ux ux)
(-
(- (- (/ 1.0 ux) (pow (- 1.0 maxCos) 2.0)) (/ (- maxCos 1.0) ux))
(/ maxCos ux))))
(sin (* (PI) (* 2.0 uy)))))\begin{array}{l}
\\
\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\frac{1}{ux} - {\left(1 - maxCos\right)}^{2}\right) - \frac{maxCos - 1}{ux}\right) - \frac{maxCos}{ux}\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 58.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 rewrites20.8%
Taylor expanded in maxCos around 0
lower--.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3256.9
Applied rewrites56.9%
Taylor expanded in ux around -inf
Applied rewrites98.4%
Final simplification98.4%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sqrt
(*
(*
(-
(- (- (/ 1.0 ux) (pow (- 1.0 maxCos) 2.0)) (/ (- maxCos 1.0) ux))
(/ maxCos ux))
ux)
ux))
(sin (* (PI) (* 2.0 uy)))))\begin{array}{l}
\\
\sqrt{\left(\left(\left(\left(\frac{1}{ux} - {\left(1 - maxCos\right)}^{2}\right) - \frac{maxCos - 1}{ux}\right) - \frac{maxCos}{ux}\right) \cdot ux\right) \cdot ux} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 58.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 rewrites19.7%
Taylor expanded in maxCos around 0
lower--.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3256.9
Applied rewrites56.9%
Taylor expanded in ux around -inf
Applied rewrites98.4%
Applied rewrites98.3%
Final simplification98.3%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sqrt
(*
(-
(- (/ 1.0 ux) (* (+ (- maxCos 1.0) maxCos) (/ 1.0 ux)))
(pow (- 1.0 maxCos) 2.0))
(* ux ux)))
(sin (* (PI) (* 2.0 uy)))))\begin{array}{l}
\\
\sqrt{\left(\left(\frac{1}{ux} - \left(\left(maxCos - 1\right) + maxCos\right) \cdot \frac{1}{ux}\right) - {\left(1 - maxCos\right)}^{2}\right) \cdot \left(ux \cdot ux\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 58.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 rewrites20.9%
Taylor expanded in ux around -inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.3%
Applied rewrites98.3%
Final simplification98.3%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (- (/ (+ (* -2.0 maxCos) 2.0) ux) (pow (- maxCos 1.0) 2.0)) (* ux ux))) (sin (* (PI) (* 2.0 uy)))))
\begin{array}{l}
\\
\sqrt{\left(\frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \left(ux \cdot ux\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 58.7%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
associate--r+N/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-subN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f32N/A
lower-/.f32N/A
+-commutativeN/A
lower-fma.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3220.2
Applied rewrites21.8%
Applied rewrites98.3%
Final simplification98.3%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (* (- (/ (- (- 2.0 maxCos) maxCos) ux) (pow (- 1.0 maxCos) 2.0)) ux) ux)) (sin (* (PI) (* 2.0 uy)))))
\begin{array}{l}
\\
\sqrt{\left(\left(\frac{\left(2 - maxCos\right) - maxCos}{ux} - {\left(1 - maxCos\right)}^{2}\right) \cdot ux\right) \cdot ux} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 58.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 rewrites21.3%
Taylor expanded in ux around -inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.3%
Applied rewrites98.2%
Final simplification98.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (- (+ -1.0 ux) (* ux maxCos))))
(if (<= (- 1.0 (* t_0 t_0)) 0.0009740000241436064)
(* (sqrt (* (fma -2.0 maxCos 2.0) ux)) (sin (* (PI) (* 2.0 uy))))
(*
(sqrt
(-
1.0
(*
(* (- (- maxCos 1.0) (/ -1.0 ux)) ux)
(- (* ux maxCos) (+ -1.0 ux)))))
(* (* (PI) 2.0) uy)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(-1 + ux\right) - ux \cdot maxCos\\
\mathbf{if}\;1 - t\_0 \cdot t\_0 \leq 0.0009740000241436064:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\left(\left(maxCos - 1\right) - \frac{-1}{ux}\right) \cdot ux\right) \cdot \left(ux \cdot maxCos - \left(-1 + ux\right)\right)} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\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)))) < 9.74000024e-4Initial program 38.4%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
associate--r+N/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-subN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f32N/A
lower-/.f32N/A
+-commutativeN/A
lower-fma.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3217.6
Applied rewrites18.6%
Taylor expanded in ux around 0
Applied rewrites31.0%
if 9.74000024e-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.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3278.1
Applied rewrites78.1%
Taylor expanded in ux around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f32N/A
lower-neg.f32N/A
lower--.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f3278.1
Applied rewrites78.1%
Final simplification80.7%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sqrt
(-
(* (* (- 1.0 maxCos) ux) (fma maxCos ux (- 1.0 ux)))
(- (* ux maxCos) ux)))
(sin (* (PI) (* 2.0 uy)))))\begin{array}{l}
\\
\sqrt{\left(\left(1 - maxCos\right) \cdot ux\right) \cdot \mathsf{fma}\left(maxCos, ux, 1 - ux\right) - \left(ux \cdot maxCos - ux\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 58.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 rewrites21.2%
lift--.f32N/A
lift-+.f32N/A
associate--r+N/A
lift-*.f32N/A
lift-fma.f32N/A
+-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
cancel-sign-sub-invN/A
lower-+.f32N/A
Applied rewrites49.1%
Final simplification50.2%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sqrt
(-
(- ux (* ux maxCos))
(* (* (fma maxCos ux (- 1.0 ux)) ux) (- maxCos 1.0))))
(sin (* (PI) (* 2.0 uy)))))\begin{array}{l}
\\
\sqrt{\left(ux - ux \cdot maxCos\right) - \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot ux\right) \cdot \left(maxCos - 1\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 58.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 rewrites20.1%
lift--.f32N/A
lift-+.f32N/A
associate--r+N/A
lower--.f32N/A
lift-fma.f32N/A
+-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
lift--.f32N/A
associate-+l-N/A
associate--r-N/A
metadata-evalN/A
lower-+.f32N/A
lower--.f3248.4
lift-*.f32N/A
*-commutativeN/A
lower-*.f3249.7
lift-*.f32N/A
lift-*.f32N/A
associate-*r*N/A
lift-+.f32N/A
+-commutativeN/A
metadata-evalN/A
Applied rewrites48.8%
Final simplification49.3%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (PI) (* 2.0 uy)))))
(if (<= maxCos 1.4999999621068127e-5)
(* (sqrt (+ (* (- 1.0 ux) ux) ux)) t_0)
(* (sqrt (* (+ (+ -2.0 maxCos) maxCos) (- ux))) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\mathbf{if}\;maxCos \leq 1.4999999621068127 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{\left(1 - ux\right) \cdot ux + ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(-2 + maxCos\right) + maxCos\right) \cdot \left(-ux\right)} \cdot t\_0\\
\end{array}
\end{array}
if maxCos < 1.49999996e-5Initial program 61.1%
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.4%
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--.f3297.6
Applied rewrites97.6%
if 1.49999996e-5 < maxCos Initial program 48.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 rewrites13.4%
Taylor expanded in ux around -inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.4%
Applied rewrites98.1%
Taylor expanded in ux around 0
Applied rewrites83.7%
Final simplification95.0%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (+ (* (- 1.0 ux) ux) ux)) (sin (* (PI) (* 2.0 uy)))))
\begin{array}{l}
\\
\sqrt{\left(1 - ux\right) \cdot ux + ux} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 58.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 rewrites20.8%
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--.f3289.9
Applied rewrites89.9%
Final simplification89.9%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy))
(t_1 (- (+ -1.0 ux) (* ux maxCos)))
(t_2 (- 1.0 (* t_1 t_1))))
(if (<= t_2 0.00019999999494757503)
(* (sqrt (* (* (- (/ 2.0 maxCos) 2.0) maxCos) ux)) t_0)
(* (sqrt t_2) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
t_1 := \left(-1 + ux\right) - ux \cdot maxCos\\
t_2 := 1 - t\_1 \cdot t\_1\\
\mathbf{if}\;t\_2 \leq 0.00019999999494757503:\\
\;\;\;\;\sqrt{\left(\left(\frac{2}{maxCos} - 2\right) \cdot maxCos\right) \cdot ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{t\_2} \cdot t\_0\\
\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)))) < 1.99999995e-4Initial program 34.2%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3231.6
Applied rewrites31.6%
Taylor expanded in maxCos around 0
lower--.f3230.9
Applied rewrites30.9%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f3270.4
Applied rewrites50.2%
Taylor expanded in maxCos around inf
Applied rewrites76.3%
if 1.99999995e-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 88.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3276.0
Applied rewrites76.0%
Final simplification76.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)))
(if (<= (- (* ux maxCos) (+ -1.0 ux)) 0.9998300075531006)
(* (sqrt (- 1.0 (- (- 1.0 (* (- 1.0 ux) ux)) ux))) t_0)
(* (sqrt (* (* (- (/ 2.0 maxCos) 2.0) maxCos) ux)) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
\mathbf{if}\;ux \cdot maxCos - \left(-1 + ux\right) \leq 0.9998300075531006:\\
\;\;\;\;\sqrt{1 - \left(\left(1 - \left(1 - ux\right) \cdot ux\right) - ux\right)} \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.999830008Initial program 89.1%
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 rewrites33.7%
Taylor expanded in maxCos around 0
lower--.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3286.9
Applied rewrites86.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3274.4
Applied rewrites74.4%
if 0.999830008 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 34.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3231.9
Applied rewrites31.9%
Taylor expanded in maxCos around 0
lower--.f3231.1
Applied rewrites31.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f3270.1
Applied rewrites66.3%
Taylor expanded in maxCos around inf
Applied rewrites75.9%
Final simplification75.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)))
(if (<= (- (* ux maxCos) (+ -1.0 ux)) 0.9998300075531006)
(* (sqrt (- 1.0 (- (- 1.0 (* (- 1.0 ux) ux)) ux))) t_0)
(* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
\mathbf{if}\;ux \cdot maxCos - \left(-1 + ux\right) \leq 0.9998300075531006:\\
\;\;\;\;\sqrt{1 - \left(\left(1 - \left(1 - ux\right) \cdot ux\right) - ux\right)} \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.999830008Initial program 89.1%
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 rewrites33.2%
Taylor expanded in maxCos around 0
lower--.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3286.9
Applied rewrites86.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3274.4
Applied rewrites74.4%
if 0.999830008 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 34.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3231.9
Applied rewrites31.9%
Taylor expanded in maxCos around 0
lower--.f3231.1
Applied rewrites31.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f3270.1
Applied rewrites62.9%
Applied rewrites75.9%
Final simplification75.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)))
(if (<= (- (* ux maxCos) (+ -1.0 ux)) 0.9998300075531006)
(* (sqrt (- 1.0 (* (- 1.0 ux) (- 1.0 ux)))) t_0)
(* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
\mathbf{if}\;ux \cdot maxCos - \left(-1 + ux\right) \leq 0.9998300075531006:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(1 - ux\right)} \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.999830008Initial program 89.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3276.5
Applied rewrites76.5%
Taylor expanded in maxCos around 0
lower--.f3274.0
Applied rewrites74.0%
Taylor expanded in maxCos around 0
lower--.f3273.7
Applied rewrites73.7%
if 0.999830008 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 34.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3231.9
Applied rewrites31.9%
Taylor expanded in maxCos around 0
lower--.f3231.1
Applied rewrites31.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f3270.1
Applied rewrites61.5%
Applied rewrites75.9%
Final simplification74.9%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) (* (* (PI) 2.0) uy)))
\begin{array}{l}
\\
\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)
\end{array}
Initial program 58.7%
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.0
Applied rewrites50.0%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f3260.2
Applied rewrites56.9%
Applied rewrites63.8%
Final simplification63.8%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* 2.0 ux)) (* (* (PI) 2.0) uy)))
\begin{array}{l}
\\
\sqrt{2 \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)
\end{array}
Initial program 58.7%
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.0
Applied rewrites50.0%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f3260.2
Applied rewrites55.2%
Taylor expanded in maxCos around 0
Applied rewrites60.2%
Final simplification60.2%
herbie shell --seed 2024296
(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)))))))