
(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))))))
float code(float ux, float uy, float maxCos) {
float t_0 = (1.0f - ux) + (ux * maxCos);
return cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((1.0f - (t_0 * t_0)));
}
function code(ux, uy, maxCos) t_0 = Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos)) return Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0)))) end
function tmp = code(ux, uy, maxCos) t_0 = (single(1.0) - ux) + (ux * maxCos); tmp = cos(((uy * single(2.0)) * single(pi))) * sqrt((single(1.0) - (t_0 * t_0))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t_0 \cdot t_0}
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 10 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))))))
float code(float ux, float uy, float maxCos) {
float t_0 = (1.0f - ux) + (ux * maxCos);
return cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((1.0f - (t_0 * t_0)));
}
function code(ux, uy, maxCos) t_0 = Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos)) return Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(1.0) - Float32(t_0 * t_0)))) end
function tmp = code(ux, uy, maxCos) t_0 = (single(1.0) - ux) + (ux * maxCos); tmp = cos(((uy * single(2.0)) * single(pi))) * sqrt((single(1.0) - (t_0 * t_0))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{1 - t_0 \cdot t_0}
\end{array}
\end{array}
(FPCore (ux uy maxCos) :precision binary32 (* (cos (* 2.0 (* uy PI))) (sqrt (* ux (- (* 2.0 (- 1.0 maxCos)) (* ux (pow (- 1.0 maxCos) 2.0)))))))
float code(float ux, float uy, float maxCos) {
return cosf((2.0f * (uy * ((float) M_PI)))) * sqrtf((ux * ((2.0f * (1.0f - maxCos)) - (ux * powf((1.0f - maxCos), 2.0f)))));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(Float32(2.0) * Float32(uy * Float32(pi)))) * sqrt(Float32(ux * Float32(Float32(Float32(2.0) * Float32(Float32(1.0) - maxCos)) - Float32(ux * (Float32(Float32(1.0) - maxCos) ^ Float32(2.0))))))) end
function tmp = code(ux, uy, maxCos) tmp = cos((single(2.0) * (uy * single(pi)))) * sqrt((ux * ((single(2.0) * (single(1.0) - maxCos)) - (ux * ((single(1.0) - maxCos) ^ single(2.0)))))); end
\begin{array}{l}
\\
\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 \cdot \left(1 - maxCos\right) - ux \cdot {\left(1 - maxCos\right)}^{2}\right)}
\end{array}
Initial program 57.0%
associate-*l*57.0%
sub-neg57.0%
+-commutative57.0%
distribute-rgt-neg-in57.0%
fma-def56.8%
+-commutative56.8%
associate-+r-56.9%
fma-def56.9%
neg-sub056.9%
+-commutative56.9%
associate-+r-56.8%
associate--r-56.8%
neg-sub056.8%
+-commutative56.8%
sub-neg56.8%
fma-def56.8%
Simplified56.8%
Taylor expanded in ux around -inf 99.0%
+-commutative99.0%
mul-1-neg99.0%
unsub-neg99.0%
associate-*r*99.0%
mul-1-neg99.0%
sub-neg99.0%
*-commutative99.0%
unpow299.0%
associate-*l*99.0%
mul-1-neg99.0%
sub-neg99.0%
Simplified99.0%
Taylor expanded in uy around inf 99.0%
associate-*r*99.0%
unpow299.0%
associate-*r*99.0%
*-commutative99.0%
distribute-rgt-out--99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (ux uy maxCos) :precision binary32 (if (<= uy 0.001500000013038516) (sqrt (* ux (- (* 2.0 (- 1.0 maxCos)) (* ux (pow (- 1.0 maxCos) 2.0))))) (* (cos (* uy (* 2.0 PI))) (sqrt (* 2.0 ux)))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (uy <= 0.001500000013038516f) {
tmp = sqrtf((ux * ((2.0f * (1.0f - maxCos)) - (ux * powf((1.0f - maxCos), 2.0f)))));
} else {
tmp = cosf((uy * (2.0f * ((float) M_PI)))) * sqrtf((2.0f * ux));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (uy <= Float32(0.001500000013038516)) tmp = sqrt(Float32(ux * Float32(Float32(Float32(2.0) * Float32(Float32(1.0) - maxCos)) - Float32(ux * (Float32(Float32(1.0) - maxCos) ^ Float32(2.0)))))); else tmp = Float32(cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(Float32(Float32(2.0) * ux))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (uy <= single(0.001500000013038516)) tmp = sqrt((ux * ((single(2.0) * (single(1.0) - maxCos)) - (ux * ((single(1.0) - maxCos) ^ single(2.0)))))); else tmp = cos((uy * (single(2.0) * single(pi)))) * sqrt((single(2.0) * ux)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \leq 0.001500000013038516:\\
\;\;\;\;\sqrt{ux \cdot \left(2 \cdot \left(1 - maxCos\right) - ux \cdot {\left(1 - maxCos\right)}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{2 \cdot ux}\\
\end{array}
\end{array}
if uy < 0.00150000001Initial program 58.1%
associate-*l*58.1%
sub-neg58.1%
+-commutative58.1%
distribute-rgt-neg-in58.1%
fma-def58.0%
+-commutative58.0%
associate-+r-58.1%
fma-def58.1%
neg-sub058.1%
+-commutative58.1%
associate-+r-58.0%
associate--r-58.0%
neg-sub058.0%
+-commutative58.0%
sub-neg58.0%
fma-def58.0%
Simplified58.0%
Taylor expanded in ux around -inf 99.4%
+-commutative99.4%
mul-1-neg99.4%
unsub-neg99.4%
associate-*r*99.4%
mul-1-neg99.4%
sub-neg99.4%
*-commutative99.4%
unpow299.4%
associate-*l*99.4%
mul-1-neg99.4%
sub-neg99.4%
Simplified99.4%
Taylor expanded in uy around 0 96.8%
associate-*r*96.8%
unpow296.8%
associate-*r*96.8%
*-commutative96.8%
distribute-rgt-out--96.8%
Simplified96.8%
if 0.00150000001 < uy Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.2%
+-commutative54.2%
associate-+r-54.2%
fma-def54.2%
neg-sub054.2%
+-commutative54.2%
associate-+r-54.1%
associate--r-54.1%
neg-sub054.1%
+-commutative54.1%
sub-neg54.1%
fma-def54.1%
Simplified54.1%
Taylor expanded in ux around 0 77.1%
Taylor expanded in maxCos around 0 71.6%
Final simplification88.9%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* ux (- 2.0 ux))) (cos (* PI (* 2.0 uy)))))
float code(float ux, float uy, float maxCos) {
return sqrtf((ux * (2.0f - ux))) * cosf((((float) M_PI) * (2.0f * uy)));
}
function code(ux, uy, maxCos) return Float32(sqrt(Float32(ux * Float32(Float32(2.0) - ux))) * cos(Float32(Float32(pi) * Float32(Float32(2.0) * uy)))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt((ux * (single(2.0) - ux))) * cos((single(pi) * (single(2.0) * uy))); end
\begin{array}{l}
\\
\sqrt{ux \cdot \left(2 - ux\right)} \cdot \cos \left(\pi \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 57.0%
associate-*l*57.0%
sub-neg57.0%
+-commutative57.0%
distribute-rgt-neg-in57.0%
fma-def56.8%
+-commutative56.8%
associate-+r-56.9%
fma-def56.9%
neg-sub056.9%
+-commutative56.9%
associate-+r-56.8%
associate--r-56.8%
neg-sub056.8%
+-commutative56.8%
sub-neg56.8%
fma-def56.8%
Simplified56.8%
Taylor expanded in ux around 0 99.0%
+-commutative99.0%
fma-def99.0%
associate--l+99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
distribute-neg-in99.0%
metadata-eval99.0%
+-commutative99.0%
sub-neg99.0%
associate-*r*99.0%
*-commutative99.0%
Simplified99.0%
Taylor expanded in maxCos around 0 93.6%
*-commutative93.6%
+-commutative93.6%
mul-1-neg93.6%
sub-neg93.6%
unpow293.6%
distribute-rgt-out--93.6%
*-commutative93.6%
*-commutative93.6%
associate-*l*93.6%
Simplified93.6%
Final simplification93.6%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (* ux (- (* 2.0 (- 1.0 maxCos)) (* ux (pow (- 1.0 maxCos) 2.0))))))
float code(float ux, float uy, float maxCos) {
return sqrtf((ux * ((2.0f * (1.0f - maxCos)) - (ux * powf((1.0f - maxCos), 2.0f)))));
}
real(4) function code(ux, uy, maxcos)
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = sqrt((ux * ((2.0e0 * (1.0e0 - maxcos)) - (ux * ((1.0e0 - maxcos) ** 2.0e0)))))
end function
function code(ux, uy, maxCos) return sqrt(Float32(ux * Float32(Float32(Float32(2.0) * Float32(Float32(1.0) - maxCos)) - Float32(ux * (Float32(Float32(1.0) - maxCos) ^ Float32(2.0)))))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt((ux * ((single(2.0) * (single(1.0) - maxCos)) - (ux * ((single(1.0) - maxCos) ^ single(2.0)))))); end
\begin{array}{l}
\\
\sqrt{ux \cdot \left(2 \cdot \left(1 - maxCos\right) - ux \cdot {\left(1 - maxCos\right)}^{2}\right)}
\end{array}
Initial program 57.0%
associate-*l*57.0%
sub-neg57.0%
+-commutative57.0%
distribute-rgt-neg-in57.0%
fma-def56.8%
+-commutative56.8%
associate-+r-56.9%
fma-def56.9%
neg-sub056.9%
+-commutative56.9%
associate-+r-56.8%
associate--r-56.8%
neg-sub056.8%
+-commutative56.8%
sub-neg56.8%
fma-def56.8%
Simplified56.8%
Taylor expanded in ux around -inf 99.0%
+-commutative99.0%
mul-1-neg99.0%
unsub-neg99.0%
associate-*r*99.0%
mul-1-neg99.0%
sub-neg99.0%
*-commutative99.0%
unpow299.0%
associate-*l*99.0%
mul-1-neg99.0%
sub-neg99.0%
Simplified99.0%
Taylor expanded in uy around 0 78.9%
associate-*r*78.9%
unpow278.9%
associate-*r*78.9%
*-commutative78.9%
distribute-rgt-out--78.9%
Simplified78.9%
Final simplification78.9%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (- (* ux (- 2.0 (* 2.0 maxCos))) (+ (* ux ux) (* -2.0 (* maxCos (* ux ux)))))))
float code(float ux, float uy, float maxCos) {
return sqrtf(((ux * (2.0f - (2.0f * maxCos))) - ((ux * ux) + (-2.0f * (maxCos * (ux * ux))))));
}
real(4) function code(ux, uy, maxcos)
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = sqrt(((ux * (2.0e0 - (2.0e0 * maxcos))) - ((ux * ux) + ((-2.0e0) * (maxcos * (ux * ux))))))
end function
function code(ux, uy, maxCos) return sqrt(Float32(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))) - Float32(Float32(ux * ux) + Float32(Float32(-2.0) * Float32(maxCos * Float32(ux * ux)))))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt(((ux * (single(2.0) - (single(2.0) * maxCos))) - ((ux * ux) + (single(-2.0) * (maxCos * (ux * ux)))))); end
\begin{array}{l}
\\
\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right) - \left(ux \cdot ux + -2 \cdot \left(maxCos \cdot \left(ux \cdot ux\right)\right)\right)}
\end{array}
Initial program 57.0%
associate-*l*57.0%
sub-neg57.0%
+-commutative57.0%
distribute-rgt-neg-in57.0%
fma-def56.8%
+-commutative56.8%
associate-+r-56.9%
fma-def56.9%
neg-sub056.9%
+-commutative56.9%
associate-+r-56.8%
associate--r-56.8%
neg-sub056.8%
+-commutative56.8%
sub-neg56.8%
fma-def56.8%
Simplified56.8%
Taylor expanded in ux around 0 99.0%
+-commutative99.0%
fma-def99.0%
associate--l+99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
distribute-neg-in99.0%
metadata-eval99.0%
+-commutative99.0%
sub-neg99.0%
associate-*r*99.0%
*-commutative99.0%
Simplified99.0%
Taylor expanded in uy around 0 78.9%
Taylor expanded in maxCos around 0 78.4%
unpow278.4%
unpow278.4%
Simplified78.4%
Final simplification78.4%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (- (* ux (- 2.0 (* 2.0 maxCos))) (* ux ux))))
float code(float ux, float uy, float maxCos) {
return sqrtf(((ux * (2.0f - (2.0f * maxCos))) - (ux * ux)));
}
real(4) function code(ux, uy, maxcos)
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = sqrt(((ux * (2.0e0 - (2.0e0 * maxcos))) - (ux * ux)))
end function
function code(ux, uy, maxCos) return sqrt(Float32(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))) - Float32(ux * ux))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt(((ux * (single(2.0) - (single(2.0) * maxCos))) - (ux * ux))); end
\begin{array}{l}
\\
\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right) - ux \cdot ux}
\end{array}
Initial program 57.0%
associate-*l*57.0%
sub-neg57.0%
+-commutative57.0%
distribute-rgt-neg-in57.0%
fma-def56.8%
+-commutative56.8%
associate-+r-56.9%
fma-def56.9%
neg-sub056.9%
+-commutative56.9%
associate-+r-56.8%
associate--r-56.8%
neg-sub056.8%
+-commutative56.8%
sub-neg56.8%
fma-def56.8%
Simplified56.8%
Taylor expanded in ux around 0 99.0%
+-commutative99.0%
fma-def99.0%
associate--l+99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
distribute-neg-in99.0%
metadata-eval99.0%
+-commutative99.0%
sub-neg99.0%
associate-*r*99.0%
*-commutative99.0%
Simplified99.0%
Taylor expanded in uy around 0 78.9%
Taylor expanded in maxCos around 0 78.0%
unpow278.0%
Simplified78.0%
Final simplification78.0%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (- (* 2.0 ux) (* ux ux))))
float code(float ux, float uy, float maxCos) {
return sqrtf(((2.0f * ux) - (ux * ux)));
}
real(4) function code(ux, uy, maxcos)
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = sqrt(((2.0e0 * ux) - (ux * ux)))
end function
function code(ux, uy, maxCos) return sqrt(Float32(Float32(Float32(2.0) * ux) - Float32(ux * ux))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt(((single(2.0) * ux) - (ux * ux))); end
\begin{array}{l}
\\
\sqrt{2 \cdot ux - ux \cdot ux}
\end{array}
Initial program 57.0%
associate-*l*57.0%
sub-neg57.0%
+-commutative57.0%
distribute-rgt-neg-in57.0%
fma-def56.8%
+-commutative56.8%
associate-+r-56.9%
fma-def56.9%
neg-sub056.9%
+-commutative56.9%
associate-+r-56.8%
associate--r-56.8%
neg-sub056.8%
+-commutative56.8%
sub-neg56.8%
fma-def56.8%
Simplified56.8%
Taylor expanded in ux around 0 99.0%
+-commutative99.0%
fma-def99.0%
associate--l+99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
distribute-neg-in99.0%
metadata-eval99.0%
+-commutative99.0%
sub-neg99.0%
associate-*r*99.0%
*-commutative99.0%
Simplified99.0%
Taylor expanded in uy around 0 78.9%
Taylor expanded in maxCos around 0 76.2%
+-commutative76.2%
mul-1-neg76.2%
sub-neg76.2%
unpow276.2%
Simplified76.2%
Final simplification76.2%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (* ux (- 2.0 maxCos))))
float code(float ux, float uy, float maxCos) {
return sqrtf((ux * (2.0f - maxCos)));
}
real(4) function code(ux, uy, maxcos)
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = sqrt((ux * (2.0e0 - maxcos)))
end function
function code(ux, uy, maxCos) return sqrt(Float32(ux * Float32(Float32(2.0) - maxCos))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt((ux * (single(2.0) - maxCos))); end
\begin{array}{l}
\\
\sqrt{ux \cdot \left(2 - maxCos\right)}
\end{array}
Initial program 57.0%
associate-*l*57.0%
sub-neg57.0%
+-commutative57.0%
distribute-rgt-neg-in57.0%
fma-def56.8%
+-commutative56.8%
associate-+r-56.9%
fma-def56.9%
neg-sub056.9%
+-commutative56.9%
associate-+r-56.8%
associate--r-56.8%
neg-sub056.8%
+-commutative56.8%
sub-neg56.8%
fma-def56.8%
Simplified56.8%
Taylor expanded in ux around 0 76.7%
Taylor expanded in uy around 0 63.8%
Taylor expanded in maxCos around 0 62.6%
Final simplification62.6%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (* ux (- 2.0 ux))))
float code(float ux, float uy, float maxCos) {
return sqrtf((ux * (2.0f - ux)));
}
real(4) function code(ux, uy, maxcos)
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = sqrt((ux * (2.0e0 - ux)))
end function
function code(ux, uy, maxCos) return sqrt(Float32(ux * Float32(Float32(2.0) - ux))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt((ux * (single(2.0) - ux))); end
\begin{array}{l}
\\
\sqrt{ux \cdot \left(2 - ux\right)}
\end{array}
Initial program 57.0%
associate-*l*57.0%
sub-neg57.0%
+-commutative57.0%
distribute-rgt-neg-in57.0%
fma-def56.8%
+-commutative56.8%
associate-+r-56.9%
fma-def56.9%
neg-sub056.9%
+-commutative56.9%
associate-+r-56.8%
associate--r-56.8%
neg-sub056.8%
+-commutative56.8%
sub-neg56.8%
fma-def56.8%
Simplified56.8%
Taylor expanded in ux around 0 99.0%
+-commutative99.0%
fma-def99.0%
associate--l+99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
distribute-neg-in99.0%
metadata-eval99.0%
+-commutative99.0%
sub-neg99.0%
associate-*r*99.0%
*-commutative99.0%
Simplified99.0%
Taylor expanded in uy around 0 78.9%
Taylor expanded in maxCos around 0 76.2%
+-commutative76.2%
mul-1-neg76.2%
sub-neg76.2%
unpow276.2%
distribute-rgt-out--76.2%
Simplified76.2%
Final simplification76.2%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (* 2.0 ux)))
float code(float ux, float uy, float maxCos) {
return sqrtf((2.0f * ux));
}
real(4) function code(ux, uy, maxcos)
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = sqrt((2.0e0 * ux))
end function
function code(ux, uy, maxCos) return sqrt(Float32(Float32(2.0) * ux)) end
function tmp = code(ux, uy, maxCos) tmp = sqrt((single(2.0) * ux)); end
\begin{array}{l}
\\
\sqrt{2 \cdot ux}
\end{array}
Initial program 57.0%
associate-*l*57.0%
sub-neg57.0%
+-commutative57.0%
distribute-rgt-neg-in57.0%
fma-def56.8%
+-commutative56.8%
associate-+r-56.9%
fma-def56.9%
neg-sub056.9%
+-commutative56.9%
associate-+r-56.8%
associate--r-56.8%
neg-sub056.8%
+-commutative56.8%
sub-neg56.8%
fma-def56.8%
Simplified56.8%
Taylor expanded in ux around 0 76.7%
Taylor expanded in uy around 0 63.8%
Taylor expanded in maxCos around 0 62.4%
Final simplification62.4%
herbie shell --seed 2023182
(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)))))))