
(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}
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (PI) (* 2.0 uy)))))
(if (<= maxCos 9.9999998245167e-15)
(* (sqrt (+ (* (- 1.0 ux) ux) ux)) t_0)
(*
(sqrt
(*
(-
(*
(-
(-
(/ 2.0 maxCos)
(/ (- (/ 2.0 maxCos) (/ 2.0 (* maxCos maxCos))) ux))
(/ 1.0 (* maxCos maxCos)))
(* ux ux))
(* ux ux))
(* maxCos maxCos)))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\mathbf{if}\;maxCos \leq 9.9999998245167 \cdot 10^{-15}:\\
\;\;\;\;\sqrt{\left(1 - ux\right) \cdot ux + ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(\left(\frac{2}{maxCos} - \frac{\frac{2}{maxCos} - \frac{2}{maxCos \cdot maxCos}}{ux}\right) - \frac{1}{maxCos \cdot maxCos}\right) \cdot \left(ux \cdot ux\right) - ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot t\_0\\
\end{array}
\end{array}
if maxCos < 9.99999982e-15Initial program 60.5%
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 rewrites20.1%
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--.f3298.2
Applied rewrites98.2%
if 9.99999982e-15 < maxCos Initial program 59.2%
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-*.f3218.2
Applied rewrites21.2%
Taylor expanded in maxCos around inf
Applied rewrites98.3%
Taylor expanded in ux around -inf
Applied rewrites98.6%
Final simplification98.3%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (* ux ux) (- (/ (+ (* -2.0 maxCos) 2.0) ux) (pow (- maxCos 1.0) 2.0)))) (sin (* (PI) (* 2.0 uy)))))
\begin{array}{l}
\\
\sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 60.1%
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-*.f3223.0
Applied rewrites21.1%
Applied rewrites98.1%
Final simplification98.1%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (PI) (* 2.0 uy)))))
(if (<= maxCos 2.0000000072549875e-15)
(* (sqrt (+ (* (- 1.0 ux) ux) ux)) t_0)
(*
(sqrt
(*
(-
(*
(/ (- 2.0 (- (/ 2.0 ux) (/ (- (/ 2.0 ux) 1.0) maxCos))) maxCos)
(* ux ux))
(* ux ux))
(* maxCos maxCos)))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\mathbf{if}\;maxCos \leq 2.0000000072549875 \cdot 10^{-15}:\\
\;\;\;\;\sqrt{\left(1 - ux\right) \cdot ux + ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\frac{2 - \left(\frac{2}{ux} - \frac{\frac{2}{ux} - 1}{maxCos}\right)}{maxCos} \cdot \left(ux \cdot ux\right) - ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot t\_0\\
\end{array}
\end{array}
if maxCos < 2.00000001e-15Initial program 61.4%
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 rewrites20.4%
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--.f3298.2
Applied rewrites98.2%
if 2.00000001e-15 < maxCos Initial program 57.6%
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-*.f3219.6
Applied rewrites19.4%
Taylor expanded in maxCos around inf
Applied rewrites98.3%
Taylor expanded in maxCos around inf
Applied rewrites98.5%
Final simplification98.3%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.00011000000085914508)
(* (sqrt (* (fma -2.0 maxCos 2.0) ux)) (sin (* (PI) (* 2.0 uy))))
(*
(sqrt
(-
1.0
(* (* (- (- maxCos 1.0) (/ -1.0 ux)) ux) (- 1.0 (- ux (* maxCos ux))))))
(* (* (PI) 2.0) uy))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00011000000085914508:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\left(\left(maxCos - 1\right) - \frac{-1}{ux}\right) \cdot ux\right) \cdot \left(1 - \left(ux - maxCos \cdot ux\right)\right)} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)\\
\end{array}
\end{array}
if ux < 1.10000001e-4Initial program 36.6%
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-*.f3224.2
Applied rewrites21.1%
Taylor expanded in ux around 0
Applied rewrites36.7%
if 1.10000001e-4 < ux Initial program 88.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3273.8
Applied rewrites73.8%
Taylor expanded in ux around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f32N/A
lower-neg.f32N/A
lower--.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f3274.0
Applied rewrites74.0%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3274.1
Applied rewrites74.1%
Final simplification81.0%
(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 60.1%
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.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--.f3292.0
Applied rewrites92.0%
Final simplification92.0%
(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.00039999998989515007)
(* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) t_0)
(*
(sqrt
(-
1.0
(*
(- (* maxCos ux) (+ -1.0 ux))
(* (- (- maxCos 1.0) (/ -1.0 ux)) 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.00039999998989515007:\\
\;\;\;\;\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(maxCos \cdot ux - \left(-1 + ux\right)\right) \cdot \left(\left(\left(maxCos - 1\right) - \frac{-1}{ux}\right) \cdot 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)))) < 3.9999999e-4Initial program 37.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3234.0
Applied rewrites34.0%
Taylor expanded in maxCos around 0
lower--.f3233.5
Applied rewrites33.5%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3272.6
Applied rewrites72.4%
Applied rewrites76.9%
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 89.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3274.0
Applied rewrites74.0%
Taylor expanded in ux around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f32N/A
lower-neg.f32N/A
lower--.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f3274.2
Applied rewrites74.2%
Final simplification75.7%
(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.00014000000373926014)
(* (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.00014000000373926014:\\
\;\;\;\;\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)))) < 1.40000004e-4Initial program 35.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3232.1
Applied rewrites32.1%
Taylor expanded in maxCos around 0
lower--.f3231.9
Applied rewrites31.9%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3273.3
Applied rewrites73.1%
Applied rewrites77.5%
if 1.40000004e-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.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3273.5
Applied rewrites73.5%
Final simplification75.6%
(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.00039999998989515007)
(* (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.00039999998989515007:\\
\;\;\;\;\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)))) < 3.9999999e-4Initial program 37.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3234.0
Applied rewrites34.0%
Taylor expanded in maxCos around 0
lower--.f3233.5
Applied rewrites33.5%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3272.6
Applied rewrites72.4%
Applied rewrites76.9%
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 89.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3274.0
Applied rewrites74.0%
Taylor expanded in maxCos around 0
lower--.f3272.1
Applied rewrites72.1%
Final simplification74.8%
(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.00039999998989515007)
(* (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.00039999998989515007:\\
\;\;\;\;\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)))) < 3.9999999e-4Initial program 37.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3234.0
Applied rewrites34.0%
Taylor expanded in maxCos around 0
lower--.f3233.5
Applied rewrites33.5%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3272.6
Applied rewrites72.4%
Applied rewrites76.9%
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 89.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3274.0
Applied rewrites74.0%
Taylor expanded in maxCos around 0
lower--.f3272.1
Applied rewrites72.1%
Taylor expanded in maxCos around 0
lower--.f3271.8
Applied rewrites71.8%
Final simplification74.7%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)))
(if (<= ux 0.00019999999494757503)
(* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) t_0)
(*
(sqrt
(-
1.0
(*
(* (- (- maxCos 1.0) (/ -1.0 ux)) ux)
(- 1.0 (- ux (* maxCos ux))))))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
\mathbf{if}\;ux \leq 0.00019999999494757503:\\
\;\;\;\;\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\left(\left(maxCos - 1\right) - \frac{-1}{ux}\right) \cdot ux\right) \cdot \left(1 - \left(ux - maxCos \cdot ux\right)\right)} \cdot t\_0\\
\end{array}
\end{array}
if ux < 1.99999995e-4Initial program 37.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3234.0
Applied rewrites34.0%
Taylor expanded in maxCos around 0
lower--.f3233.5
Applied rewrites33.5%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3272.6
Applied rewrites72.6%
Applied rewrites76.9%
if 1.99999995e-4 < ux Initial program 89.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3274.0
Applied rewrites74.0%
Taylor expanded in ux around -inf
associate-*r*N/A
mul-1-negN/A
lower-*.f32N/A
lower-neg.f32N/A
lower--.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f3274.2
Applied rewrites74.2%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3274.3
Applied rewrites74.3%
Final simplification75.7%
(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 60.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.5
Applied rewrites51.5%
Taylor expanded in maxCos around 0
lower--.f3250.4
Applied rewrites50.4%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3261.4
Applied rewrites60.8%
Applied rewrites64.0%
Final simplification64.0%
(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 60.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.5
Applied rewrites51.5%
Taylor expanded in maxCos around 0
lower--.f3250.4
Applied rewrites50.4%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3261.4
Applied rewrites58.0%
Final simplification61.4%
herbie shell --seed 2024285
(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)))))))