
(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 18 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
(cbrt
(*
(pow
(fma
ux
(+ 2.0 (* maxCos -2.0))
(* (pow ux 2.0) (* (- 1.0 maxCos) (+ maxCos -1.0))))
1.5)
(pow (cos (* uy (* 2.0 PI))) 3.0))))
float code(float ux, float uy, float maxCos) {
return cbrtf((powf(fmaf(ux, (2.0f + (maxCos * -2.0f)), (powf(ux, 2.0f) * ((1.0f - maxCos) * (maxCos + -1.0f)))), 1.5f) * powf(cosf((uy * (2.0f * ((float) M_PI)))), 3.0f)));
}
function code(ux, uy, maxCos) return cbrt(Float32((fma(ux, Float32(Float32(2.0) + Float32(maxCos * Float32(-2.0))), Float32((ux ^ Float32(2.0)) * Float32(Float32(Float32(1.0) - maxCos) * Float32(maxCos + Float32(-1.0))))) ^ Float32(1.5)) * (cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) ^ Float32(3.0)))) end
\begin{array}{l}
\\
\sqrt[3]{{\left(\mathsf{fma}\left(ux, 2 + maxCos \cdot -2, {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right)\right)\right)}^{1.5} \cdot {\cos \left(uy \cdot \left(2 \cdot \pi\right)\right)}^{3}}
\end{array}
Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.6%
Simplified54.7%
Taylor expanded in ux around 0 98.9%
fma-def98.9%
+-commutative98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
distribute-lft-in98.9%
metadata-eval98.9%
associate--l+98.9%
mul-1-neg98.9%
sub-neg98.9%
associate-*r*98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in ux around 0 98.9%
Applied egg-rr99.0%
metadata-eval99.0%
cancel-sign-sub-inv99.0%
cancel-sign-sub-inv99.0%
metadata-eval99.0%
*-commutative99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (cos (* PI (* 2.0 uy)))) (t_1 (* ux (- 2.0 (* 2.0 maxCos)))))
(if (<= t_0 0.9999955296516418)
(* t_0 (sqrt t_1))
(sqrt (- t_1 (* (pow ux 2.0) (* (- 1.0 maxCos) (- 1.0 maxCos))))))))
float code(float ux, float uy, float maxCos) {
float t_0 = cosf((((float) M_PI) * (2.0f * uy)));
float t_1 = ux * (2.0f - (2.0f * maxCos));
float tmp;
if (t_0 <= 0.9999955296516418f) {
tmp = t_0 * sqrtf(t_1);
} else {
tmp = sqrtf((t_1 - (powf(ux, 2.0f) * ((1.0f - maxCos) * (1.0f - maxCos)))));
}
return tmp;
}
function code(ux, uy, maxCos) t_0 = cos(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) t_1 = Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))) tmp = Float32(0.0) if (t_0 <= Float32(0.9999955296516418)) tmp = Float32(t_0 * sqrt(t_1)); else tmp = sqrt(Float32(t_1 - Float32((ux ^ Float32(2.0)) * Float32(Float32(Float32(1.0) - maxCos) * Float32(Float32(1.0) - maxCos))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) t_0 = cos((single(pi) * (single(2.0) * uy))); t_1 = ux * (single(2.0) - (single(2.0) * maxCos)); tmp = single(0.0); if (t_0 <= single(0.9999955296516418)) tmp = t_0 * sqrt(t_1); else tmp = sqrt((t_1 - ((ux ^ single(2.0)) * ((single(1.0) - maxCos) * (single(1.0) - maxCos))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\pi \cdot \left(2 \cdot uy\right)\right)\\
t_1 := ux \cdot \left(2 - 2 \cdot maxCos\right)\\
\mathbf{if}\;t_0 \leq 0.9999955296516418:\\
\;\;\;\;t_0 \cdot \sqrt{t_1}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{t_1 - {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(1 - maxCos\right)\right)}\\
\end{array}
\end{array}
if (cos.f32 (*.f32 (*.f32 uy 2) (PI.f32))) < 0.99999553Initial program 52.0%
Taylor expanded in ux around 0 79.2%
if 0.99999553 < (cos.f32 (*.f32 (*.f32 uy 2) (PI.f32))) Initial program 56.3%
associate-*l*56.3%
sub-neg56.3%
+-commutative56.3%
distribute-rgt-neg-in56.3%
fma-def56.5%
Simplified56.5%
Taylor expanded in ux around -inf 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
associate-*r*99.6%
mul-1-neg99.6%
sub-neg99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
sub-neg99.6%
mul-1-neg99.6%
unsub-neg99.6%
mul-1-neg99.6%
sub-neg99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in uy around 0 98.3%
Final simplification90.4%
(FPCore (ux uy maxCos)
:precision binary32
(*
(cos (* uy (* 2.0 PI)))
(sqrt
(-
(* (- 1.0 maxCos) (* (pow ux 2.0) (+ maxCos -1.0)))
(* ux (+ -1.0 (+ maxCos (+ maxCos -1.0))))))))
float code(float ux, float uy, float maxCos) {
return cosf((uy * (2.0f * ((float) M_PI)))) * sqrtf((((1.0f - maxCos) * (powf(ux, 2.0f) * (maxCos + -1.0f))) - (ux * (-1.0f + (maxCos + (maxCos + -1.0f))))));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(Float32(Float32(Float32(Float32(1.0) - maxCos) * Float32((ux ^ Float32(2.0)) * Float32(maxCos + Float32(-1.0)))) - Float32(ux * Float32(Float32(-1.0) + Float32(maxCos + Float32(maxCos + Float32(-1.0)))))))) end
function tmp = code(ux, uy, maxCos) tmp = cos((uy * (single(2.0) * single(pi)))) * sqrt((((single(1.0) - maxCos) * ((ux ^ single(2.0)) * (maxCos + single(-1.0)))) - (ux * (single(-1.0) + (maxCos + (maxCos + single(-1.0))))))); end
\begin{array}{l}
\\
\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left({ux}^{2} \cdot \left(maxCos + -1\right)\right) - ux \cdot \left(-1 + \left(maxCos + \left(maxCos + -1\right)\right)\right)}
\end{array}
Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.6%
Simplified54.7%
Taylor expanded in ux around -inf 98.9%
+-commutative98.9%
mul-1-neg98.9%
unsub-neg98.9%
associate-*r*98.9%
mul-1-neg98.9%
sub-neg98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
sub-neg98.9%
mul-1-neg98.9%
unsub-neg98.9%
mul-1-neg98.9%
sub-neg98.9%
metadata-eval98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (ux uy maxCos)
:precision binary32
(*
(cos (* uy (* 2.0 PI)))
(sqrt
(-
(* ux (- 2.0 (* 2.0 maxCos)))
(* (pow ux 2.0) (* (- 1.0 maxCos) (- 1.0 maxCos)))))))
float code(float ux, float uy, float maxCos) {
return cosf((uy * (2.0f * ((float) M_PI)))) * sqrtf(((ux * (2.0f - (2.0f * maxCos))) - (powf(ux, 2.0f) * ((1.0f - maxCos) * (1.0f - maxCos)))));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(Float32(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))) - Float32((ux ^ Float32(2.0)) * Float32(Float32(Float32(1.0) - maxCos) * Float32(Float32(1.0) - maxCos)))))) end
function tmp = code(ux, uy, maxCos) tmp = cos((uy * (single(2.0) * single(pi)))) * sqrt(((ux * (single(2.0) - (single(2.0) * maxCos))) - ((ux ^ single(2.0)) * ((single(1.0) - maxCos) * (single(1.0) - maxCos))))); end
\begin{array}{l}
\\
\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right) - {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(1 - maxCos\right)\right)}
\end{array}
Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.6%
Simplified54.7%
Taylor expanded in ux around 0 98.9%
fma-def98.9%
+-commutative98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
distribute-lft-in98.9%
metadata-eval98.9%
associate--l+98.9%
mul-1-neg98.9%
sub-neg98.9%
associate-*r*98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in ux around 0 98.9%
Final simplification98.9%
(FPCore (ux uy maxCos)
:precision binary32
(*
(cos (* uy (* 2.0 PI)))
(sqrt
(+
(* ux (+ 2.0 (* maxCos -2.0)))
(* (pow ux 2.0) (+ -1.0 (* 2.0 maxCos)))))))
float code(float ux, float uy, float maxCos) {
return cosf((uy * (2.0f * ((float) M_PI)))) * sqrtf(((ux * (2.0f + (maxCos * -2.0f))) + (powf(ux, 2.0f) * (-1.0f + (2.0f * maxCos)))));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(Float32(Float32(ux * Float32(Float32(2.0) + Float32(maxCos * Float32(-2.0)))) + Float32((ux ^ Float32(2.0)) * Float32(Float32(-1.0) + Float32(Float32(2.0) * maxCos)))))) end
function tmp = code(ux, uy, maxCos) tmp = cos((uy * (single(2.0) * single(pi)))) * sqrt(((ux * (single(2.0) + (maxCos * single(-2.0)))) + ((ux ^ single(2.0)) * (single(-1.0) + (single(2.0) * maxCos))))); end
\begin{array}{l}
\\
\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + maxCos \cdot -2\right) + {ux}^{2} \cdot \left(-1 + 2 \cdot maxCos\right)}
\end{array}
Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.6%
Simplified54.7%
Taylor expanded in maxCos around 0 54.4%
Taylor expanded in ux around 0 98.4%
Final simplification98.4%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* 2.0 uy) 0.00014000000373926014)
(sqrt
(-
(* ux (- 2.0 (* 2.0 maxCos)))
(* (pow ux 2.0) (* (- 1.0 maxCos) (- 1.0 maxCos)))))
(* (cos (* uy (* 2.0 PI))) (sqrt (- (* ux 2.0) (pow ux 2.0))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if ((2.0f * uy) <= 0.00014000000373926014f) {
tmp = sqrtf(((ux * (2.0f - (2.0f * maxCos))) - (powf(ux, 2.0f) * ((1.0f - maxCos) * (1.0f - maxCos)))));
} else {
tmp = cosf((uy * (2.0f * ((float) M_PI)))) * sqrtf(((ux * 2.0f) - powf(ux, 2.0f)));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (Float32(Float32(2.0) * uy) <= Float32(0.00014000000373926014)) tmp = sqrt(Float32(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))) - Float32((ux ^ Float32(2.0)) * Float32(Float32(Float32(1.0) - maxCos) * Float32(Float32(1.0) - maxCos))))); else tmp = Float32(cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(Float32(Float32(ux * Float32(2.0)) - (ux ^ Float32(2.0))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if ((single(2.0) * uy) <= single(0.00014000000373926014)) tmp = sqrt(((ux * (single(2.0) - (single(2.0) * maxCos))) - ((ux ^ single(2.0)) * ((single(1.0) - maxCos) * (single(1.0) - maxCos))))); else tmp = cos((uy * (single(2.0) * single(pi)))) * sqrt(((ux * single(2.0)) - (ux ^ single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.00014000000373926014:\\
\;\;\;\;\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right) - {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(1 - maxCos\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot 2 - {ux}^{2}}\\
\end{array}
\end{array}
if (*.f32 uy 2) < 1.40000004e-4Initial program 55.7%
associate-*l*55.7%
sub-neg55.7%
+-commutative55.7%
distribute-rgt-neg-in55.7%
fma-def55.9%
Simplified55.8%
Taylor expanded in ux around -inf 99.6%
+-commutative99.6%
mul-1-neg99.6%
unsub-neg99.6%
associate-*r*99.6%
mul-1-neg99.6%
sub-neg99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
sub-neg99.6%
mul-1-neg99.6%
unsub-neg99.6%
mul-1-neg99.6%
sub-neg99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in uy around 0 99.6%
if 1.40000004e-4 < (*.f32 uy 2) Initial program 53.4%
associate-*l*53.4%
sub-neg53.4%
+-commutative53.4%
distribute-rgt-neg-in53.4%
fma-def53.4%
Simplified53.6%
Taylor expanded in ux around 0 98.1%
fma-def98.1%
+-commutative98.1%
sub-neg98.1%
metadata-eval98.1%
+-commutative98.1%
distribute-lft-in98.1%
metadata-eval98.1%
associate--l+98.1%
mul-1-neg98.1%
sub-neg98.1%
associate-*r*98.1%
sub-neg98.1%
metadata-eval98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in maxCos around 0 92.7%
+-commutative92.7%
mul-1-neg92.7%
unsub-neg92.7%
*-commutative92.7%
Simplified92.7%
Final simplification96.1%
(FPCore (ux uy maxCos) :precision binary32 (* (cos (* uy (* 2.0 PI))) (sqrt (- (* ux (- 2.0 (* 2.0 maxCos))) (pow ux 2.0)))))
float code(float ux, float uy, float maxCos) {
return cosf((uy * (2.0f * ((float) M_PI)))) * sqrtf(((ux * (2.0f - (2.0f * maxCos))) - powf(ux, 2.0f)));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(Float32(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))) - (ux ^ Float32(2.0))))) end
function tmp = code(ux, uy, maxCos) tmp = cos((uy * (single(2.0) * single(pi)))) * sqrt(((ux * (single(2.0) - (single(2.0) * maxCos))) - (ux ^ single(2.0)))); end
\begin{array}{l}
\\
\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right) - {ux}^{2}}
\end{array}
Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.6%
Simplified54.7%
Taylor expanded in ux around 0 98.9%
fma-def98.9%
+-commutative98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
distribute-lft-in98.9%
metadata-eval98.9%
associate--l+98.9%
mul-1-neg98.9%
sub-neg98.9%
associate-*r*98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
Simplified98.9%
Taylor expanded in ux around 0 98.9%
Taylor expanded in maxCos around 0 97.8%
neg-mul-197.8%
Simplified97.8%
Final simplification97.8%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))) (t_1 (cos (* PI (* 2.0 uy)))))
(if (<= t_0 0.9998199939727783)
(* t_1 (sqrt (+ 1.0 (* t_0 (- (+ ux -1.0) (* ux maxCos))))))
(* t_1 (sqrt (* ux (- 2.0 (* 2.0 maxCos))))))))
float code(float ux, float uy, float maxCos) {
float t_0 = (1.0f - ux) + (ux * maxCos);
float t_1 = cosf((((float) M_PI) * (2.0f * uy)));
float tmp;
if (t_0 <= 0.9998199939727783f) {
tmp = t_1 * sqrtf((1.0f + (t_0 * ((ux + -1.0f) - (ux * maxCos)))));
} else {
tmp = t_1 * sqrtf((ux * (2.0f - (2.0f * maxCos))));
}
return tmp;
}
function code(ux, uy, maxCos) t_0 = Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos)) t_1 = cos(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) tmp = Float32(0.0) if (t_0 <= Float32(0.9998199939727783)) tmp = Float32(t_1 * sqrt(Float32(Float32(1.0) + Float32(t_0 * Float32(Float32(ux + Float32(-1.0)) - Float32(ux * maxCos)))))); else tmp = Float32(t_1 * sqrt(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) t_0 = (single(1.0) - ux) + (ux * maxCos); t_1 = cos((single(pi) * (single(2.0) * uy))); tmp = single(0.0); if (t_0 <= single(0.9998199939727783)) tmp = t_1 * sqrt((single(1.0) + (t_0 * ((ux + single(-1.0)) - (ux * maxCos))))); else tmp = t_1 * sqrt((ux * (single(2.0) - (single(2.0) * maxCos)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
t_1 := \cos \left(\pi \cdot \left(2 \cdot uy\right)\right)\\
\mathbf{if}\;t_0 \leq 0.9998199939727783:\\
\;\;\;\;t_1 \cdot \sqrt{1 + t_0 \cdot \left(\left(ux + -1\right) - ux \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\\
\end{array}
\end{array}
if (+.f32 (-.f32 1 ux) (*.f32 ux maxCos)) < 0.999819994Initial program 89.8%
if 0.999819994 < (+.f32 (-.f32 1 ux) (*.f32 ux maxCos)) Initial program 35.4%
Taylor expanded in ux around 0 93.2%
Final simplification92.0%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (+ (- 1.0 ux) (* ux maxCos)) 0.9998199939727783)
(*
(cos (* 2.0 (* uy PI)))
(sqrt
(+ 1.0 (* (- (+ 1.0 (* ux maxCos)) ux) (+ -1.0 (* ux (- 1.0 maxCos)))))))
(* (cos (* PI (* 2.0 uy))) (sqrt (* ux (- 2.0 (* 2.0 maxCos)))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (((1.0f - ux) + (ux * maxCos)) <= 0.9998199939727783f) {
tmp = cosf((2.0f * (uy * ((float) M_PI)))) * sqrtf((1.0f + (((1.0f + (ux * maxCos)) - ux) * (-1.0f + (ux * (1.0f - maxCos))))));
} else {
tmp = cosf((((float) M_PI) * (2.0f * uy))) * sqrtf((ux * (2.0f - (2.0f * maxCos))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos)) <= Float32(0.9998199939727783)) tmp = Float32(cos(Float32(Float32(2.0) * Float32(uy * Float32(pi)))) * sqrt(Float32(Float32(1.0) + Float32(Float32(Float32(Float32(1.0) + Float32(ux * maxCos)) - ux) * Float32(Float32(-1.0) + Float32(ux * Float32(Float32(1.0) - maxCos))))))); else tmp = Float32(cos(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) * sqrt(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (((single(1.0) - ux) + (ux * maxCos)) <= single(0.9998199939727783)) tmp = cos((single(2.0) * (uy * single(pi)))) * sqrt((single(1.0) + (((single(1.0) + (ux * maxCos)) - ux) * (single(-1.0) + (ux * (single(1.0) - maxCos)))))); else tmp = cos((single(pi) * (single(2.0) * uy))) * sqrt((ux * (single(2.0) - (single(2.0) * maxCos)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(1 - ux\right) + ux \cdot maxCos \leq 0.9998199939727783:\\
\;\;\;\;\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{1 + \left(\left(1 + ux \cdot maxCos\right) - ux\right) \cdot \left(-1 + ux \cdot \left(1 - maxCos\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\\
\end{array}
\end{array}
if (+.f32 (-.f32 1 ux) (*.f32 ux maxCos)) < 0.999819994Initial program 89.8%
associate-*l*89.8%
sub-neg89.8%
+-commutative89.8%
distribute-rgt-neg-in89.8%
fma-def90.0%
Simplified89.9%
Taylor expanded in uy around inf 90.0%
if 0.999819994 < (+.f32 (-.f32 1 ux) (*.f32 ux maxCos)) Initial program 35.4%
Taylor expanded in ux around 0 93.2%
Final simplification92.1%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (- (* ux (- 2.0 (* 2.0 maxCos))) (* (pow ux 2.0) (* (- 1.0 maxCos) (- 1.0 maxCos))))))
float code(float ux, float uy, float maxCos) {
return sqrtf(((ux * (2.0f - (2.0f * maxCos))) - (powf(ux, 2.0f) * ((1.0f - maxCos) * (1.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 - (2.0e0 * maxcos))) - ((ux ** 2.0e0) * ((1.0e0 - maxcos) * (1.0e0 - maxcos)))))
end function
function code(ux, uy, maxCos) return sqrt(Float32(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))) - Float32((ux ^ Float32(2.0)) * Float32(Float32(Float32(1.0) - maxCos) * Float32(Float32(1.0) - maxCos))))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt(((ux * (single(2.0) - (single(2.0) * maxCos))) - ((ux ^ single(2.0)) * ((single(1.0) - maxCos) * (single(1.0) - maxCos))))); end
\begin{array}{l}
\\
\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right) - {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(1 - maxCos\right)\right)}
\end{array}
Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.6%
Simplified54.7%
Taylor expanded in ux around -inf 98.9%
+-commutative98.9%
mul-1-neg98.9%
unsub-neg98.9%
associate-*r*98.9%
mul-1-neg98.9%
sub-neg98.9%
sub-neg98.9%
metadata-eval98.9%
+-commutative98.9%
sub-neg98.9%
mul-1-neg98.9%
unsub-neg98.9%
mul-1-neg98.9%
sub-neg98.9%
metadata-eval98.9%
Simplified98.9%
Taylor expanded in uy around 0 74.7%
Final simplification74.7%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (- (* ux (- (+ 1.0 (- 1.0 maxCos)) maxCos)) (pow (* ux (+ maxCos -1.0)) 2.0))))
float code(float ux, float uy, float maxCos) {
return sqrtf(((ux * ((1.0f + (1.0f - maxCos)) - maxCos)) - powf((ux * (maxCos + -1.0f)), 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 * ((1.0e0 + (1.0e0 - maxcos)) - maxcos)) - ((ux * (maxcos + (-1.0e0))) ** 2.0e0)))
end function
function code(ux, uy, maxCos) return sqrt(Float32(Float32(ux * Float32(Float32(Float32(1.0) + Float32(Float32(1.0) - maxCos)) - maxCos)) - (Float32(ux * Float32(maxCos + Float32(-1.0))) ^ Float32(2.0)))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt(((ux * ((single(1.0) + (single(1.0) - maxCos)) - maxCos)) - ((ux * (maxCos + single(-1.0))) ^ single(2.0)))); end
\begin{array}{l}
\\
\sqrt{ux \cdot \left(\left(1 + \left(1 - maxCos\right)\right) - maxCos\right) - {\left(ux \cdot \left(maxCos + -1\right)\right)}^{2}}
\end{array}
Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.6%
Simplified54.7%
Taylor expanded in uy around 0 45.8%
associate--l+45.8%
fma-neg45.8%
mul-1-neg45.8%
fma-def45.8%
distribute-rgt-in45.8%
metadata-eval45.8%
sub-neg45.8%
flip-+46.2%
metadata-eval46.2%
pow246.2%
sub-neg46.2%
metadata-eval46.2%
sub-neg46.2%
metadata-eval46.2%
Applied egg-rr46.2%
Taylor expanded in ux around -inf 74.6%
+-commutative74.6%
mul-1-neg74.6%
unsub-neg74.6%
mul-1-neg74.6%
unsub-neg74.6%
sub-neg74.6%
metadata-eval74.6%
unpow274.6%
unpow274.6%
swap-sqr74.6%
sub-neg74.6%
metadata-eval74.6%
sub-neg74.6%
metadata-eval74.6%
unpow274.6%
Simplified74.6%
Final simplification74.6%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (- (* ux 2.0) (pow ux 2.0))))
float code(float ux, float uy, float maxCos) {
return sqrtf(((ux * 2.0f) - powf(ux, 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) - (ux ** 2.0e0)))
end function
function code(ux, uy, maxCos) return sqrt(Float32(Float32(ux * Float32(2.0)) - (ux ^ Float32(2.0)))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt(((ux * single(2.0)) - (ux ^ single(2.0)))); end
\begin{array}{l}
\\
\sqrt{ux \cdot 2 - {ux}^{2}}
\end{array}
Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.6%
Simplified54.7%
Taylor expanded in uy around 0 45.8%
Taylor expanded in ux around 0 74.6%
Taylor expanded in maxCos around 0 70.8%
+-commutative70.8%
neg-mul-170.8%
unsub-neg70.8%
*-commutative70.8%
Simplified70.8%
Final simplification70.8%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* ux (+ maxCos -1.0))))
(if (<= ux 0.00014000000373926014)
(sqrt (* ux (- 2.0 (* 2.0 maxCos))))
(sqrt
(+
1.0
(*
(+ 1.0 t_0)
(/ (+ -1.0 (* t_0 t_0)) (+ 1.0 (* ux (- 1.0 maxCos))))))))))
float code(float ux, float uy, float maxCos) {
float t_0 = ux * (maxCos + -1.0f);
float tmp;
if (ux <= 0.00014000000373926014f) {
tmp = sqrtf((ux * (2.0f - (2.0f * maxCos))));
} else {
tmp = sqrtf((1.0f + ((1.0f + t_0) * ((-1.0f + (t_0 * t_0)) / (1.0f + (ux * (1.0f - maxCos)))))));
}
return tmp;
}
real(4) function code(ux, uy, maxcos)
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
real(4) :: t_0
real(4) :: tmp
t_0 = ux * (maxcos + (-1.0e0))
if (ux <= 0.00014000000373926014e0) then
tmp = sqrt((ux * (2.0e0 - (2.0e0 * maxcos))))
else
tmp = sqrt((1.0e0 + ((1.0e0 + t_0) * (((-1.0e0) + (t_0 * t_0)) / (1.0e0 + (ux * (1.0e0 - maxcos)))))))
end if
code = tmp
end function
function code(ux, uy, maxCos) t_0 = Float32(ux * Float32(maxCos + Float32(-1.0))) tmp = Float32(0.0) if (ux <= Float32(0.00014000000373926014)) tmp = sqrt(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos)))); else tmp = sqrt(Float32(Float32(1.0) + Float32(Float32(Float32(1.0) + t_0) * Float32(Float32(Float32(-1.0) + Float32(t_0 * t_0)) / Float32(Float32(1.0) + Float32(ux * Float32(Float32(1.0) - maxCos))))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) t_0 = ux * (maxCos + single(-1.0)); tmp = single(0.0); if (ux <= single(0.00014000000373926014)) tmp = sqrt((ux * (single(2.0) - (single(2.0) * maxCos)))); else tmp = sqrt((single(1.0) + ((single(1.0) + t_0) * ((single(-1.0) + (t_0 * t_0)) / (single(1.0) + (ux * (single(1.0) - maxCos))))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := ux \cdot \left(maxCos + -1\right)\\
\mathbf{if}\;ux \leq 0.00014000000373926014:\\
\;\;\;\;\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 + \left(1 + t_0\right) \cdot \frac{-1 + t_0 \cdot t_0}{1 + ux \cdot \left(1 - maxCos\right)}}\\
\end{array}
\end{array}
if ux < 1.40000004e-4Initial program 35.0%
associate-*l*35.0%
sub-neg35.0%
+-commutative35.0%
distribute-rgt-neg-in35.0%
fma-def35.0%
Simplified35.2%
Taylor expanded in uy around 0 31.5%
Taylor expanded in ux around 0 70.4%
if 1.40000004e-4 < ux Initial program 89.4%
associate-*l*89.4%
sub-neg89.4%
+-commutative89.4%
distribute-rgt-neg-in89.4%
fma-def89.6%
Simplified89.5%
Taylor expanded in uy around 0 71.2%
associate--l+71.3%
fma-neg71.3%
mul-1-neg71.3%
fma-def71.3%
distribute-rgt-in71.3%
metadata-eval71.3%
sub-neg71.3%
flip-+71.7%
metadata-eval71.7%
pow271.7%
sub-neg71.7%
metadata-eval71.7%
sub-neg71.7%
metadata-eval71.7%
Applied egg-rr71.7%
unpow271.7%
Applied egg-rr71.7%
Final simplification70.9%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.00015999999595806003)
(sqrt (* ux (- 2.0 (* 2.0 maxCos))))
(sqrt
(+
1.0
(* (+ 1.0 (* ux (+ maxCos -1.0))) (+ -1.0 (* ux (- 1.0 maxCos))))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00015999999595806003f) {
tmp = sqrtf((ux * (2.0f - (2.0f * maxCos))));
} else {
tmp = sqrtf((1.0f + ((1.0f + (ux * (maxCos + -1.0f))) * (-1.0f + (ux * (1.0f - maxCos))))));
}
return tmp;
}
real(4) function code(ux, uy, maxcos)
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
real(4) :: tmp
if (ux <= 0.00015999999595806003e0) then
tmp = sqrt((ux * (2.0e0 - (2.0e0 * maxcos))))
else
tmp = sqrt((1.0e0 + ((1.0e0 + (ux * (maxcos + (-1.0e0)))) * ((-1.0e0) + (ux * (1.0e0 - maxcos))))))
end if
code = tmp
end function
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.00015999999595806003)) tmp = sqrt(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos)))); else tmp = sqrt(Float32(Float32(1.0) + Float32(Float32(Float32(1.0) + Float32(ux * Float32(maxCos + Float32(-1.0)))) * Float32(Float32(-1.0) + Float32(ux * Float32(Float32(1.0) - maxCos)))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.00015999999595806003)) tmp = sqrt((ux * (single(2.0) - (single(2.0) * maxCos)))); else tmp = sqrt((single(1.0) + ((single(1.0) + (ux * (maxCos + single(-1.0)))) * (single(-1.0) + (ux * (single(1.0) - maxCos)))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00015999999595806003:\\
\;\;\;\;\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right) \cdot \left(-1 + ux \cdot \left(1 - maxCos\right)\right)}\\
\end{array}
\end{array}
if ux < 1.59999996e-4Initial program 35.4%
associate-*l*35.4%
sub-neg35.4%
+-commutative35.4%
distribute-rgt-neg-in35.4%
fma-def35.4%
Simplified35.6%
Taylor expanded in uy around 0 31.7%
Taylor expanded in ux around 0 70.2%
if 1.59999996e-4 < ux Initial program 89.8%
associate-*l*89.8%
sub-neg89.8%
+-commutative89.8%
distribute-rgt-neg-in89.8%
fma-def90.0%
Simplified89.9%
Taylor expanded in uy around 0 71.6%
associate--l+71.7%
fma-neg71.7%
mul-1-neg71.7%
fma-def71.7%
distribute-rgt-in71.7%
metadata-eval71.7%
sub-neg71.7%
+-commutative71.7%
sub-neg71.7%
metadata-eval71.7%
Applied egg-rr71.7%
Final simplification70.7%
(FPCore (ux uy maxCos) :precision binary32 (if (<= ux 0.00015999999595806003) (sqrt (* ux (- 2.0 (* 2.0 maxCos)))) (sqrt (+ 1.0 (* (- 1.0 ux) (+ -1.0 (* ux (- 1.0 maxCos))))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00015999999595806003f) {
tmp = sqrtf((ux * (2.0f - (2.0f * maxCos))));
} else {
tmp = sqrtf((1.0f + ((1.0f - ux) * (-1.0f + (ux * (1.0f - maxCos))))));
}
return tmp;
}
real(4) function code(ux, uy, maxcos)
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
real(4) :: tmp
if (ux <= 0.00015999999595806003e0) then
tmp = sqrt((ux * (2.0e0 - (2.0e0 * maxcos))))
else
tmp = sqrt((1.0e0 + ((1.0e0 - ux) * ((-1.0e0) + (ux * (1.0e0 - maxcos))))))
end if
code = tmp
end function
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.00015999999595806003)) tmp = sqrt(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos)))); else tmp = sqrt(Float32(Float32(1.0) + Float32(Float32(Float32(1.0) - ux) * Float32(Float32(-1.0) + Float32(ux * Float32(Float32(1.0) - maxCos)))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.00015999999595806003)) tmp = sqrt((ux * (single(2.0) - (single(2.0) * maxCos)))); else tmp = sqrt((single(1.0) + ((single(1.0) - ux) * (single(-1.0) + (ux * (single(1.0) - maxCos)))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00015999999595806003:\\
\;\;\;\;\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 + \left(1 - ux\right) \cdot \left(-1 + ux \cdot \left(1 - maxCos\right)\right)}\\
\end{array}
\end{array}
if ux < 1.59999996e-4Initial program 35.4%
associate-*l*35.4%
sub-neg35.4%
+-commutative35.4%
distribute-rgt-neg-in35.4%
fma-def35.4%
Simplified35.6%
Taylor expanded in uy around 0 31.7%
Taylor expanded in ux around 0 70.2%
if 1.59999996e-4 < ux Initial program 89.8%
associate-*l*89.8%
sub-neg89.8%
+-commutative89.8%
distribute-rgt-neg-in89.8%
fma-def90.0%
Simplified89.9%
Taylor expanded in uy around 0 71.6%
Taylor expanded in maxCos around 0 68.6%
Final simplification69.7%
(FPCore (ux uy maxCos) :precision binary32 (if (<= ux 0.00015999999595806003) (sqrt (* ux (- 2.0 (* 2.0 maxCos)))) (sqrt (+ 1.0 (* (- 1.0 ux) (+ ux -1.0))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00015999999595806003f) {
tmp = sqrtf((ux * (2.0f - (2.0f * maxCos))));
} else {
tmp = sqrtf((1.0f + ((1.0f - ux) * (ux + -1.0f))));
}
return tmp;
}
real(4) function code(ux, uy, maxcos)
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
real(4) :: tmp
if (ux <= 0.00015999999595806003e0) then
tmp = sqrt((ux * (2.0e0 - (2.0e0 * maxcos))))
else
tmp = sqrt((1.0e0 + ((1.0e0 - ux) * (ux + (-1.0e0)))))
end if
code = tmp
end function
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.00015999999595806003)) tmp = sqrt(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos)))); else tmp = sqrt(Float32(Float32(1.0) + Float32(Float32(Float32(1.0) - ux) * Float32(ux + Float32(-1.0))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.00015999999595806003)) tmp = sqrt((ux * (single(2.0) - (single(2.0) * maxCos)))); else tmp = sqrt((single(1.0) + ((single(1.0) - ux) * (ux + single(-1.0))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00015999999595806003:\\
\;\;\;\;\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 + \left(1 - ux\right) \cdot \left(ux + -1\right)}\\
\end{array}
\end{array}
if ux < 1.59999996e-4Initial program 35.4%
associate-*l*35.4%
sub-neg35.4%
+-commutative35.4%
distribute-rgt-neg-in35.4%
fma-def35.4%
Simplified35.6%
Taylor expanded in uy around 0 31.7%
Taylor expanded in ux around 0 70.2%
if 1.59999996e-4 < ux Initial program 89.8%
associate-*l*89.8%
sub-neg89.8%
+-commutative89.8%
distribute-rgt-neg-in89.8%
fma-def90.0%
Simplified89.9%
Taylor expanded in uy around 0 71.6%
Taylor expanded in maxCos around 0 68.3%
Final simplification69.5%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (* ux (- 2.0 (* 2.0 maxCos)))))
float code(float ux, float uy, float maxCos) {
return sqrtf((ux * (2.0f - (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 - (2.0e0 * maxcos))))
end function
function code(ux, uy, maxCos) return sqrt(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos)))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt((ux * (single(2.0) - (single(2.0) * maxCos)))); end
\begin{array}{l}
\\
\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}
\end{array}
Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.6%
Simplified54.7%
Taylor expanded in uy around 0 45.8%
Taylor expanded in ux around 0 61.6%
Final simplification61.6%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (* ux (- -2.0))))
float code(float ux, float uy, float maxCos) {
return sqrtf((ux * -(-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)))
end function
function code(ux, uy, maxCos) return sqrt(Float32(ux * Float32(-Float32(-2.0)))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt((ux * -single(-2.0))); end
\begin{array}{l}
\\
\sqrt{ux \cdot \left(--2\right)}
\end{array}
Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.6%
Simplified54.7%
Taylor expanded in uy around 0 45.8%
Taylor expanded in ux around 0 61.6%
Taylor expanded in maxCos around 0 59.4%
Final simplification59.4%
herbie shell --seed 2023322
(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)))))))