
(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
(*
(sin (* (* uy 2.0) (PI)))
(sqrt
(*
(* ux ux)
(-
(+ (/ (- 2.0 maxCos) ux) (* (- 1.0 maxCos) (+ maxCos -1.0)))
(/ maxCos ux))))))\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\frac{2 - maxCos}{ux} + \left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right) - \frac{maxCos}{ux}\right)}
\end{array}
Initial program 57.1%
lift-*.f32N/A
associate-+l-N/A
flip--N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower--.f32N/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-+.f32N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
lower-*.f32N/A
Applied rewrites57.1%
Taylor expanded in ux around -inf
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
distribute-lft-out--N/A
mul-1-negN/A
lower-neg.f32N/A
sub-negN/A
mul-1-negN/A
lower-+.f32N/A
Applied rewrites98.3%
lift--.f32N/A
lift-+.f32N/A
div-subN/A
lift--.f32N/A
lift--.f32N/A
lift-*.f32N/A
associate-+l-N/A
lower--.f32N/A
lower-/.f32N/A
lower--.f32N/A
lower-/.f3298.4
lift-+.f32N/A
lift--.f32N/A
associate-+r-N/A
metadata-evalN/A
lower--.f3298.4
Applied rewrites98.4%
Final simplification98.4%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sin (* (* uy 2.0) (PI)))
(sqrt
(*
(* ux ux)
(+ (/ (- (- 2.0 maxCos) maxCos) ux) (* (- 1.0 maxCos) (+ maxCos -1.0)))))))\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{\left(2 - maxCos\right) - maxCos}{ux} + \left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right)}
\end{array}
Initial program 57.1%
lift-*.f32N/A
associate-+l-N/A
flip--N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower--.f32N/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-+.f32N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
lower-*.f32N/A
Applied rewrites57.1%
Taylor expanded in ux around -inf
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
distribute-lft-out--N/A
mul-1-negN/A
lower-neg.f32N/A
sub-negN/A
mul-1-negN/A
lower-+.f32N/A
Applied rewrites98.3%
lift--.f32N/A
lift-+.f32N/A
lift--.f32N/A
lift-/.f32N/A
lift--.f32N/A
lift--.f32N/A
lift-*.f32N/A
distribute-neg-inN/A
unsub-negN/A
lower--.f32N/A
Applied rewrites98.3%
Final simplification98.3%
(FPCore (ux uy maxCos)
:precision binary32
(*
ux
(*
(sin (* 2.0 (* uy (PI))))
(sqrt
(+ (/ (+ 2.0 (* maxCos -2.0)) ux) (* (- 1.0 maxCos) (+ maxCos -1.0)))))))\begin{array}{l}
\\
ux \cdot \left(\sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\frac{2 + maxCos \cdot -2}{ux} + \left(1 - maxCos\right) \cdot \left(maxCos + -1\right)}\right)
\end{array}
Initial program 57.1%
lift-*.f32N/A
associate-+l-N/A
flip--N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower--.f32N/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-+.f32N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
lower-*.f32N/A
Applied rewrites57.1%
Taylor expanded in ux around -inf
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
distribute-lft-out--N/A
mul-1-negN/A
lower-neg.f32N/A
sub-negN/A
mul-1-negN/A
lower-+.f32N/A
Applied rewrites98.3%
Taylor expanded in uy around inf
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-sin.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
associate--r+N/A
lower--.f32N/A
Applied rewrites97.9%
Final simplification97.9%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* uy 2.0) 0.0025599999353289604)
(*
(* 2.0 (* uy (PI)))
(sqrt
(*
(* ux ux)
(+
(* (- 1.0 maxCos) (+ maxCos -1.0))
(/ (- (+ 1.0 (- 1.0 maxCos)) maxCos) ux)))))
(* (sin (* (* uy 2.0) (PI))) (sqrt (* ux (+ 2.0 (* maxCos -2.0)))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \cdot 2 \leq 0.0025599999353289604:\\
\;\;\;\;\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right) + \frac{\left(1 + \left(1 - maxCos\right)\right) - maxCos}{ux}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(2 + maxCos \cdot -2\right)}\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00255999994Initial program 58.2%
lift-*.f32N/A
associate-+l-N/A
flip--N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower--.f32N/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-+.f32N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
lower-*.f32N/A
Applied rewrites58.1%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3257.9
Applied rewrites57.9%
Taylor expanded in ux around -inf
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
distribute-lft-out--N/A
mul-1-negN/A
lower-neg.f32N/A
lower--.f32N/A
lower-/.f32N/A
lower--.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
sub-negN/A
metadata-evalN/A
lower-+.f32N/A
Applied rewrites97.1%
if 0.00255999994 < (*.f32 uy #s(literal 2 binary32)) Initial program 54.9%
lift-*.f32N/A
associate-+l-N/A
flip--N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower--.f32N/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-+.f32N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
lower-*.f32N/A
Applied rewrites55.0%
Taylor expanded in ux around -inf
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
distribute-lft-out--N/A
mul-1-negN/A
lower-neg.f32N/A
sub-negN/A
mul-1-negN/A
lower-+.f32N/A
Applied rewrites97.9%
Taylor expanded in ux around 0
lower-*.f32N/A
cancel-sign-sub-invN/A
lower-+.f32N/A
metadata-evalN/A
lower-*.f3276.6
Applied rewrites76.6%
Final simplification90.3%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* (* uy 2.0) (PI))) (sqrt (* (* ux ux) (+ (/ 2.0 ux) -1.0)))))
\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{2}{ux} + -1\right)}
\end{array}
Initial program 57.1%
lift-*.f32N/A
associate-+l-N/A
flip--N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower--.f32N/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-+.f32N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
lower-*.f32N/A
Applied rewrites57.1%
Taylor expanded in ux around -inf
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
distribute-lft-out--N/A
mul-1-negN/A
lower-neg.f32N/A
sub-negN/A
mul-1-negN/A
lower-+.f32N/A
Applied rewrites98.3%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
sub-negN/A
metadata-evalN/A
lower-+.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
unpow2N/A
lower-*.f3293.7
Applied rewrites93.7%
Final simplification93.7%
(FPCore (ux uy maxCos) :precision binary32 (* (* ux (sin (* 2.0 (* uy (PI))))) (sqrt (+ (/ 2.0 ux) -1.0))))
\begin{array}{l}
\\
\left(ux \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right) \cdot \sqrt{\frac{2}{ux} + -1}
\end{array}
Initial program 57.1%
lift-*.f32N/A
associate-+l-N/A
flip--N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower--.f32N/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-+.f32N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
lower-*.f32N/A
Applied rewrites57.1%
Taylor expanded in ux around -inf
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
distribute-lft-out--N/A
mul-1-negN/A
lower-neg.f32N/A
sub-negN/A
mul-1-negN/A
lower-+.f32N/A
Applied rewrites98.3%
Taylor expanded in maxCos around 0
lower-*.f32N/A
lower-*.f32N/A
lower-sin.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
sub-negN/A
metadata-evalN/A
lower-+.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f3293.5
Applied rewrites93.5%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* uy 2.0) 0.0025599999353289604)
(*
(* 2.0 (* uy (PI)))
(sqrt
(*
(* ux ux)
(+
(* (- 1.0 maxCos) (+ maxCos -1.0))
(/ (- (+ 1.0 (- 1.0 maxCos)) maxCos) ux)))))
(* (sin (* (* uy 2.0) (PI))) (sqrt (* 2.0 ux)))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \cdot 2 \leq 0.0025599999353289604:\\
\;\;\;\;\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right) + \frac{\left(1 + \left(1 - maxCos\right)\right) - maxCos}{ux}\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{2 \cdot ux}\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00255999994Initial program 58.2%
lift-*.f32N/A
associate-+l-N/A
flip--N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower--.f32N/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-+.f32N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
lower-*.f32N/A
Applied rewrites58.1%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3257.9
Applied rewrites57.9%
Taylor expanded in ux around -inf
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
distribute-lft-out--N/A
mul-1-negN/A
lower-neg.f32N/A
lower--.f32N/A
lower-/.f32N/A
lower--.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
sub-negN/A
metadata-evalN/A
lower-+.f32N/A
Applied rewrites97.1%
if 0.00255999994 < (*.f32 uy #s(literal 2 binary32)) Initial program 54.9%
Taylor expanded in maxCos around inf
lower-*.f32N/A
associate--l+N/A
div-subN/A
lower-+.f32N/A
lower-/.f32N/A
lower--.f3256.5
Applied rewrites56.5%
Taylor expanded in ux around 0
mul-1-negN/A
associate-*r*N/A
distribute-rgt-neg-inN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-neg.f32N/A
sub-negN/A
lower-+.f32N/A
associate-*r/N/A
metadata-evalN/A
distribute-neg-fracN/A
metadata-evalN/A
lower-/.f3273.1
Applied rewrites73.1%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f3273.5
Applied rewrites73.5%
Final simplification89.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))) (t_1 (* 2.0 (* uy (PI)))))
(if (<= t_0 0.999809980392456)
(* t_1 (sqrt (+ 1.0 (* t_0 (- (+ ux -1.0) (* ux maxCos))))))
(* t_1 (sqrt (* ux (+ 2.0 (* maxCos -2.0))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
t_1 := 2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\\
\mathbf{if}\;t\_0 \leq 0.999809980392456:\\
\;\;\;\;t\_1 \cdot \sqrt{1 + t\_0 \cdot \left(\left(ux + -1\right) - ux \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \sqrt{ux \cdot \left(2 + maxCos \cdot -2\right)}\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.99980998Initial program 88.8%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3272.6
Applied rewrites72.6%
if 0.99980998 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 34.3%
lift-*.f32N/A
associate-+l-N/A
flip--N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower--.f32N/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-+.f32N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
lower-*.f32N/A
Applied rewrites34.3%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3231.5
Applied rewrites31.5%
Taylor expanded in ux around 0
lower-*.f32N/A
cancel-sign-sub-invN/A
lower-+.f32N/A
metadata-evalN/A
lower-*.f3277.1
Applied rewrites77.1%
Final simplification75.2%
(FPCore (ux uy maxCos)
:precision binary32
(*
(* 2.0 (* uy (PI)))
(sqrt
(*
(* ux ux)
(+
(* (- 1.0 maxCos) (+ maxCos -1.0))
(/ (- (+ 1.0 (- 1.0 maxCos)) maxCos) ux))))))\begin{array}{l}
\\
\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right) + \frac{\left(1 + \left(1 - maxCos\right)\right) - maxCos}{ux}\right)}
\end{array}
Initial program 57.1%
lift-*.f32N/A
associate-+l-N/A
flip--N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower--.f32N/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-+.f32N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
lower-*.f32N/A
Applied rewrites57.1%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3248.7
Applied rewrites48.7%
Taylor expanded in ux around -inf
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
distribute-lft-out--N/A
mul-1-negN/A
lower-neg.f32N/A
lower--.f32N/A
lower-/.f32N/A
lower--.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
sub-negN/A
metadata-evalN/A
lower-+.f32N/A
Applied rewrites79.2%
Final simplification79.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* 2.0 (* uy (PI)))))
(if (<= (+ (- 1.0 ux) (* ux maxCos)) 0.9997699856758118)
(* t_0 (sqrt (+ 1.0 (* (- 1.0 ux) (- (+ ux -1.0) (* ux maxCos))))))
(* t_0 (sqrt (* ux (+ 2.0 (* maxCos -2.0))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\\
\mathbf{if}\;\left(1 - ux\right) + ux \cdot maxCos \leq 0.9997699856758118:\\
\;\;\;\;t\_0 \cdot \sqrt{1 + \left(1 - ux\right) \cdot \left(\left(ux + -1\right) - ux \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{ux \cdot \left(2 + maxCos \cdot -2\right)}\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999769986Initial program 89.4%
Taylor expanded in maxCos around inf
lower-*.f32N/A
associate--l+N/A
div-subN/A
lower-+.f32N/A
lower-/.f32N/A
lower--.f3288.7
Applied rewrites88.7%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3271.7
Applied rewrites71.7%
Taylor expanded in maxCos around 0
lower--.f3270.0
Applied rewrites70.0%
if 0.999769986 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 35.3%
lift-*.f32N/A
associate-+l-N/A
flip--N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower--.f32N/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-+.f32N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
lower-*.f32N/A
Applied rewrites35.3%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3232.6
Applied rewrites32.6%
Taylor expanded in ux around 0
lower-*.f32N/A
cancel-sign-sub-invN/A
lower-+.f32N/A
metadata-evalN/A
lower-*.f3276.9
Applied rewrites76.9%
Final simplification74.1%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (+ (/ (+ 2.0 (* maxCos -2.0)) ux) (* (- 1.0 maxCos) (+ maxCos -1.0)))) (* 2.0 (* ux (* uy (PI))))))
\begin{array}{l}
\\
\sqrt{\frac{2 + maxCos \cdot -2}{ux} + \left(1 - maxCos\right) \cdot \left(maxCos + -1\right)} \cdot \left(2 \cdot \left(ux \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)\right)
\end{array}
Initial program 57.1%
lift-*.f32N/A
associate-+l-N/A
flip--N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower--.f32N/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-+.f32N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
lower-*.f32N/A
Applied rewrites57.1%
Taylor expanded in ux around -inf
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
distribute-lft-out--N/A
mul-1-negN/A
lower-neg.f32N/A
sub-negN/A
mul-1-negN/A
lower-+.f32N/A
Applied rewrites98.3%
Taylor expanded in uy around 0
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
associate--r+N/A
lower--.f32N/A
Applied rewrites79.1%
Final simplification79.1%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* 2.0 (* uy (PI)))))
(if (<= (+ (- 1.0 ux) (* ux maxCos)) 0.9997699856758118)
(* t_0 (sqrt (+ 1.0 (* (- 1.0 ux) (+ ux -1.0)))))
(* t_0 (sqrt (* ux (+ 2.0 (* maxCos -2.0))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\\
\mathbf{if}\;\left(1 - ux\right) + ux \cdot maxCos \leq 0.9997699856758118:\\
\;\;\;\;t\_0 \cdot \sqrt{1 + \left(1 - ux\right) \cdot \left(ux + -1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{ux \cdot \left(2 + maxCos \cdot -2\right)}\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999769986Initial program 89.4%
Taylor expanded in maxCos around inf
lower-*.f32N/A
associate--l+N/A
div-subN/A
lower-+.f32N/A
lower-/.f32N/A
lower--.f3288.7
Applied rewrites88.7%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3271.7
Applied rewrites71.7%
Taylor expanded in maxCos around 0
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
lower--.f32N/A
lower--.f3269.7
Applied rewrites69.7%
if 0.999769986 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 35.3%
lift-*.f32N/A
associate-+l-N/A
flip--N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower--.f32N/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-+.f32N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
lower-*.f32N/A
Applied rewrites35.3%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3232.6
Applied rewrites32.6%
Taylor expanded in ux around 0
lower-*.f32N/A
cancel-sign-sub-invN/A
lower-+.f32N/A
metadata-evalN/A
lower-*.f3276.9
Applied rewrites76.9%
Final simplification74.0%
(FPCore (ux uy maxCos) :precision binary32 (* (* 2.0 (* uy (PI))) (sqrt (* ux (+ 2.0 (* maxCos -2.0))))))
\begin{array}{l}
\\
\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{ux \cdot \left(2 + maxCos \cdot -2\right)}
\end{array}
Initial program 57.1%
lift-*.f32N/A
associate-+l-N/A
flip--N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
lower-+.f32N/A
lower--.f32N/A
metadata-evalN/A
cancel-sign-sub-invN/A
lower-+.f32N/A
neg-sub0N/A
associate-+l-N/A
neg-sub0N/A
lower-*.f32N/A
Applied rewrites57.1%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3248.7
Applied rewrites48.7%
Taylor expanded in ux around 0
lower-*.f32N/A
cancel-sign-sub-invN/A
lower-+.f32N/A
metadata-evalN/A
lower-*.f3264.2
Applied rewrites64.2%
Final simplification64.2%
(FPCore (ux uy maxCos) :precision binary32 (* 2.0 (* (* uy (PI)) (sqrt (* -2.0 (fma ux maxCos (- ux)))))))
\begin{array}{l}
\\
2 \cdot \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{-2 \cdot \mathsf{fma}\left(ux, maxCos, -ux\right)}\right)
\end{array}
Initial program 57.1%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
sub-negN/A
+-commutativeN/A
unpow2N/A
distribute-rgt-neg-inN/A
lower-fma.f32N/A
Applied rewrites30.4%
Taylor expanded in ux around 0
lower-*.f32N/A
sub-negN/A
metadata-evalN/A
distribute-lft-inN/A
*-commutativeN/A
lower-fma.f32N/A
mul-1-negN/A
lower-neg.f3262.5
Applied rewrites-0.0%
(FPCore (ux uy maxCos) :precision binary32 (* (* uy (sqrt ux)) (* 2.0 (PI))))
\begin{array}{l}
\\
\left(uy \cdot \sqrt{ux}\right) \cdot \left(2 \cdot \mathsf{PI}\left(\right)\right)
\end{array}
Initial program 57.1%
Taylor expanded in ux around 0
Applied rewrites26.2%
Taylor expanded in uy around 0
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
cancel-sign-sub-invN/A
*-lft-identityN/A
mul-1-negN/A
distribute-rgt-inN/A
mul-1-negN/A
sub-negN/A
sub-negN/A
mul-1-negN/A
lower-sqrt.f32N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f32N/A
mul-1-negN/A
lower-neg.f3230.4
Applied rewrites-0.0%
Taylor expanded in maxCos around 0
lower-sqrt.f3230.5
Applied rewrites30.5%
lift-PI.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lift-sqrt.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3230.5
Applied rewrites30.5%
Final simplification30.5%
(FPCore (ux uy maxCos) :precision binary32 (* (* 2.0 (* uy (PI))) (sqrt ux)))
\begin{array}{l}
\\
\left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot \sqrt{ux}
\end{array}
Initial program 57.1%
Taylor expanded in ux around 0
Applied rewrites26.2%
Taylor expanded in uy around 0
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
cancel-sign-sub-invN/A
*-lft-identityN/A
mul-1-negN/A
distribute-rgt-inN/A
mul-1-negN/A
sub-negN/A
sub-negN/A
mul-1-negN/A
lower-sqrt.f32N/A
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f32N/A
mul-1-negN/A
lower-neg.f3230.4
Applied rewrites-0.0%
Taylor expanded in maxCos around 0
lower-sqrt.f3230.5
Applied rewrites30.5%
herbie shell --seed 2024216
(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)))))))