
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux))
(t_1 (sqrt (- 1.0 (* t_0 t_0))))
(t_2 (* (* uy 2.0) (PI))))
(+ (+ (* (* (cos t_2) t_1) xi) (* (* (sin t_2) t_1) yi)) (* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\\
\left(\left(\cos t\_2 \cdot t\_1\right) \cdot xi + \left(\sin t\_2 \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux))
(t_1 (sqrt (- 1.0 (* t_0 t_0))))
(t_2 (* (* uy 2.0) (PI))))
(+ (+ (* (* (cos t_2) t_1) xi) (* (* (sin t_2) t_1) yi)) (* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\\
\left(\left(\cos t\_2 \cdot t\_1\right) \cdot xi + \left(\sin t\_2 \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
\end{array}
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux))
(t_1 (sqrt (- 1.0 (* t_0 t_0))))
(t_2 (* (* uy 2.0) (PI))))
(+
(+ (* (* (cos t_2) t_1) xi) (* (* (sin t_2) t_1) yi))
(* (* (- 1.0 ux) (* maxCos ux)) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\\
\left(\left(\cos t\_2 \cdot t\_1\right) \cdot xi + \left(\sin t\_2 \cdot t\_1\right) \cdot yi\right) + \left(\left(1 - ux\right) \cdot \left(maxCos \cdot ux\right)\right) \cdot zi
\end{array}
\end{array}
Initial program 99.1%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.1
Applied rewrites99.1%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux))
(t_1 (sqrt (- 1.0 (* t_0 t_0))))
(t_2 (* (* uy 2.0) (PI))))
(+ (+ (* (* (cos t_2) t_1) xi) (* (* (sin t_2) t_1) yi)) (* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\\
\left(\left(\cos t\_2 \cdot t\_1\right) \cdot xi + \left(\sin t\_2 \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
\end{array}
Initial program 99.1%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (let* ((t_0 (* (* (PI) uy) 2.0))) (fma (* (* zi (- 1.0 ux)) ux) maxCos (fma (cos t_0) xi (* (sin t_0) yi)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
\mathsf{fma}\left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux, maxCos, \mathsf{fma}\left(\cos t\_0, xi, \sin t\_0 \cdot yi\right)\right)
\end{array}
\end{array}
Initial program 99.1%
Taylor expanded in ux around 0
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.9
Applied rewrites98.9%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
Applied rewrites98.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) uy)))
(fma
(* maxCos ux)
(* (- 1.0 ux) zi)
(fma (cos (* -2.0 t_0)) xi (* (sin (* t_0 2.0)) yi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot uy\\
\mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot zi, \mathsf{fma}\left(\cos \left(-2 \cdot t\_0\right), xi, \sin \left(t\_0 \cdot 2\right) \cdot yi\right)\right)
\end{array}
\end{array}
Initial program 99.1%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-fma.f32N/A
cos-neg-revN/A
lower-cos.f32N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
Applied rewrites98.9%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* maxCos ux) zi (fma (sin (* (PI) (* 2.0 uy))) yi (* xi (cos (* -2.0 (* (PI) uy)))))))
\begin{array}{l}
\\
\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(\sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right), yi, xi \cdot \cos \left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\right)\right)\right)
\end{array}
Initial program 99.1%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.1
Applied rewrites99.1%
Taylor expanded in ux around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-fma.f32N/A
lower-cos.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-*.f32N/A
lower-sin.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3296.5
Applied rewrites96.5%
Applied rewrites96.5%
Final simplification96.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) uy)))
(fma
(* maxCos ux)
zi
(fma (cos (* -2.0 t_0)) xi (* (sin (* t_0 2.0)) yi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot uy\\
\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(\cos \left(-2 \cdot t\_0\right), xi, \sin \left(t\_0 \cdot 2\right) \cdot yi\right)\right)
\end{array}
\end{array}
Initial program 99.1%
Taylor expanded in ux around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
cos-neg-revN/A
lower-cos.f32N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites96.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) uy)))
(if (<= uy 0.007400000002235174)
(+
xi
(fma
(* 2.0 uy)
(* yi (PI))
(fma
(* maxCos ux)
(* zi (- 1.0 ux))
(*
(* uy uy)
(fma
-2.0
(* xi (* (PI) (PI)))
(* -1.3333333333333333 (* uy (* yi (pow (PI) 3.0)))))))))
(fma (cos (* -2.0 t_0)) xi (* (sin (* t_0 2.0)) yi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot uy\\
\mathbf{if}\;uy \leq 0.007400000002235174:\\
\;\;\;\;xi + \mathsf{fma}\left(2 \cdot uy, yi \cdot \mathsf{PI}\left(\right), \mathsf{fma}\left(maxCos \cdot ux, zi \cdot \left(1 - ux\right), \left(uy \cdot uy\right) \cdot \mathsf{fma}\left(-2, xi \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right), -1.3333333333333333 \cdot \left(uy \cdot \left(yi \cdot {\mathsf{PI}\left(\right)}^{3}\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(-2 \cdot t\_0\right), xi, \sin \left(t\_0 \cdot 2\right) \cdot yi\right)\\
\end{array}
\end{array}
if uy < 0.0074Initial program 99.3%
Taylor expanded in uy around 0
Applied rewrites99.4%
Taylor expanded in maxCos around 0
Applied rewrites99.3%
if 0.0074 < uy Initial program 98.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
cos-neg-revN/A
lower-cos.f32N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3291.0
Applied rewrites91.0%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* (* zi (- 1.0 ux)) ux) maxCos (fma (fma (* -2.0 (* uy uy)) (* (PI) (PI)) 1.0) xi (* (sin (* (* (PI) uy) 2.0)) yi))))
\begin{array}{l}
\\
\mathsf{fma}\left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux, maxCos, \mathsf{fma}\left(\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right), xi, \sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\right)\right)
\end{array}
Initial program 99.1%
Taylor expanded in ux around 0
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.9
Applied rewrites98.9%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
Applied rewrites98.9%
Taylor expanded in uy around 0
Applied rewrites93.3%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* maxCos ux) zi (fma xi (cos (* 2.0 (* uy (PI)))) (* (* (* yi (PI)) uy) 2.0))))
\begin{array}{l}
\\
\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(xi, \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right), \left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2\right)\right)
\end{array}
Initial program 99.1%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.1
Applied rewrites99.1%
Taylor expanded in ux around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-fma.f32N/A
lower-cos.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-*.f32N/A
lower-sin.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3296.5
Applied rewrites96.5%
Taylor expanded in uy around 0
Applied rewrites87.3%
Final simplification87.3%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (fma (* (* (* (PI) (PI)) xi) uy) -2.0 (* (* yi (PI)) 2.0)) uy (* (fma maxCos (/ (* zi ux) xi) 1.0) xi)))
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot xi\right) \cdot uy, -2, \left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right), uy, \mathsf{fma}\left(maxCos, \frac{zi \cdot ux}{xi}, 1\right) \cdot xi\right)
\end{array}
Initial program 99.1%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.1
Applied rewrites99.1%
Taylor expanded in ux around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-fma.f32N/A
lower-cos.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-*.f32N/A
lower-sin.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3296.5
Applied rewrites96.5%
Taylor expanded in xi around inf
Applied rewrites96.4%
Taylor expanded in uy around 0
Applied rewrites83.7%
Final simplification83.7%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* maxCos ux) zi (fma (fma (* (* (* (PI) (PI)) xi) uy) -2.0 (* (* yi (PI)) 2.0)) uy xi)))
\begin{array}{l}
\\
\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(\mathsf{fma}\left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot xi\right) \cdot uy, -2, \left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right), uy, xi\right)\right)
\end{array}
Initial program 99.1%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.1
Applied rewrites99.1%
Taylor expanded in ux around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-fma.f32N/A
lower-cos.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-*.f32N/A
lower-sin.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3296.5
Applied rewrites96.5%
Taylor expanded in uy around 0
Applied rewrites83.7%
Final simplification83.7%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (fma (* (* yi (PI)) uy) 2.0 (* (* (* zi (- 1.0 ux)) ux) maxCos)) xi))
\begin{array}{l}
\\
\mathsf{fma}\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy, 2, \left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot maxCos\right) + xi
\end{array}
Initial program 99.1%
Taylor expanded in ux around 0
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.9
Applied rewrites98.9%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
Applied rewrites98.9%
Taylor expanded in uy around 0
Applied rewrites81.5%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* maxCos ux) zi (fma (* 2.0 uy) (* yi (PI)) xi)))
\begin{array}{l}
\\
\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(2 \cdot uy, yi \cdot \mathsf{PI}\left(\right), xi\right)\right)
\end{array}
Initial program 99.1%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.1
Applied rewrites99.1%
Taylor expanded in ux around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-fma.f32N/A
lower-cos.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-*.f32N/A
lower-sin.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3296.5
Applied rewrites96.5%
Taylor expanded in uy around 0
Applied rewrites79.2%
Final simplification79.2%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* (- zi (* zi ux)) ux) maxCos xi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return fmaf(((zi - (zi * ux)) * ux), maxCos, xi);
}
function code(xi, yi, zi, ux, uy, maxCos) return fma(Float32(Float32(zi - Float32(zi * ux)) * ux), maxCos, xi) end
\begin{array}{l}
\\
\mathsf{fma}\left(\left(zi - zi \cdot ux\right) \cdot ux, maxCos, xi\right)
\end{array}
Initial program 99.1%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites52.7%
Taylor expanded in ux around 0
Applied rewrites52.7%
Taylor expanded in maxCos around 0
Applied rewrites52.8%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* maxCos ux) zi xi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return fmaf((maxCos * ux), zi, xi);
}
function code(xi, yi, zi, ux, uy, maxCos) return fma(Float32(maxCos * ux), zi, xi) end
\begin{array}{l}
\\
\mathsf{fma}\left(maxCos \cdot ux, zi, xi\right)
\end{array}
Initial program 99.1%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites52.7%
Taylor expanded in ux around 0
Applied rewrites50.6%
Applied rewrites50.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* maxCos ux) zi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (maxCos * ux) * zi;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(xi, yi, zi, ux, uy, maxcos)
use fmin_fmax_functions
real(4), intent (in) :: xi
real(4), intent (in) :: yi
real(4), intent (in) :: zi
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = (maxcos * ux) * zi
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(maxCos * ux) * zi) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (maxCos * ux) * zi; end
\begin{array}{l}
\\
\left(maxCos \cdot ux\right) \cdot zi
\end{array}
Initial program 99.1%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites52.7%
Taylor expanded in ux around 0
Applied rewrites50.6%
Taylor expanded in xi around 0
Applied rewrites11.5%
Applied rewrites11.5%
herbie shell --seed 2025017
(FPCore (xi yi zi ux uy maxCos)
:name "UniformSampleCone 2"
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0)) (and (<= -10000.0 yi) (<= yi 10000.0))) (and (<= -10000.0 zi) (<= zi 10000.0))) (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) maxCos) ux) (* (* (- 1.0 ux) maxCos) ux))))) xi) (* (* (sin (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* (* (* (- 1.0 ux) maxCos) ux) (* (* (- 1.0 ux) maxCos) ux))))) yi)) (* (* (* (- 1.0 ux) maxCos) ux) zi)))