
(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 12 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}
uy\_m = (fabs.f32 uy)
uy\_s = (copysign.f32 #s(literal 1 binary32) uy)
(FPCore (uy_s ux uy_m maxCos)
:precision binary32
(*
uy_s
(if (<= (* 2.0 uy_m) 0.00016999999934341758)
(*
(sqrt
(*
(- (- 2.0 (* (* (- maxCos 1.0) (- maxCos 1.0)) ux)) (* maxCos 2.0))
ux))
(* (* (PI) 2.0) uy_m))
(*
(sqrt
(* (* ux ux) (- (/ (fma -2.0 maxCos 2.0) ux) (pow (- maxCos 1.0) 2.0))))
(sin (* (PI) (* 2.0 uy_m)))))))\begin{array}{l}
uy\_m = \left|uy\right|
\\
uy\_s = \mathsf{copysign}\left(1, uy\right)
\\
uy\_s \cdot \begin{array}{l}
\mathbf{if}\;2 \cdot uy\_m \leq 0.00016999999934341758:\\
\;\;\;\;\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\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{\mathsf{fma}\left(-2, maxCos, 2\right)}{ux} - {\left(maxCos - 1\right)}^{2}\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\_m\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 1.69999999e-4Initial program 56.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3256.8
Applied rewrites56.8%
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f32N/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
Applied rewrites53.5%
Taylor expanded in ux around 0
Applied rewrites7.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-*.f3298.7
Applied rewrites98.7%
if 1.69999999e-4 < (*.f32 uy #s(literal 2 binary32)) Initial program 56.9%
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-*.f3228.5
Applied rewrites29.5%
Final simplification96.5%
uy\_m = (fabs.f32 uy)
uy\_s = (copysign.f32 #s(literal 1 binary32) uy)
(FPCore (uy_s ux uy_m maxCos)
:precision binary32
(*
uy_s
(if (<= (* 2.0 uy_m) 0.002199999988079071)
(*
(sqrt
(*
(- (- 2.0 (* (* (- maxCos 1.0) (- maxCos 1.0)) ux)) (* maxCos 2.0))
ux))
(* (* (PI) 2.0) uy_m))
(*
(sqrt (* (- (pow (- 2.0 maxCos) 2.0) (* maxCos maxCos)) ux))
(* (sin (* (* (PI) uy_m) 2.0)) (sqrt 0.5))))))\begin{array}{l}
uy\_m = \left|uy\right|
\\
uy\_s = \mathsf{copysign}\left(1, uy\right)
\\
uy\_s \cdot \begin{array}{l}
\mathbf{if}\;2 \cdot uy\_m \leq 0.002199999988079071:\\
\;\;\;\;\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\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left({\left(2 - maxCos\right)}^{2} - maxCos \cdot maxCos\right) \cdot ux} \cdot \left(\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\_m\right) \cdot 2\right) \cdot \sqrt{0.5}\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.0022Initial program 60.2%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3259.6
Applied rewrites59.6%
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f32N/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
Applied rewrites56.7%
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
distribute-rgt-outN/A
lower-*.f32N/A
lower--.f32N/A
lower-+.f32N/A
lower-*.f3296.8
Applied rewrites96.8%
if 0.0022 < (*.f32 uy #s(literal 2 binary32)) Initial program 48.8%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
associate--r+N/A
flip--N/A
lower-/.f32N/A
Applied rewrites9.9%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites81.8%
Final simplification92.4%
uy\_m = (fabs.f32 uy)
uy\_s = (copysign.f32 #s(literal 1 binary32) uy)
(FPCore (uy_s ux uy_m maxCos)
:precision binary32
(*
uy_s
(if (<= (* 2.0 uy_m) 0.002199999988079071)
(*
(sqrt
(*
(- (- 2.0 (* (* (- maxCos 1.0) (- maxCos 1.0)) ux)) (* maxCos 2.0))
ux))
(* (* (PI) 2.0) uy_m))
(*
(sqrt (* (* (- (/ 4.0 maxCos) 4.0) maxCos) (* 0.5 ux)))
(sin (* (PI) (* 2.0 uy_m)))))))\begin{array}{l}
uy\_m = \left|uy\right|
\\
uy\_s = \mathsf{copysign}\left(1, uy\right)
\\
uy\_s \cdot \begin{array}{l}
\mathbf{if}\;2 \cdot uy\_m \leq 0.002199999988079071:\\
\;\;\;\;\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\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(\frac{4}{maxCos} - 4\right) \cdot maxCos\right) \cdot \left(0.5 \cdot ux\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\_m\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.0022Initial program 60.2%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3259.6
Applied rewrites59.6%
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f32N/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
Applied rewrites56.7%
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
distribute-rgt-outN/A
lower-*.f32N/A
lower--.f32N/A
lower-+.f32N/A
lower-*.f3296.8
Applied rewrites96.8%
if 0.0022 < (*.f32 uy #s(literal 2 binary32)) Initial program 48.8%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
associate--r+N/A
flip--N/A
lower-/.f32N/A
Applied rewrites9.7%
Taylor expanded in ux around 0
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3281.5
Applied rewrites81.5%
Taylor expanded in maxCos around inf
Applied rewrites81.5%
Final simplification92.4%
uy\_m = (fabs.f32 uy)
uy\_s = (copysign.f32 #s(literal 1 binary32) uy)
(FPCore (uy_s ux uy_m maxCos)
:precision binary32
(*
uy_s
(if (<= (* 2.0 uy_m) 0.002199999988079071)
(*
(sqrt
(*
(- (- 2.0 (* (* (- maxCos 1.0) (- maxCos 1.0)) ux)) (* maxCos 2.0))
ux))
(* (* (PI) 2.0) uy_m))
(*
(sqrt
(* (* (- (- 2.0 maxCos) maxCos) (+ (- 2.0 maxCos) maxCos)) (* 0.5 ux)))
(sin (* (PI) (* 2.0 uy_m)))))))\begin{array}{l}
uy\_m = \left|uy\right|
\\
uy\_s = \mathsf{copysign}\left(1, uy\right)
\\
uy\_s \cdot \begin{array}{l}
\mathbf{if}\;2 \cdot uy\_m \leq 0.002199999988079071:\\
\;\;\;\;\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\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(\left(2 - maxCos\right) - maxCos\right) \cdot \left(\left(2 - maxCos\right) + maxCos\right)\right) \cdot \left(0.5 \cdot ux\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\_m\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.0022Initial program 60.2%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3259.6
Applied rewrites59.6%
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f32N/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
Applied rewrites56.7%
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
distribute-rgt-outN/A
lower-*.f32N/A
lower--.f32N/A
lower-+.f32N/A
lower-*.f3296.8
Applied rewrites96.8%
if 0.0022 < (*.f32 uy #s(literal 2 binary32)) Initial program 48.8%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
associate--r+N/A
flip--N/A
lower-/.f32N/A
Applied rewrites10.2%
Taylor expanded in ux around 0
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3281.5
Applied rewrites81.5%
Applied rewrites81.5%
Final simplification92.4%
uy\_m = (fabs.f32 uy)
uy\_s = (copysign.f32 #s(literal 1 binary32) uy)
(FPCore (uy_s ux uy_m maxCos)
:precision binary32
(*
uy_s
(if (<= (* 2.0 uy_m) 0.002199999988079071)
(*
(sqrt
(*
(- (- 2.0 (* (* (- maxCos 1.0) (- maxCos 1.0)) ux)) (* maxCos 2.0))
ux))
(* (* (PI) 2.0) uy_m))
(* (sqrt (* 4.0 (* 0.5 ux))) (sin (* (PI) (* 2.0 uy_m)))))))\begin{array}{l}
uy\_m = \left|uy\right|
\\
uy\_s = \mathsf{copysign}\left(1, uy\right)
\\
uy\_s \cdot \begin{array}{l}
\mathbf{if}\;2 \cdot uy\_m \leq 0.002199999988079071:\\
\;\;\;\;\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\_m\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{4 \cdot \left(0.5 \cdot ux\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\_m\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.0022Initial program 60.2%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3259.6
Applied rewrites59.6%
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f32N/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
Applied rewrites56.7%
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
distribute-rgt-outN/A
lower-*.f32N/A
lower--.f32N/A
lower-+.f32N/A
lower-*.f3296.8
Applied rewrites96.8%
if 0.0022 < (*.f32 uy #s(literal 2 binary32)) Initial program 48.8%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
associate--r+N/A
flip--N/A
lower-/.f32N/A
Applied rewrites9.4%
Taylor expanded in ux around 0
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3281.5
Applied rewrites81.5%
Taylor expanded in maxCos around 0
Applied rewrites77.3%
Final simplification91.1%
uy\_m = (fabs.f32 uy)
uy\_s = (copysign.f32 #s(literal 1 binary32) uy)
(FPCore (uy_s ux uy_m maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy_m)) (t_1 (+ (* ux maxCos) (- 1.0 ux))))
(*
uy_s
(if (<= (- 1.0 (* t_1 t_1)) 0.00039999998989515007)
(* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) t_0)
(* (sqrt (- 1.0 (* (- 1.0 (- ux (* ux maxCos))) t_1))) t_0)))))\begin{array}{l}
uy\_m = \left|uy\right|
\\
uy\_s = \mathsf{copysign}\left(1, uy\right)
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\_m\\
t_1 := ux \cdot maxCos + \left(1 - ux\right)\\
uy\_s \cdot \begin{array}{l}
\mathbf{if}\;1 - t\_1 \cdot t\_1 \leq 0.00039999998989515007:\\
\;\;\;\;\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 - \left(ux - ux \cdot maxCos\right)\right) \cdot t\_1} \cdot t\_0\\
\end{array}
\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.9999999e-4Initial program 38.5%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3237.4
Applied rewrites37.4%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3273.6
Applied rewrites73.2%
Applied rewrites77.0%
if 3.9999999e-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.5%
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%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f3278.2
Applied rewrites78.2%
Final simplification77.5%
uy\_m = (fabs.f32 uy)
uy\_s = (copysign.f32 #s(literal 1 binary32) uy)
(FPCore (uy_s ux uy_m maxCos)
:precision binary32
(let* ((t_0 (+ (* ux maxCos) (- 1.0 ux)))
(t_1 (- 1.0 (* t_0 t_0)))
(t_2 (* (* (PI) 2.0) uy_m)))
(*
uy_s
(if (<= t_1 0.00039999998989515007)
(* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) t_2)
(* (sqrt t_1) t_2)))))\begin{array}{l}
uy\_m = \left|uy\right|
\\
uy\_s = \mathsf{copysign}\left(1, uy\right)
\\
\begin{array}{l}
t_0 := ux \cdot maxCos + \left(1 - ux\right)\\
t_1 := 1 - t\_0 \cdot t\_0\\
t_2 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\_m\\
uy\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_1 \leq 0.00039999998989515007:\\
\;\;\;\;\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot t\_2\\
\mathbf{else}:\\
\;\;\;\;\sqrt{t\_1} \cdot t\_2\\
\end{array}
\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.9999999e-4Initial program 38.5%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3237.4
Applied rewrites37.4%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3273.6
Applied rewrites73.2%
Applied rewrites77.0%
if 3.9999999e-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.5%
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%
Final simplification77.4%
uy\_m = (fabs.f32 uy)
uy\_s = (copysign.f32 #s(literal 1 binary32) uy)
(FPCore (uy_s ux uy_m maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy_m)) (t_1 (+ (* ux maxCos) (- 1.0 ux))))
(*
uy_s
(if (<= (- 1.0 (* t_1 t_1)) 0.00039999998989515007)
(* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) t_0)
(* (sqrt (- 1.0 (* (- 1.0 ux) t_1))) t_0)))))\begin{array}{l}
uy\_m = \left|uy\right|
\\
uy\_s = \mathsf{copysign}\left(1, uy\right)
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\_m\\
t_1 := ux \cdot maxCos + \left(1 - ux\right)\\
uy\_s \cdot \begin{array}{l}
\mathbf{if}\;1 - t\_1 \cdot t\_1 \leq 0.00039999998989515007:\\
\;\;\;\;\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot t\_1} \cdot t\_0\\
\end{array}
\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.9999999e-4Initial program 38.5%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3237.4
Applied rewrites37.4%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3273.6
Applied rewrites73.2%
Applied rewrites77.0%
if 3.9999999e-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.5%
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 maxCos around 0
lower--.f3274.0
Applied rewrites74.0%
Final simplification75.9%
uy\_m = (fabs.f32 uy)
uy\_s = (copysign.f32 #s(literal 1 binary32) uy)
(FPCore (uy_s ux uy_m maxCos)
:precision binary32
(*
uy_s
(*
(sqrt
(* (- (- 2.0 (* (* (- maxCos 1.0) (- maxCos 1.0)) ux)) (* maxCos 2.0)) ux))
(* (* (PI) 2.0) uy_m))))\begin{array}{l}
uy\_m = \left|uy\right|
\\
uy\_s = \mathsf{copysign}\left(1, uy\right)
\\
uy\_s \cdot \left(\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\_m\right)\right)
\end{array}
Initial program 56.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3252.3
Applied rewrites52.3%
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f32N/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
Applied rewrites49.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
distribute-rgt-outN/A
lower-*.f32N/A
lower--.f32N/A
lower-+.f32N/A
lower-*.f3283.1
Applied rewrites83.1%
Final simplification83.1%
uy\_m = (fabs.f32 uy) uy\_s = (copysign.f32 #s(literal 1 binary32) uy) (FPCore (uy_s ux uy_m maxCos) :precision binary32 (* uy_s (* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) (* (* (PI) 2.0) uy_m))))
\begin{array}{l}
uy\_m = \left|uy\right|
\\
uy\_s = \mathsf{copysign}\left(1, uy\right)
\\
uy\_s \cdot \left(\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\_m\right)\right)
\end{array}
Initial program 56.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3252.3
Applied rewrites52.3%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3265.1
Applied rewrites65.0%
Applied rewrites67.6%
Final simplification67.6%
uy\_m = (fabs.f32 uy) uy\_s = (copysign.f32 #s(literal 1 binary32) uy) (FPCore (uy_s ux uy_m maxCos) :precision binary32 (* uy_s (* (sqrt (* 2.0 ux)) (* (* (PI) 2.0) uy_m))))
\begin{array}{l}
uy\_m = \left|uy\right|
\\
uy\_s = \mathsf{copysign}\left(1, uy\right)
\\
uy\_s \cdot \left(\sqrt{2 \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\_m\right)\right)
\end{array}
Initial program 56.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3252.3
Applied rewrites52.3%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3265.1
Applied rewrites65.0%
Taylor expanded in maxCos around 0
Applied rewrites65.1%
Final simplification65.1%
uy\_m = (fabs.f32 uy) uy\_s = (copysign.f32 #s(literal 1 binary32) uy) (FPCore (uy_s ux uy_m maxCos) :precision binary32 (* uy_s (* (sqrt (- 1.0 1.0)) (* (+ uy_m uy_m) (PI)))))
\begin{array}{l}
uy\_m = \left|uy\right|
\\
uy\_s = \mathsf{copysign}\left(1, uy\right)
\\
uy\_s \cdot \left(\sqrt{1 - 1} \cdot \left(\left(uy\_m + uy\_m\right) \cdot \mathsf{PI}\left(\right)\right)\right)
\end{array}
Initial program 56.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3252.3
Applied rewrites52.3%
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*l*N/A
lift-*.f32N/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
Applied rewrites50.1%
Taylor expanded in ux around 0
Applied rewrites7.1%
Applied rewrites7.1%
Final simplification7.1%
herbie shell --seed 2024284
(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)))))))