
(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 (* (- (- 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(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)
\end{array}
Initial program 59.6%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.3
Applied rewrites51.3%
Taylor expanded in ux around 0
Applied rewrites7.1%
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-*.f3279.2
Applied rewrites79.2%
Taylor expanded in uy around inf
*-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.f3298.3
Applied rewrites98.3%
Final simplification98.3%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (* 2.0 uy) (PI)))))
(if (<= maxCos 2.0000000233721948e-7)
(*
(sqrt (* (fma maxCos -2.0 (- 2.0 (* (pow (- maxCos 1.0) 2.0) ux))) ux))
t_0)
(*
(sqrt
(*
(* ux ux)
(-
(-
(- (fma (- 1.0 maxCos) maxCos (/ 1.0 ux)) (/ (- maxCos 1.0) ux))
(- (/ maxCos ux) maxCos))
1.0)))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
\mathbf{if}\;maxCos \leq 2.0000000233721948 \cdot 10^{-7}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{fma}\left(1 - maxCos, maxCos, \frac{1}{ux}\right) - \frac{maxCos - 1}{ux}\right) - \left(\frac{maxCos}{ux} - maxCos\right)\right) - 1\right)} \cdot t\_0\\
\end{array}
\end{array}
if maxCos < 2.00000002e-7Initial program 61.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f320.9
Applied rewrites0.5%
if 2.00000002e-7 < maxCos Initial program 50.8%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-+l+N/A
distribute-rgt-neg-inN/A
lower-fma.f32N/A
Applied rewrites18.4%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites50.9%
Final simplification8.5%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* 2.0 uy) 0.0002800000074785203)
(*
(* (* (PI) 2.0) uy)
(sqrt (* (- (- 2.0 (* (pow (- maxCos 1.0) 2.0) ux)) (* maxCos 2.0)) ux)))
(*
(sqrt
(*
(* ux ux)
(-
(-
(- (fma (- 1.0 maxCos) maxCos (/ 1.0 ux)) (/ (- maxCos 1.0) ux))
(- (/ maxCos ux) maxCos))
1.0)))
(sin (* (* 2.0 uy) (PI))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.0002800000074785203:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(\left(2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) - maxCos \cdot 2\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(ux \cdot ux\right) \cdot \left(\left(\left(\mathsf{fma}\left(1 - maxCos, maxCos, \frac{1}{ux}\right) - \frac{maxCos - 1}{ux}\right) - \left(\frac{maxCos}{ux} - maxCos\right)\right) - 1\right)} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 2.80000007e-4Initial program 60.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3260.2
Applied rewrites60.2%
Taylor expanded in ux around 0
Applied rewrites7.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
*-commutativeN/A
lower-*.f3298.4
Applied rewrites98.4%
if 2.80000007e-4 < (*.f32 uy #s(literal 2 binary32)) Initial program 58.8%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-+l+N/A
distribute-rgt-neg-inN/A
lower-fma.f32N/A
Applied rewrites12.5%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites35.7%
Final simplification97.7%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* 2.0 uy) 0.0012000000569969416)
(*
(* (* (PI) 2.0) uy)
(sqrt (* (- (- 2.0 (* (pow (- maxCos 1.0) 2.0) ux)) (* maxCos 2.0)) ux)))
(*
(sqrt
(fma
(* maxCos ux)
(- -1.0 (- (* maxCos ux) ux))
(* (- (- (- maxCos (/ (- maxCos 1.0) ux)) (/ -1.0 ux)) 1.0) (* ux ux))))
(sin (* (* 2.0 uy) (PI))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.0012000000569969416:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(\left(2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) - maxCos \cdot 2\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(maxCos \cdot ux, -1 - \left(maxCos \cdot ux - ux\right), \left(\left(\left(maxCos - \frac{maxCos - 1}{ux}\right) - \frac{-1}{ux}\right) - 1\right) \cdot \left(ux \cdot ux\right)\right)} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00120000006Initial program 61.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3261.3
Applied rewrites61.3%
Taylor expanded in ux around 0
Applied rewrites7.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
*-commutativeN/A
lower-*.f3297.6
Applied rewrites97.6%
if 0.00120000006 < (*.f32 uy #s(literal 2 binary32)) Initial program 57.1%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-+l+N/A
distribute-rgt-neg-inN/A
lower-fma.f32N/A
Applied rewrites11.3%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
associate-+r+N/A
lower-+.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f32N/A
lower--.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f3219.7
Applied rewrites22.5%
Final simplification95.8%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (* 2.0 uy) (PI)))))
(if (<= (+ (- 1.0 ux) (* maxCos ux)) 0.9998999834060669)
(*
(sqrt
(-
1.0
(+
(* (* (- (/ 2.0 ux) (- 1.0 maxCos)) (- maxCos 1.0)) (* ux ux))
1.0)))
t_0)
(* (sqrt (* (- (- 1.0 maxCos) (- maxCos 1.0)) ux)) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
\mathbf{if}\;\left(1 - ux\right) + maxCos \cdot ux \leq 0.9998999834060669:\\
\;\;\;\;\sqrt{1 - \left(\left(\left(\frac{2}{ux} - \left(1 - maxCos\right)\right) \cdot \left(maxCos - 1\right)\right) \cdot \left(ux \cdot ux\right) + 1\right)} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(1 - maxCos\right) - \left(maxCos - 1\right)\right) \cdot ux} \cdot t\_0\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999899983Initial program 88.6%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites87.7%
lift-*.f32N/A
*-commutativeN/A
lower-*.f3287.7
Applied rewrites90.6%
if 0.999899983 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 36.7%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-+l+N/A
distribute-rgt-neg-inN/A
lower-fma.f32N/A
Applied rewrites14.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
mul-1-negN/A
sub-negN/A
lower--.f32N/A
lower--.f3292.9
Applied rewrites92.9%
Final simplification91.9%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (* 2.0 uy) (PI)))) (t_1 (+ (- 1.0 ux) (* maxCos ux))))
(if (<= (- 1.0 (* t_1 t_1)) 0.0003600000054575503)
(* (sqrt (* (- (- 1.0 maxCos) (- maxCos 1.0)) ux)) t_0)
(* (sqrt (- 1.0 (* (- 1.0 ux) t_1))) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
t_1 := \left(1 - ux\right) + maxCos \cdot ux\\
\mathbf{if}\;1 - t\_1 \cdot t\_1 \leq 0.0003600000054575503:\\
\;\;\;\;\sqrt{\left(\left(1 - maxCos\right) - \left(maxCos - 1\right)\right) \cdot ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot t\_1} \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)))) < 3.60000005e-4Initial program 37.7%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-+l+N/A
distribute-rgt-neg-inN/A
lower-fma.f32N/A
Applied rewrites14.3%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
mul-1-negN/A
sub-negN/A
lower--.f32N/A
lower--.f3292.3
Applied rewrites92.3%
if 3.60000005e-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 89.2%
Taylor expanded in maxCos around 0
lower--.f3284.9
Applied rewrites84.9%
Final simplification89.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (* 2.0 uy) (PI)))) (t_1 (+ (- 1.0 ux) (* maxCos ux))))
(if (<= t_1 0.9998199939727783)
(* (sqrt (- 1.0 (* (- 1.0 (- ux (* maxCos ux))) t_1))) t_0)
(* (sqrt (* (- (- 1.0 maxCos) (- maxCos 1.0)) ux)) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
t_1 := \left(1 - ux\right) + maxCos \cdot ux\\
\mathbf{if}\;t\_1 \leq 0.9998199939727783:\\
\;\;\;\;\sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot t\_1} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(1 - maxCos\right) - \left(maxCos - 1\right)\right) \cdot ux} \cdot t\_0\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999819994Initial program 89.2%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3289.4
lift-*.f32N/A
*-commutativeN/A
lower-*.f3289.4
Applied rewrites89.4%
if 0.999819994 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 37.7%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-+l+N/A
distribute-rgt-neg-inN/A
lower-fma.f32N/A
Applied rewrites14.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
mul-1-negN/A
sub-negN/A
lower--.f32N/A
lower--.f3292.3
Applied rewrites92.3%
Final simplification91.1%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (* 2.0 uy) (PI)))) (t_1 (+ (- 1.0 ux) (* maxCos ux))))
(if (<= t_1 0.9998199939727783)
(* (sqrt (- 1.0 (* t_1 t_1))) t_0)
(* (sqrt (* (- (- 1.0 maxCos) (- maxCos 1.0)) ux)) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
t_1 := \left(1 - ux\right) + maxCos \cdot ux\\
\mathbf{if}\;t\_1 \leq 0.9998199939727783:\\
\;\;\;\;\sqrt{1 - t\_1 \cdot t\_1} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(1 - maxCos\right) - \left(maxCos - 1\right)\right) \cdot ux} \cdot t\_0\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999819994Initial program 89.2%
if 0.999819994 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 37.7%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-+l+N/A
distribute-rgt-neg-inN/A
lower-fma.f32N/A
Applied rewrites14.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
mul-1-negN/A
sub-negN/A
lower--.f32N/A
lower--.f3292.3
Applied rewrites92.3%
Final simplification91.0%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* 2.0 uy) 0.00139999995008111)
(*
(* (* (PI) 2.0) uy)
(sqrt (* (- (- 2.0 (* (pow (- maxCos 1.0) 2.0) ux)) (* maxCos 2.0)) ux)))
(*
(sqrt (* (- (- 1.0 maxCos) (- maxCos 1.0)) ux))
(sin (* (* 2.0 uy) (PI))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.00139999995008111:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(\left(2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) - maxCos \cdot 2\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(1 - maxCos\right) - \left(maxCos - 1\right)\right) \cdot ux} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00139999995Initial program 61.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3261.6
Applied rewrites61.6%
Taylor expanded in ux around 0
Applied rewrites7.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
*-commutativeN/A
lower-*.f3297.4
Applied rewrites97.4%
if 0.00139999995 < (*.f32 uy #s(literal 2 binary32)) Initial program 56.3%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-+l+N/A
distribute-rgt-neg-inN/A
lower-fma.f32N/A
Applied rewrites11.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
mul-1-negN/A
sub-negN/A
lower--.f32N/A
lower--.f3277.2
Applied rewrites77.2%
Final simplification89.4%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* 2.0 uy) 0.00139999995008111)
(*
(sqrt (* (- (- 2.0 (* (fma -2.0 ux 2.0) maxCos)) ux) ux))
(* (* (PI) 2.0) uy))
(*
(sqrt (* (- (- 1.0 maxCos) (- maxCos 1.0)) ux))
(sin (* (* 2.0 uy) (PI))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.00139999995008111:\\
\;\;\;\;\sqrt{\left(\left(2 - \mathsf{fma}\left(-2, ux, 2\right) \cdot maxCos\right) - ux\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(1 - maxCos\right) - \left(maxCos - 1\right)\right) \cdot ux} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00139999995Initial program 61.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3261.6
Applied rewrites61.6%
Taylor expanded in ux around 0
Applied rewrites7.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
*-commutativeN/A
lower-*.f3297.4
Applied rewrites97.4%
Taylor expanded in maxCos around 0
Applied rewrites95.7%
if 0.00139999995 < (*.f32 uy #s(literal 2 binary32)) Initial program 56.3%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-+l+N/A
distribute-rgt-neg-inN/A
lower-fma.f32N/A
Applied rewrites10.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
mul-1-negN/A
sub-negN/A
lower--.f32N/A
lower--.f3277.2
Applied rewrites77.2%
Final simplification79.6%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* 2.0 uy) 0.002050000010058284)
(*
(sqrt (* (- (- 2.0 (* (fma -2.0 ux 2.0) maxCos)) ux) ux))
(* (* (PI) 2.0) uy))
(* (sqrt (* (fma -2.0 maxCos 2.0) ux)) (sin (* (* 2.0 uy) (PI))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.002050000010058284:\\
\;\;\;\;\sqrt{\left(\left(2 - \mathsf{fma}\left(-2, ux, 2\right) \cdot maxCos\right) - ux\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00205000001Initial program 61.2%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3260.9
Applied rewrites60.9%
Taylor expanded in ux around 0
Applied rewrites7.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
*-commutativeN/A
lower-*.f3296.8
Applied rewrites96.8%
Taylor expanded in maxCos around 0
Applied rewrites95.2%
if 0.00205000001 < (*.f32 uy #s(literal 2 binary32)) Initial program 57.0%
lift-+.f32N/A
+-commutativeN/A
lift--.f32N/A
flip--N/A
metadata-evalN/A
div-subN/A
associate-+r-N/A
lower--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-/.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f32N/A
lower-*.f32N/A
+-commutativeN/A
lower-+.f3210.5
Applied rewrites9.9%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3213.7
Applied rewrites14.3%
Final simplification78.4%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (* 2.0 uy) (PI)))))
(if (<= ux 0.00018000000272877514)
(* (sqrt (* (- (- 1.0 maxCos) (- maxCos 1.0)) ux)) t_0)
(* (sqrt (- 1.0 (* (- 1.0 ux) (- 1.0 ux)))) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
\mathbf{if}\;ux \leq 0.00018000000272877514:\\
\;\;\;\;\sqrt{\left(\left(1 - maxCos\right) - \left(maxCos - 1\right)\right) \cdot ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(1 - ux\right)} \cdot t\_0\\
\end{array}
\end{array}
if ux < 1.80000003e-4Initial program 37.7%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
distribute-neg-inN/A
associate-+l+N/A
distribute-rgt-neg-inN/A
lower-fma.f32N/A
Applied rewrites14.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
associate-+r+N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
mul-1-negN/A
sub-negN/A
lower--.f32N/A
lower--.f3292.3
Applied rewrites92.3%
if 1.80000003e-4 < ux Initial program 89.2%
Taylor expanded in maxCos around 0
lower--.f3284.9
Applied rewrites84.9%
Taylor expanded in maxCos around 0
lower--.f3284.4
Applied rewrites84.4%
Final simplification89.0%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (- (- 2.0 (* (fma -2.0 ux 2.0) maxCos)) ux) ux)) (* (* (PI) 2.0) uy)))
\begin{array}{l}
\\
\sqrt{\left(\left(2 - \mathsf{fma}\left(-2, ux, 2\right) \cdot maxCos\right) - ux\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)
\end{array}
Initial program 59.6%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.3
Applied rewrites51.3%
Taylor expanded in ux around 0
Applied rewrites7.1%
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-*.f3279.2
Applied rewrites79.2%
Taylor expanded in maxCos around 0
Applied rewrites78.2%
Final simplification78.2%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (- 2.0 ux) ux)) (* (* (PI) 2.0) uy)))
\begin{array}{l}
\\
\sqrt{\left(2 - ux\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)
\end{array}
Initial program 59.6%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.3
Applied rewrites51.3%
Taylor expanded in ux around 0
Applied rewrites7.1%
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-*.f3279.2
Applied rewrites79.2%
Taylor expanded in maxCos around 0
Applied rewrites74.2%
Final simplification74.2%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (fma -1.0 1.0 1.0)) (* (* (PI) 2.0) uy)))
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(-1, 1, 1\right)} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)
\end{array}
Initial program 59.6%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.3
Applied rewrites51.3%
Taylor expanded in ux around 0
Applied rewrites7.1%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
neg-mul-1N/A
lower-fma.f3220.5
Applied rewrites20.5%
Final simplification20.5%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- 1.0 1.0)) (* (* (PI) 2.0) uy)))
\begin{array}{l}
\\
\sqrt{1 - 1} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)
\end{array}
Initial program 59.6%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.3
Applied rewrites51.3%
Taylor expanded in ux around 0
Applied rewrites7.1%
Final simplification7.1%
herbie shell --seed 2024267
(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)))))))