
(FPCore (ux uy maxCos) :precision binary32 (let* ((t_0 (+ (- 1.0 ux) (* ux maxCos)))) (* (cos (* (* 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\\
\cos \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)))) (* (cos (* (* 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\\
\cos \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 ux)
(- (/ (+ (* -2.0 maxCos) 2.0) ux) (* (- 1.0 maxCos) (- 1.0 maxCos)))))
(cos (* (PI) (* 2.0 uy)))))\begin{array}{l}
\\
\sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{-2 \cdot maxCos + 2}{ux} - \left(1 - maxCos\right) \cdot \left(1 - maxCos\right)\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 58.7%
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-*.f3268.6
Applied rewrites68.2%
Applied rewrites98.7%
Applied rewrites98.7%
Final simplification98.7%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= maxCos 5.6000000768108293e-5)
(* (sqrt (* (* (- (/ 2.0 ux) 1.0) ux) ux)) (cos (* (PI) (* 2.0 uy))))
(*
(fma (* (* uy uy) -2.0) (* (PI) (PI)) 1.0)
(sqrt
(*
(* ux ux)
(- (/ (+ (* -2.0 maxCos) 2.0) ux) (* (- 1.0 maxCos) (- 1.0 maxCos))))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 5.6000000768108293 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{-2 \cdot maxCos + 2}{ux} - \left(1 - maxCos\right) \cdot \left(1 - maxCos\right)\right)}\\
\end{array}
\end{array}
if maxCos < 5.60000008e-5Initial program 59.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-*.f3271.3
Applied rewrites71.3%
Taylor expanded in maxCos around 0
Applied rewrites98.2%
if 5.60000008e-5 < maxCos Initial program 51.4%
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-*.f3243.3
Applied rewrites43.3%
Applied rewrites97.9%
Applied rewrites97.9%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3281.6
Applied rewrites81.9%
Final simplification96.0%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* 2.0 uy) 0.0014070000033825636)
(*
(fma (* (* uy uy) -2.0) (* (PI) (PI)) 1.0)
(sqrt
(*
(* ux ux)
(- (/ (+ (* -2.0 maxCos) 2.0) ux) (* (- 1.0 maxCos) (- 1.0 maxCos))))))
(* (sqrt (* (fma -2.0 maxCos 2.0) ux)) (cos (* (PI) (* 2.0 uy))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.0014070000033825636:\\
\;\;\;\;\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{-2 \cdot maxCos + 2}{ux} - \left(1 - maxCos\right) \cdot \left(1 - maxCos\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.001407Initial program 59.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-*.f3292.5
Applied rewrites92.5%
Applied rewrites99.2%
Applied rewrites99.2%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3297.1
Applied rewrites97.1%
if 0.001407 < (*.f32 uy #s(literal 2 binary32)) Initial program 56.3%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3222.7
Applied rewrites22.7%
Final simplification73.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (fma (* (* uy uy) -2.0) (* (PI) (PI)) 1.0))
(t_1 (+ (* maxCos ux) (- 1.0 ux))))
(if (<= (- 1.0 (* t_1 t_1)) 9.999999747378752e-5)
(* (sqrt (* (fma -2.0 maxCos 2.0) ux)) t_0)
(* (sqrt (- 1.0 (* (* (- (+ (/ 1.0 ux) maxCos) 1.0) ux) t_1))) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right)\\
t_1 := maxCos \cdot ux + \left(1 - ux\right)\\
\mathbf{if}\;1 - t\_1 \cdot t\_1 \leq 9.999999747378752 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot 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)))) < 9.99999975e-5Initial program 34.2%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3230.7
Applied rewrites30.8%
Taylor expanded in ux around 0
Applied rewrites20.8%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3272.4
Applied rewrites72.4%
if 9.99999975e-5 < (-.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 87.4%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3274.7
Applied rewrites74.2%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3275.3
Applied rewrites74.9%
Final simplification73.7%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (- 1.0 (- ux (* maxCos ux))))
(t_1 (+ (* maxCos ux) (- 1.0 ux)))
(t_2 (* (PI) (PI))))
(if (<= (- 1.0 (* t_1 t_1)) 0.0003000000142492354)
(* (sqrt (* (fma -2.0 maxCos 2.0) ux)) (fma (* (* uy uy) -2.0) t_2 1.0))
(* (sqrt (- 1.0 (* t_0 t_0))) (fma (* t_2 -2.0) (* uy uy) 1.0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - \left(ux - maxCos \cdot ux\right)\\
t_1 := maxCos \cdot ux + \left(1 - ux\right)\\
t_2 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;1 - t\_1 \cdot t\_1 \leq 0.0003000000142492354:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, t\_2, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - t\_0 \cdot t\_0} \cdot \mathsf{fma}\left(t\_2 \cdot -2, uy \cdot uy, 1\right)\\
\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.00000014e-4Initial program 37.3%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3233.0
Applied rewrites33.0%
Taylor expanded in ux around 0
Applied rewrites21.8%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3270.9
Applied rewrites70.9%
if 3.00000014e-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 90.0%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3290.1
lift-*.f32N/A
*-commutativeN/A
lower-*.f3290.1
Applied rewrites90.1%
lift-+.f32N/A
lift--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate--r-N/A
lift--.f32N/A
lift--.f3290.1
Applied rewrites90.1%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f32N/A
unpow2N/A
lower-*.f3277.3
Applied rewrites76.9%
Final simplification73.5%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* maxCos ux) (- 1.0 ux))) (t_1 (* (PI) (PI))))
(if (<= (- 1.0 (* t_0 t_0)) 0.0003000000142492354)
(* (sqrt (* (fma -2.0 maxCos 2.0) ux)) (fma (* (* uy uy) -2.0) t_1 1.0))
(*
(sqrt (- 1.0 (* (- 1.0 (- ux (* maxCos ux))) t_0)))
(fma (* t_1 -2.0) (* uy uy) 1.0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := maxCos \cdot ux + \left(1 - ux\right)\\
t_1 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;1 - t\_0 \cdot t\_0 \leq 0.0003000000142492354:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, t\_1, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot t\_0} \cdot \mathsf{fma}\left(t\_1 \cdot -2, uy \cdot uy, 1\right)\\
\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.00000014e-4Initial program 37.3%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3233.0
Applied rewrites33.0%
Taylor expanded in ux around 0
Applied rewrites21.8%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3270.9
Applied rewrites70.9%
if 3.00000014e-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 90.0%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3290.1
lift-*.f32N/A
*-commutativeN/A
lower-*.f3290.1
Applied rewrites90.1%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f32N/A
unpow2N/A
lower-*.f3277.3
Applied rewrites76.8%
Final simplification73.5%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* maxCos ux) (- 1.0 ux)))
(t_1 (- 1.0 (* t_0 t_0)))
(t_2 (* (PI) (PI))))
(if (<= t_1 0.0003000000142492354)
(* (sqrt (* (fma -2.0 maxCos 2.0) ux)) (fma (* (* uy uy) -2.0) t_2 1.0))
(* (sqrt t_1) (fma uy (* (* t_2 -2.0) uy) 1.0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := maxCos \cdot ux + \left(1 - ux\right)\\
t_1 := 1 - t\_0 \cdot t\_0\\
t_2 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;t\_1 \leq 0.0003000000142492354:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, t\_2, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{t\_1} \cdot \mathsf{fma}\left(uy, \left(t\_2 \cdot -2\right) \cdot uy, 1\right)\\
\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.00000014e-4Initial program 37.3%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3233.0
Applied rewrites33.0%
Taylor expanded in ux around 0
Applied rewrites21.8%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3270.9
Applied rewrites70.9%
if 3.00000014e-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 90.0%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3277.2
Applied rewrites76.7%
Applied rewrites76.7%
Final simplification73.4%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* maxCos ux) (- 1.0 ux))) (t_1 (* (PI) (PI))))
(if (<= (- 1.0 (* t_0 t_0)) 0.0003000000142492354)
(* (sqrt (* (fma -2.0 maxCos 2.0) ux)) (fma (* (* uy uy) -2.0) t_1 1.0))
(* (sqrt (- 1.0 (* (- 1.0 ux) t_0))) (fma uy (* (* t_1 -2.0) uy) 1.0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := maxCos \cdot ux + \left(1 - ux\right)\\
t_1 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;1 - t\_0 \cdot t\_0 \leq 0.0003000000142492354:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, t\_1, 1\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot t\_0} \cdot \mathsf{fma}\left(uy, \left(t\_1 \cdot -2\right) \cdot uy, 1\right)\\
\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.00000014e-4Initial program 37.3%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3233.0
Applied rewrites33.0%
Taylor expanded in ux around 0
Applied rewrites21.8%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3270.9
Applied rewrites70.9%
if 3.00000014e-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 90.0%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3277.2
Applied rewrites76.7%
Applied rewrites77.2%
Taylor expanded in maxCos around 0
lower--.f3275.1
Applied rewrites74.5%
Final simplification72.6%
(FPCore (ux uy maxCos)
:precision binary32
(*
(fma (* (* uy uy) -2.0) (* (PI) (PI)) 1.0)
(sqrt
(*
(* ux ux)
(- (/ (+ (* -2.0 maxCos) 2.0) ux) (* (- 1.0 maxCos) (- 1.0 maxCos)))))))\begin{array}{l}
\\
\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{-2 \cdot maxCos + 2}{ux} - \left(1 - maxCos\right) \cdot \left(1 - maxCos\right)\right)}
\end{array}
Initial program 58.7%
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-*.f3268.2
Applied rewrites68.2%
Applied rewrites98.7%
Applied rewrites98.7%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3280.0
Applied rewrites80.1%
Final simplification80.0%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (fma -2.0 maxCos 2.0) ux)) (fma (* (* uy uy) -2.0) (* (PI) (PI)) 1.0)))
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right)
\end{array}
Initial program 58.7%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3251.0
Applied rewrites51.0%
Taylor expanded in ux around 0
Applied rewrites25.7%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3262.0
Applied rewrites62.0%
Final simplification62.0%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (fma (- 1.0) 1.0 1.0)) (fma (* (* uy uy) -2.0) (* (PI) (PI)) 1.0)))
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(-1, 1, 1\right)} \cdot \mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right)
\end{array}
Initial program 58.7%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3251.0
Applied rewrites51.0%
Taylor expanded in ux around 0
Applied rewrites25.7%
Taylor expanded in ux around 0
Applied rewrites6.6%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lift-*.f32N/A
distribute-lft-neg-inN/A
lower-fma.f32N/A
lower-neg.f3220.1
Applied rewrites20.1%
Final simplification20.1%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- 1.0 (* 1.0 1.0))) (* (* (* (* uy uy) -2.0) (PI)) (PI))))
\begin{array}{l}
\\
\sqrt{1 - 1 \cdot 1} \cdot \left(\left(\left(\left(uy \cdot uy\right) \cdot -2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)\right)
\end{array}
Initial program 58.7%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3251.0
Applied rewrites51.0%
Taylor expanded in ux around 0
Applied rewrites25.7%
Taylor expanded in ux around 0
Applied rewrites6.6%
Taylor expanded in uy around inf
Applied rewrites6.6%
Final simplification6.6%
herbie shell --seed 2024295
(FPCore (ux uy maxCos)
:name "UniformSampleCone, x"
: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)))
(* (cos (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (+ (- 1.0 ux) (* ux maxCos)))))))