
(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 15 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
(- (* maxCos ux) (* (* (- 1.0 (- ux (* maxCos ux))) ux) (- 1.0 maxCos)))))
(sin (* (PI) (* 2.0 uy)))))\begin{array}{l}
\\
\sqrt{ux - \left(maxCos \cdot ux - \left(\left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot ux\right) \cdot \left(1 - maxCos\right)\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 57.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.3%
lift--.f32N/A
lift-+.f32N/A
associate--r+N/A
lower--.f32N/A
lift-fma.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift--.f32N/A
associate-+l-N/A
associate--r-N/A
metadata-evalN/A
lower-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f3245.6
lift-*.f32N/A
lift-*.f32N/A
associate-*r*N/A
lift-+.f32N/A
Applied rewrites44.9%
lift--.f32N/A
sub-negN/A
lift-+.f32N/A
+-lft-identityN/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-*.f32N/A
distribute-lft-neg-inN/A
lower-*.f32N/A
Applied rewrites98.3%
Final simplification98.3%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* 2.0 uy) 0.0005499999970197678)
(*
(sqrt (* (- (- 2.0 (* (pow (- maxCos 1.0) 2.0) ux)) (* maxCos 2.0)) ux))
(* (* (PI) 2.0) uy))
(* (sqrt (+ (* (- 1.0 ux) ux) ux)) (sin (* (PI) (* 2.0 uy))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.0005499999970197678:\\
\;\;\;\;\sqrt{\left(\left(2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) - maxCos \cdot 2\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(1 - ux\right) \cdot ux + ux} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 5.5e-4Initial program 57.2%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3257.1
Applied rewrites57.1%
Taylor expanded in maxCos around 0
lower--.f3255.2
Applied rewrites55.2%
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.2
Applied rewrites98.2%
if 5.5e-4 < (*.f32 uy #s(literal 2 binary32)) 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 rewrites12.6%
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--.f3294.5
Applied rewrites94.5%
Final simplification96.8%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- (- ux (* maxCos ux)) (* (* (- 1.0 ux) ux) (- maxCos 1.0)))) (sin (* (PI) (* 2.0 uy)))))
\begin{array}{l}
\\
\sqrt{\left(ux - maxCos \cdot ux\right) - \left(\left(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 57.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 rewrites18.6%
lift--.f32N/A
lift-+.f32N/A
associate--r+N/A
lower--.f32N/A
lift-fma.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift--.f32N/A
associate-+l-N/A
associate--r-N/A
metadata-evalN/A
lower-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f3246.1
lift-*.f32N/A
lift-*.f32N/A
associate-*r*N/A
lift-+.f32N/A
Applied rewrites46.2%
Taylor expanded in maxCos around 0
lower--.f3297.2
Applied rewrites97.2%
Final simplification97.2%
(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 57.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 rewrites18.2%
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--.f3293.2
Applied rewrites93.2%
Final simplification93.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy))
(t_1 (- (+ -1.0 ux) (* maxCos ux)))
(t_2 (- 1.0 (* t_1 t_1))))
(if (<= t_2 0.0002500000118743628)
(* (sqrt (* (+ (* -2.0 maxCos) 2.0) 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) - maxCos \cdot ux\\
t_2 := 1 - t\_1 \cdot t\_1\\
\mathbf{if}\;t\_2 \leq 0.0002500000118743628:\\
\;\;\;\;\sqrt{\left(-2 \cdot maxCos + 2\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)))) < 2.50000012e-4Initial program 35.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3232.4
Applied rewrites32.4%
Taylor expanded in maxCos around 0
lower--.f3232.3
Applied rewrites32.3%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3274.5
Applied rewrites67.0%
Applied rewrites77.6%
if 2.50000012e-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.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3272.2
Applied rewrites72.2%
Final simplification75.3%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sqrt
(-
(* (* ux ux) (- (/ 2.0 ux) (- (/ maxCos ux) (- maxCos 1.0))))
(* (* (fma maxCos ux (- 1.0 ux)) maxCos) ux)))
(* (* (PI) 2.0) uy)))\begin{array}{l}
\\
\sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{2}{ux} - \left(\frac{maxCos}{ux} - \left(maxCos - 1\right)\right)\right) - \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot maxCos\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)
\end{array}
Initial program 57.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3249.2
Applied rewrites49.2%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
associate--r+N/A
lower--.f32N/A
lower--.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
Applied rewrites30.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3279.2
Applied rewrites79.2%
Final simplification79.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)) (t_1 (- (+ -1.0 ux) (* maxCos ux))))
(if (<= (- 1.0 (* t_1 t_1)) 0.0002500000118743628)
(* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) t_0)
(* (sqrt (- 1.0 (* (- 1.0 ux) (- (* maxCos ux) (+ -1.0 ux))))) 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) - maxCos \cdot ux\\
\mathbf{if}\;1 - t\_1 \cdot t\_1 \leq 0.0002500000118743628:\\
\;\;\;\;\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(maxCos \cdot ux - \left(-1 + ux\right)\right)} \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)))) < 2.50000012e-4Initial program 35.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3232.4
Applied rewrites32.4%
Taylor expanded in maxCos around 0
lower--.f3232.3
Applied rewrites32.3%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3274.5
Applied rewrites67.3%
Applied rewrites77.6%
if 2.50000012e-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.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3272.2
Applied rewrites72.2%
Taylor expanded in maxCos around 0
lower--.f3269.4
Applied rewrites69.4%
Final simplification74.1%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)) (t_1 (- (+ -1.0 ux) (* maxCos ux))))
(if (<= (- 1.0 (* t_1 t_1)) 0.0002500000118743628)
(* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) t_0)
(* (sqrt (- 1.0 (* (+ (* (- maxCos 1.0) ux) 1.0) (- 1.0 ux)))) 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) - maxCos \cdot ux\\
\mathbf{if}\;1 - t\_1 \cdot t\_1 \leq 0.0002500000118743628:\\
\;\;\;\;\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\left(maxCos - 1\right) \cdot ux + 1\right) \cdot \left(1 - ux\right)} \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)))) < 2.50000012e-4Initial program 35.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3232.4
Applied rewrites32.4%
Taylor expanded in maxCos around 0
lower--.f3232.3
Applied rewrites32.3%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3274.5
Applied rewrites73.2%
Applied rewrites77.6%
if 2.50000012e-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.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3272.2
Applied rewrites72.2%
Taylor expanded in maxCos around 0
lower--.f3269.4
Applied rewrites69.4%
lift-*.f32N/A
*-commutativeN/A
lower-+.f32N/A
lift--.f32N/A
sub-negN/A
associate-+l+N/A
+-commutativeN/A
neg-mul-1N/A
distribute-rgt-inN/A
metadata-evalN/A
sub-negN/A
lift--.f32N/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f3269.4
Applied rewrites69.4%
Final simplification74.1%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sqrt
(-
(* (- (/ (- 2.0 maxCos) ux) (- 1.0 maxCos)) (* ux ux))
(* (* (fma maxCos ux (- 1.0 ux)) maxCos) ux)))
(* (* (PI) 2.0) uy)))\begin{array}{l}
\\
\sqrt{\left(\frac{2 - maxCos}{ux} - \left(1 - maxCos\right)\right) \cdot \left(ux \cdot ux\right) - \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot maxCos\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)
\end{array}
Initial program 57.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3249.2
Applied rewrites49.2%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
associate--r+N/A
lower--.f32N/A
lower--.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
Applied rewrites26.3%
Taylor expanded in ux around -inf
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
associate-*r/N/A
metadata-evalN/A
div-subN/A
sub-negN/A
mul-1-negN/A
lower--.f32N/A
mul-1-negN/A
sub-negN/A
lower-/.f32N/A
lower--.f32N/A
mul-1-negN/A
sub-negN/A
lower--.f32N/A
unpow2N/A
lower-*.f3279.2
Applied rewrites78.4%
Final simplification79.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)) (t_1 (- (+ -1.0 ux) (* maxCos ux))))
(if (<= (- 1.0 (* t_1 t_1)) 0.0005200000014156103)
(* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) t_0)
(* (sqrt (- 1.0 (* (- 1.0 ux) (- 1.0 ux)))) 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) - maxCos \cdot ux\\
\mathbf{if}\;1 - t\_1 \cdot t\_1 \leq 0.0005200000014156103:\\
\;\;\;\;\sqrt{\left(-2 \cdot maxCos + 2\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 (-.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)))) < 5.20000001e-4Initial program 37.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3233.9
Applied rewrites33.9%
Taylor expanded in maxCos around 0
lower--.f3233.7
Applied rewrites33.7%
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.6%
Applied rewrites76.6%
if 5.20000001e-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.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3273.0
Applied rewrites73.0%
Taylor expanded in maxCos around 0
lower--.f3270.2
Applied rewrites70.2%
Taylor expanded in maxCos around 0
lower--.f3269.9
Applied rewrites69.9%
Final simplification74.0%
(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 57.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3249.2
Applied rewrites49.2%
Taylor expanded in maxCos around 0
lower--.f3247.9
Applied rewrites47.9%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3262.9
Applied rewrites62.9%
Applied rewrites64.8%
Final simplification64.8%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- 1.0 (* 1.0 (- 1.0 ux)))) (* (* (PI) 2.0) uy)))
\begin{array}{l}
\\
\sqrt{1 - 1 \cdot \left(1 - ux\right)} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)
\end{array}
Initial program 57.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3249.2
Applied rewrites49.2%
Taylor expanded in maxCos around 0
lower--.f3247.9
Applied rewrites47.9%
Taylor expanded in ux around 0
Applied rewrites26.0%
Final simplification26.0%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (fma maxCos -2.0 2.0) ux)) (* (* (PI) 2.0) uy)))
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)
\end{array}
Initial program 57.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3249.2
Applied rewrites49.2%
Taylor expanded in maxCos around 0
lower--.f3247.9
Applied rewrites47.9%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3262.9
Applied rewrites62.9%
Applied rewrites62.8%
Final simplification62.9%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (fma -2.0 maxCos 2.0) ux)) (* (* (PI) 2.0) uy)))
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)
\end{array}
Initial program 57.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3249.2
Applied rewrites49.2%
Taylor expanded in maxCos around 0
lower--.f3247.9
Applied rewrites47.9%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3262.9
Applied rewrites62.9%
Final simplification62.9%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (* -2.0 maxCos) ux)) (* (* (PI) 2.0) uy)))
\begin{array}{l}
\\
\sqrt{\left(-2 \cdot maxCos\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)
\end{array}
Initial program 57.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3249.2
Applied rewrites49.2%
Taylor expanded in maxCos around 0
lower--.f3247.9
Applied rewrites47.9%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3262.9
Applied rewrites62.7%
Taylor expanded in maxCos around inf
Applied rewrites0.1%
Final simplification0.1%
herbie shell --seed 2024308
(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)))))))