
(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 14 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 (* (PI) (* 2.0 uy)))) (t_1 (- (/ 2.0 ux) 1.0)))
(if (<= maxCos 1.999999943436137e-9)
(* (sqrt (* (* ux ux) t_1)) t_0)
(*
(sqrt
(*
(*
(* maxCos maxCos)
(- (/ (- 2.0 (- (/ 2.0 ux) (/ t_1 maxCos))) maxCos) 1.0))
(* ux ux)))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
t_1 := \frac{2}{ux} - 1\\
\mathbf{if}\;maxCos \leq 1.999999943436137 \cdot 10^{-9}:\\
\;\;\;\;\sqrt{\left(ux \cdot ux\right) \cdot t\_1} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(maxCos \cdot maxCos\right) \cdot \left(\frac{2 - \left(\frac{2}{ux} - \frac{t\_1}{maxCos}\right)}{maxCos} - 1\right)\right) \cdot \left(ux \cdot ux\right)} \cdot t\_0\\
\end{array}
\end{array}
if maxCos < 1.99999994e-9Initial program 56.2%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
lower--.f32N/A
lift-*.f32N/A
pow2N/A
pow-to-expN/A
rem-log-expN/A
pow-to-expN/A
pow2N/A
lift-*.f32N/A
lower-expm1.f32N/A
Applied rewrites45.1%
Taylor expanded in ux around -inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.3%
Taylor expanded in maxCos around 0
Applied rewrites98.3%
if 1.99999994e-9 < maxCos Initial program 60.1%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
lower--.f32N/A
lift-*.f32N/A
pow2N/A
pow-to-expN/A
rem-log-expN/A
pow-to-expN/A
pow2N/A
lift-*.f32N/A
lower-expm1.f32N/A
Applied rewrites41.6%
Taylor expanded in ux around -inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.3%
Taylor expanded in maxCos around -inf
Applied rewrites98.5%
Final simplification98.4%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (- (- 2.0 (* (pow (- maxCos 1.0) 2.0) ux)) (* maxCos 2.0)) ux)) (sin (* (PI) (* 2.0 uy)))))
\begin{array}{l}
\\
\sqrt{\left(\left(2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) - maxCos \cdot 2\right) \cdot ux} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 57.1%
Taylor expanded in maxCos around inf
*-commutativeN/A
lower-*.f32N/A
associate--l+N/A
div-subN/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f32N/A
lower--.f3257.3
Applied rewrites57.3%
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.4
Applied rewrites98.4%
Final simplification98.4%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)))
(if (<= (* 2.0 uy) 0.003000000026077032)
(*
(sqrt
(*
(- (- 2.0 (* (* (- maxCos 1.0) (- maxCos 1.0)) ux)) (* maxCos 2.0))
ux))
t_0)
(* (sqrt (* (* (- (/ 2.0 maxCos) 2.0) maxCos) ux)) (sin t_0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
\mathbf{if}\;2 \cdot uy \leq 0.003000000026077032:\\
\;\;\;\;\sqrt{\left(\left(2 - \left(\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)\right) \cdot ux\right) - maxCos \cdot 2\right) \cdot ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(\frac{2}{maxCos} - 2\right) \cdot maxCos\right) \cdot ux} \cdot \sin t\_0\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00300000003Initial program 56.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3255.9
Applied rewrites55.9%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
flip--N/A
lower-/.f32N/A
metadata-evalN/A
lower--.f32N/A
pow2N/A
lower-pow.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f32N/A
lower-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f3256.2
Applied rewrites56.2%
lift-*.f32N/A
lift-/.f32N/A
lift--.f32N/A
metadata-evalN/A
lift-pow.f32N/A
unpow2N/A
lift-+.f32N/A
flip--N/A
lift--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-+l-N/A
lift-*.f32N/A
lift-+.f32N/A
lift--.f32N/A
lift-*.f32N/A
*-lft-identityN/A
Applied rewrites19.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
distribute-rgt-outN/A
lower-*.f32N/A
lower--.f32N/A
lower-+.f32N/A
lower-*.f3296.3
Applied rewrites96.3%
if 0.00300000003 < (*.f32 uy #s(literal 2 binary32)) Initial program 58.7%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3259.1
Applied rewrites59.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-sin.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3211.1
Applied rewrites11.1%
Taylor expanded in maxCos around inf
Applied rewrites76.2%
Final simplification90.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)))
(if (<= (* 2.0 uy) 0.003000000026077032)
(*
(sqrt
(*
(- (- 2.0 (* (* (- maxCos 1.0) (- maxCos 1.0)) ux)) (* maxCos 2.0))
ux))
t_0)
(* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) (sin t_0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
\mathbf{if}\;2 \cdot uy \leq 0.003000000026077032:\\
\;\;\;\;\sqrt{\left(\left(2 - \left(\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)\right) \cdot ux\right) - maxCos \cdot 2\right) \cdot ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot \sin t\_0\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00300000003Initial program 56.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3255.9
Applied rewrites55.9%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
flip--N/A
lower-/.f32N/A
metadata-evalN/A
lower--.f32N/A
pow2N/A
lower-pow.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f32N/A
lower-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f3256.2
Applied rewrites56.2%
lift-*.f32N/A
lift-/.f32N/A
lift--.f32N/A
metadata-evalN/A
lift-pow.f32N/A
unpow2N/A
lift-+.f32N/A
flip--N/A
lift--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-+l-N/A
lift-*.f32N/A
lift-+.f32N/A
lift--.f32N/A
lift-*.f32N/A
*-lft-identityN/A
Applied rewrites21.0%
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
distribute-rgt-outN/A
lower-*.f32N/A
lower--.f32N/A
lower-+.f32N/A
lower-*.f3296.3
Applied rewrites96.3%
if 0.00300000003 < (*.f32 uy #s(literal 2 binary32)) Initial program 58.7%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3259.1
Applied rewrites59.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-sin.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3211.1
Applied rewrites11.1%
Applied rewrites76.2%
Final simplification90.2%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (* ux ux) (- (/ 2.0 ux) 1.0))) (sin (* (PI) (* 2.0 uy)))))
\begin{array}{l}
\\
\sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{2}{ux} - 1\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 57.1%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
lower--.f32N/A
lift-*.f32N/A
pow2N/A
pow-to-expN/A
rem-log-expN/A
pow-to-expN/A
pow2N/A
lift-*.f32N/A
lower-expm1.f32N/A
Applied rewrites46.9%
Taylor expanded in ux around -inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.3%
Taylor expanded in maxCos around 0
Applied rewrites93.4%
Final simplification93.4%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)))
(if (<= (* 2.0 uy) 0.003000000026077032)
(*
(sqrt
(*
(- (- 2.0 (* (* (- maxCos 1.0) (- maxCos 1.0)) ux)) (* maxCos 2.0))
ux))
t_0)
(* (sqrt (* 2.0 ux)) (sin t_0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
\mathbf{if}\;2 \cdot uy \leq 0.003000000026077032:\\
\;\;\;\;\sqrt{\left(\left(2 - \left(\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)\right) \cdot ux\right) - maxCos \cdot 2\right) \cdot ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2 \cdot ux} \cdot \sin t\_0\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00300000003Initial program 56.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3255.9
Applied rewrites55.9%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
flip--N/A
lower-/.f32N/A
metadata-evalN/A
lower--.f32N/A
pow2N/A
lower-pow.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f32N/A
lower-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f3256.2
Applied rewrites56.2%
lift-*.f32N/A
lift-/.f32N/A
lift--.f32N/A
metadata-evalN/A
lift-pow.f32N/A
unpow2N/A
lift-+.f32N/A
flip--N/A
lift--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-+l-N/A
lift-*.f32N/A
lift-+.f32N/A
lift--.f32N/A
lift-*.f32N/A
*-lft-identityN/A
Applied rewrites20.4%
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
distribute-rgt-outN/A
lower-*.f32N/A
lower--.f32N/A
lower-+.f32N/A
lower-*.f3296.3
Applied rewrites96.3%
if 0.00300000003 < (*.f32 uy #s(literal 2 binary32)) Initial program 58.7%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3259.1
Applied rewrites59.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-sin.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3211.1
Applied rewrites11.1%
Taylor expanded in maxCos around 0
Applied rewrites73.7%
Final simplification89.4%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* maxCos ux) (- 1.0 ux))))
(if (<= t_0 0.9998199939727783)
(*
(sqrt (- 1.0 (* (- 1.0 (- ux (* maxCos ux))) t_0)))
(* (* (PI) 2.0) uy))
(* (* (PI) uy) (* (sqrt (* (* (- (/ 2.0 maxCos) 2.0) maxCos) ux)) 2.0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := maxCos \cdot ux + \left(1 - ux\right)\\
\mathbf{if}\;t\_0 \leq 0.9998199939727783:\\
\;\;\;\;\sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot t\_0} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot \left(\sqrt{\left(\left(\frac{2}{maxCos} - 2\right) \cdot maxCos\right) \cdot ux} \cdot 2\right)\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999819994Initial program 88.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3274.8
Applied rewrites74.8%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f3274.9
Applied rewrites74.9%
if 0.999819994 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 35.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3236.2
Applied rewrites36.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-sin.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3225.9
Applied rewrites28.8%
Taylor expanded in uy around 0
Applied rewrites73.3%
Taylor expanded in maxCos around inf
Applied rewrites76.3%
Final simplification75.7%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* maxCos ux) (- 1.0 ux))))
(if (<= t_0 0.9998199939727783)
(* (sqrt (- 1.0 (* t_0 t_0))) (* (* (PI) 2.0) uy))
(* (* (PI) uy) (* (sqrt (* (* (- (/ 2.0 maxCos) 2.0) maxCos) ux)) 2.0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := maxCos \cdot ux + \left(1 - ux\right)\\
\mathbf{if}\;t\_0 \leq 0.9998199939727783:\\
\;\;\;\;\sqrt{1 - t\_0 \cdot t\_0} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot \left(\sqrt{\left(\left(\frac{2}{maxCos} - 2\right) \cdot maxCos\right) \cdot ux} \cdot 2\right)\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999819994Initial program 88.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3274.8
Applied rewrites74.8%
if 0.999819994 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 35.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3236.2
Applied rewrites36.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-sin.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3228.6
Applied rewrites26.7%
Taylor expanded in uy around 0
Applied rewrites73.3%
Taylor expanded in maxCos around inf
Applied rewrites76.3%
Final simplification75.7%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* maxCos ux) (- 1.0 ux))))
(if (<= t_0 0.9995999932289124)
(* (sqrt (- 1.0 (* (- 1.0 ux) t_0))) (* (* (PI) 2.0) uy))
(* (* (PI) uy) (* (sqrt (* (* (- (/ 2.0 maxCos) 2.0) maxCos) ux)) 2.0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := maxCos \cdot ux + \left(1 - ux\right)\\
\mathbf{if}\;t\_0 \leq 0.9995999932289124:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot t\_0} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot \left(\sqrt{\left(\left(\frac{2}{maxCos} - 2\right) \cdot maxCos\right) \cdot ux} \cdot 2\right)\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999599993Initial program 89.9%
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%
Taylor expanded in maxCos around 0
lower--.f3273.8
Applied rewrites73.8%
if 0.999599993 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 37.8%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3238.8
Applied rewrites38.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-sin.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3226.8
Applied rewrites27.2%
Taylor expanded in uy around 0
Applied rewrites72.1%
Taylor expanded in maxCos around inf
Applied rewrites75.2%
Final simplification74.7%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* maxCos ux) (- 1.0 ux))))
(if (<= t_0 0.9995999932289124)
(* (sqrt (- 1.0 (* (- 1.0 ux) t_0))) (* (* (PI) 2.0) uy))
(* (* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) 2.0) (* (PI) uy)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := maxCos \cdot ux + \left(1 - ux\right)\\
\mathbf{if}\;t\_0 \leq 0.9995999932289124:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot t\_0} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot 2\right) \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999599993Initial program 89.9%
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%
Taylor expanded in maxCos around 0
lower--.f3273.8
Applied rewrites73.8%
if 0.999599993 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 37.8%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3238.8
Applied rewrites38.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-sin.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3226.8
Applied rewrites28.1%
Taylor expanded in uy around 0
Applied rewrites72.1%
Applied rewrites75.2%
Final simplification74.7%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (- (- 2.0 (* (* (- maxCos 1.0) (- maxCos 1.0)) ux)) (* maxCos 2.0)) ux)) (* (* (PI) 2.0) uy)))
\begin{array}{l}
\\
\sqrt{\left(\left(2 - \left(\left(maxCos - 1\right) \cdot \left(maxCos - 1\right)\right) \cdot ux\right) - maxCos \cdot 2\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)
\end{array}
Initial program 57.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3249.4
Applied rewrites49.4%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
flip--N/A
lower-/.f32N/A
metadata-evalN/A
lower--.f32N/A
pow2N/A
lower-pow.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f32N/A
lower-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f3249.7
Applied rewrites49.7%
lift-*.f32N/A
lift-/.f32N/A
lift--.f32N/A
metadata-evalN/A
lift-pow.f32N/A
unpow2N/A
lift-+.f32N/A
flip--N/A
lift--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-+l-N/A
lift-*.f32N/A
lift-+.f32N/A
lift--.f32N/A
lift-*.f32N/A
*-lft-identityN/A
Applied rewrites19.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
distribute-rgt-outN/A
lower-*.f32N/A
lower--.f32N/A
lower-+.f32N/A
lower-*.f3279.9
Applied rewrites79.9%
Final simplification79.9%
(FPCore (ux uy maxCos) :precision binary32 (if (<= (+ (* maxCos ux) (- 1.0 ux)) 0.9995999932289124) (* (sqrt (- 1.0 (* (- 1.0 ux) (- 1.0 ux)))) (* (* (PI) 2.0) uy)) (* (* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) 2.0) (* (PI) uy))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;maxCos \cdot ux + \left(1 - ux\right) \leq 0.9995999932289124:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(1 - ux\right)} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot 2\right) \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999599993Initial program 89.9%
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%
Taylor expanded in maxCos around 0
lower--.f3273.8
Applied rewrites73.8%
Taylor expanded in maxCos around 0
lower--.f3273.6
Applied rewrites73.6%
if 0.999599993 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 37.8%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3238.8
Applied rewrites38.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-sin.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3227.8
Applied rewrites30.1%
Taylor expanded in uy around 0
Applied rewrites72.1%
Applied rewrites75.2%
Final simplification74.6%
(FPCore (ux uy maxCos) :precision binary32 (* (* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) 2.0) (* (PI) uy)))
\begin{array}{l}
\\
\left(\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot 2\right) \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)
\end{array}
Initial program 57.1%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3258.1
Applied rewrites58.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-sin.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3229.8
Applied rewrites28.3%
Taylor expanded in uy around 0
Applied rewrites58.2%
Applied rewrites64.7%
Final simplification64.7%
(FPCore (ux uy maxCos) :precision binary32 (* (* (sqrt (* 2.0 ux)) 2.0) (* (PI) uy)))
\begin{array}{l}
\\
\left(\sqrt{2 \cdot ux} \cdot 2\right) \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)
\end{array}
Initial program 57.1%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3258.1
Applied rewrites58.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-sin.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3230.2
Applied rewrites28.1%
Taylor expanded in uy around 0
Applied rewrites62.6%
Taylor expanded in maxCos around 0
Applied rewrites62.9%
Final simplification62.9%
herbie shell --seed 2024332
(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)))))))