
(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 19 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 (cbrt (* (pow (* uy 2.0) 3.0) (pow PI 3.0))))
(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(cbrtf((powf((uy * 2.0f), 3.0f) * powf(((float) M_PI), 3.0f)))) * 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(cbrt(Float32((Float32(uy * Float32(2.0)) ^ Float32(3.0)) * (Float32(pi) ^ Float32(3.0))))) * sqrt(Float32(Float32(Float32(Float32(1.0) - maxCos) * Float32((ux ^ Float32(2.0)) * Float32(maxCos + Float32(-1.0)))) + Float32(ux * Float32(Float32(Float32(Float32(1.0) - maxCos) - maxCos) - Float32(-1.0)))))) end
\begin{array}{l}
\\
\cos \left(\sqrt[3]{{\left(uy \cdot 2\right)}^{3} \cdot {\pi}^{3}}\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot \left({ux}^{2} \cdot \left(maxCos + -1\right)\right) + ux \cdot \left(\left(\left(1 - maxCos\right) - maxCos\right) - -1\right)}
\end{array}
Initial program 54.7%
associate-*l*54.7%
sub-neg54.7%
+-commutative54.7%
distribute-rgt-neg-in54.7%
fma-def54.8%
Simplified55.0%
Taylor expanded in ux around -inf 99.0%
+-commutative99.0%
mul-1-neg99.0%
unsub-neg99.0%
associate-*r*99.0%
sub-neg99.0%
metadata-eval99.0%
mul-1-neg99.0%
sub-neg99.0%
+-commutative99.0%
sub-neg99.0%
mul-1-neg99.0%
unsub-neg99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
Simplified99.0%
associate-*r*99.0%
add-cbrt-cube99.0%
add-cbrt-cube99.0%
cbrt-unprod99.0%
pow399.0%
pow399.0%
Applied egg-rr99.0%
Final simplification99.0%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sqrt
(+
(* (- 1.0 maxCos) (* (pow ux 2.0) (+ maxCos -1.0)))
(* ux (- (- (- 1.0 maxCos) maxCos) -1.0))))
(cos (log1p (expm1 (* uy (* 2.0 PI)))))))
float code(float ux, float uy, float maxCos) {
return sqrtf((((1.0f - maxCos) * (powf(ux, 2.0f) * (maxCos + -1.0f))) + (ux * (((1.0f - maxCos) - maxCos) - -1.0f)))) * cosf(log1pf(expm1f((uy * (2.0f * ((float) M_PI))))));
}
function code(ux, uy, maxCos) return Float32(sqrt(Float32(Float32(Float32(Float32(1.0) - maxCos) * Float32((ux ^ Float32(2.0)) * Float32(maxCos + Float32(-1.0)))) + Float32(ux * Float32(Float32(Float32(Float32(1.0) - maxCos) - maxCos) - Float32(-1.0))))) * cos(log1p(expm1(Float32(uy * Float32(Float32(2.0) * Float32(pi))))))) end
\begin{array}{l}
\\
\sqrt{\left(1 - maxCos\right) \cdot \left({ux}^{2} \cdot \left(maxCos + -1\right)\right) + ux \cdot \left(\left(\left(1 - maxCos\right) - maxCos\right) - -1\right)} \cdot \cos \left(\mathsf{log1p}\left(\mathsf{expm1}\left(uy \cdot \left(2 \cdot \pi\right)\right)\right)\right)
\end{array}
Initial program 54.7%
associate-*l*54.7%
sub-neg54.7%
+-commutative54.7%
distribute-rgt-neg-in54.7%
fma-def54.8%
Simplified55.0%
Taylor expanded in ux around -inf 99.0%
+-commutative99.0%
mul-1-neg99.0%
unsub-neg99.0%
associate-*r*99.0%
sub-neg99.0%
metadata-eval99.0%
mul-1-neg99.0%
sub-neg99.0%
+-commutative99.0%
sub-neg99.0%
mul-1-neg99.0%
unsub-neg99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
Simplified99.0%
log1p-expm1-u99.0%
Applied egg-rr99.0%
Final simplification99.0%
(FPCore (ux uy maxCos)
:precision binary32
(*
(cos (* 2.0 (* uy PI)))
(sqrt
(+
(* (pow ux 2.0) (* (- 1.0 maxCos) (+ maxCos -1.0)))
(* ux (- 2.0 (* 2.0 maxCos)))))))
float code(float ux, float uy, float maxCos) {
return cosf((2.0f * (uy * ((float) M_PI)))) * sqrtf(((powf(ux, 2.0f) * ((1.0f - maxCos) * (maxCos + -1.0f))) + (ux * (2.0f - (2.0f * maxCos)))));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(Float32(2.0) * Float32(uy * Float32(pi)))) * sqrt(Float32(Float32((ux ^ Float32(2.0)) * Float32(Float32(Float32(1.0) - maxCos) * Float32(maxCos + Float32(-1.0)))) + Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos)))))) end
function tmp = code(ux, uy, maxCos) tmp = cos((single(2.0) * (uy * single(pi)))) * sqrt((((ux ^ single(2.0)) * ((single(1.0) - maxCos) * (maxCos + single(-1.0)))) + (ux * (single(2.0) - (single(2.0) * maxCos))))); end
\begin{array}{l}
\\
\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right) + ux \cdot \left(2 - 2 \cdot maxCos\right)}
\end{array}
Initial program 54.7%
associate-*l*54.7%
sub-neg54.7%
+-commutative54.7%
distribute-rgt-neg-in54.7%
fma-def54.8%
Simplified55.0%
Taylor expanded in ux around -inf 99.0%
+-commutative99.0%
mul-1-neg99.0%
unsub-neg99.0%
associate-*r*99.0%
sub-neg99.0%
metadata-eval99.0%
mul-1-neg99.0%
sub-neg99.0%
+-commutative99.0%
sub-neg99.0%
mul-1-neg99.0%
unsub-neg99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
Simplified99.0%
Taylor expanded in uy around inf 99.0%
Final simplification99.0%
(FPCore (ux uy maxCos)
:precision binary32
(*
(cos (* 2.0 (* uy PI)))
(sqrt
(+
(* (pow ux 2.0) (+ -1.0 (* 2.0 maxCos)))
(* ux (- 2.0 (* 2.0 maxCos)))))))
float code(float ux, float uy, float maxCos) {
return cosf((2.0f * (uy * ((float) M_PI)))) * sqrtf(((powf(ux, 2.0f) * (-1.0f + (2.0f * maxCos))) + (ux * (2.0f - (2.0f * maxCos)))));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(Float32(2.0) * Float32(uy * Float32(pi)))) * sqrt(Float32(Float32((ux ^ Float32(2.0)) * Float32(Float32(-1.0) + Float32(Float32(2.0) * maxCos))) + Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos)))))) end
function tmp = code(ux, uy, maxCos) tmp = cos((single(2.0) * (uy * single(pi)))) * sqrt((((ux ^ single(2.0)) * (single(-1.0) + (single(2.0) * maxCos))) + (ux * (single(2.0) - (single(2.0) * maxCos))))); end
\begin{array}{l}
\\
\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{{ux}^{2} \cdot \left(-1 + 2 \cdot maxCos\right) + ux \cdot \left(2 - 2 \cdot maxCos\right)}
\end{array}
Initial program 54.7%
associate-*l*54.7%
sub-neg54.7%
+-commutative54.7%
distribute-rgt-neg-in54.7%
fma-def54.8%
Simplified55.0%
Taylor expanded in ux around -inf 99.0%
+-commutative99.0%
mul-1-neg99.0%
unsub-neg99.0%
associate-*r*99.0%
sub-neg99.0%
metadata-eval99.0%
mul-1-neg99.0%
sub-neg99.0%
+-commutative99.0%
sub-neg99.0%
mul-1-neg99.0%
unsub-neg99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
Simplified99.0%
Taylor expanded in uy around inf 99.0%
Taylor expanded in maxCos around 0 98.5%
Final simplification98.5%
(FPCore (ux uy maxCos) :precision binary32 (* (cos (* 2.0 (* uy PI))) (sqrt (- (* ux (- 2.0 (* 2.0 maxCos))) (pow ux 2.0)))))
float code(float ux, float uy, float maxCos) {
return cosf((2.0f * (uy * ((float) M_PI)))) * sqrtf(((ux * (2.0f - (2.0f * maxCos))) - powf(ux, 2.0f)));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(Float32(2.0) * Float32(uy * 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((single(2.0) * (uy * single(pi)))) * sqrt(((ux * (single(2.0) - (single(2.0) * maxCos))) - (ux ^ single(2.0)))); end
\begin{array}{l}
\\
\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right) - {ux}^{2}}
\end{array}
Initial program 54.7%
associate-*l*54.7%
sub-neg54.7%
+-commutative54.7%
distribute-rgt-neg-in54.7%
fma-def54.8%
Simplified55.0%
Taylor expanded in ux around -inf 99.0%
+-commutative99.0%
mul-1-neg99.0%
unsub-neg99.0%
associate-*r*99.0%
sub-neg99.0%
metadata-eval99.0%
mul-1-neg99.0%
sub-neg99.0%
+-commutative99.0%
sub-neg99.0%
mul-1-neg99.0%
unsub-neg99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
Simplified99.0%
Taylor expanded in uy around inf 99.0%
Taylor expanded in maxCos around 0 98.0%
Final simplification98.0%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- (* 2.0 ux) (pow ux 2.0))) (cos (* (* uy 2.0) PI))))
float code(float ux, float uy, float maxCos) {
return sqrtf(((2.0f * ux) - powf(ux, 2.0f))) * cosf(((uy * 2.0f) * ((float) M_PI)));
}
function code(ux, uy, maxCos) return Float32(sqrt(Float32(Float32(Float32(2.0) * ux) - (ux ^ Float32(2.0)))) * cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi)))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt(((single(2.0) * ux) - (ux ^ single(2.0)))) * cos(((uy * single(2.0)) * single(pi))); end
\begin{array}{l}
\\
\sqrt{2 \cdot ux - {ux}^{2}} \cdot \cos \left(\left(uy \cdot 2\right) \cdot \pi\right)
\end{array}
Initial program 54.7%
associate-*l*54.7%
sub-neg54.7%
+-commutative54.7%
distribute-rgt-neg-in54.7%
fma-def54.8%
Simplified55.0%
Taylor expanded in ux around -inf 99.0%
+-commutative99.0%
mul-1-neg99.0%
unsub-neg99.0%
associate-*r*99.0%
sub-neg99.0%
metadata-eval99.0%
mul-1-neg99.0%
sub-neg99.0%
+-commutative99.0%
sub-neg99.0%
mul-1-neg99.0%
unsub-neg99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
Simplified99.0%
Taylor expanded in maxCos around 0 93.1%
associate-*r*93.1%
*-commutative93.1%
*-commutative93.1%
*-commutative93.1%
cancel-sign-sub-inv93.1%
metadata-eval93.1%
+-commutative93.1%
mul-1-neg93.1%
unsub-neg93.1%
*-commutative93.1%
Simplified93.1%
Final simplification93.1%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))) (t_1 (cos (* (* uy 2.0) PI))))
(if (<= t_0 0.9998000264167786)
(* t_1 (sqrt (+ 1.0 (* t_0 (- (+ ux -1.0) (* ux maxCos))))))
(* t_1 (sqrt (+ (* 2.0 ux) (* (* ux maxCos) -2.0)))))))
float code(float ux, float uy, float maxCos) {
float t_0 = (1.0f - ux) + (ux * maxCos);
float t_1 = cosf(((uy * 2.0f) * ((float) M_PI)));
float tmp;
if (t_0 <= 0.9998000264167786f) {
tmp = t_1 * sqrtf((1.0f + (t_0 * ((ux + -1.0f) - (ux * maxCos)))));
} else {
tmp = t_1 * sqrtf(((2.0f * ux) + ((ux * maxCos) * -2.0f)));
}
return tmp;
}
function code(ux, uy, maxCos) t_0 = Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos)) t_1 = cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) tmp = Float32(0.0) if (t_0 <= Float32(0.9998000264167786)) 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(Float32(Float32(2.0) * ux) + Float32(Float32(ux * maxCos) * Float32(-2.0))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) t_0 = (single(1.0) - ux) + (ux * maxCos); t_1 = cos(((uy * single(2.0)) * single(pi))); tmp = single(0.0); if (t_0 <= single(0.9998000264167786)) tmp = t_1 * sqrt((single(1.0) + (t_0 * ((ux + single(-1.0)) - (ux * maxCos))))); else tmp = t_1 * sqrt(((single(2.0) * ux) + ((ux * maxCos) * single(-2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
t_1 := \cos \left(\left(uy \cdot 2\right) \cdot \pi\right)\\
\mathbf{if}\;t_0 \leq 0.9998000264167786:\\
\;\;\;\;t_1 \cdot \sqrt{1 + t_0 \cdot \left(\left(ux + -1\right) - ux \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \sqrt{2 \cdot ux + \left(ux \cdot maxCos\right) \cdot -2}\\
\end{array}
\end{array}
if (+.f32 (-.f32 1 ux) (*.f32 ux maxCos)) < 0.999800026Initial program 88.5%
if 0.999800026 < (+.f32 (-.f32 1 ux) (*.f32 ux maxCos)) Initial program 35.5%
Taylor expanded in ux around 0 39.9%
Taylor expanded in maxCos around 0 92.8%
Final simplification91.2%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* uy 2.0) 0.0015999999595806003)
(sqrt
(+
(* (pow ux 2.0) (* (- 1.0 maxCos) (+ maxCos -1.0)))
(* ux (- 2.0 (* 2.0 maxCos)))))
(*
(cos (* uy (* 2.0 PI)))
(sqrt (* ux (- (+ 1.0 (- 1.0 maxCos)) maxCos))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if ((uy * 2.0f) <= 0.0015999999595806003f) {
tmp = sqrtf(((powf(ux, 2.0f) * ((1.0f - maxCos) * (maxCos + -1.0f))) + (ux * (2.0f - (2.0f * maxCos)))));
} else {
tmp = cosf((uy * (2.0f * ((float) M_PI)))) * sqrtf((ux * ((1.0f + (1.0f - maxCos)) - maxCos)));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (Float32(uy * Float32(2.0)) <= Float32(0.0015999999595806003)) tmp = sqrt(Float32(Float32((ux ^ Float32(2.0)) * Float32(Float32(Float32(1.0) - maxCos) * Float32(maxCos + Float32(-1.0)))) + Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))))); else tmp = Float32(cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(Float32(ux * Float32(Float32(Float32(1.0) + Float32(Float32(1.0) - maxCos)) - maxCos)))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if ((uy * single(2.0)) <= single(0.0015999999595806003)) tmp = sqrt((((ux ^ single(2.0)) * ((single(1.0) - maxCos) * (maxCos + single(-1.0)))) + (ux * (single(2.0) - (single(2.0) * maxCos))))); else tmp = cos((uy * (single(2.0) * single(pi)))) * sqrt((ux * ((single(1.0) + (single(1.0) - maxCos)) - maxCos))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \cdot 2 \leq 0.0015999999595806003:\\
\;\;\;\;\sqrt{{ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right) + ux \cdot \left(2 - 2 \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 - maxCos\right)\right) - maxCos\right)}\\
\end{array}
\end{array}
if (*.f32 uy 2) < 0.00159999996Initial program 53.7%
associate-*l*53.7%
sub-neg53.7%
+-commutative53.7%
distribute-rgt-neg-in53.7%
fma-def53.8%
Simplified53.9%
Taylor expanded in ux around -inf 99.3%
+-commutative99.3%
mul-1-neg99.3%
unsub-neg99.3%
associate-*r*99.3%
sub-neg99.3%
metadata-eval99.3%
mul-1-neg99.3%
sub-neg99.3%
+-commutative99.3%
sub-neg99.3%
mul-1-neg99.3%
unsub-neg99.3%
mul-1-neg99.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in uy around 0 97.6%
if 0.00159999996 < (*.f32 uy 2) Initial program 56.7%
associate-*l*56.7%
sub-neg56.7%
+-commutative56.7%
distribute-rgt-neg-in56.7%
fma-def56.7%
Simplified57.2%
Taylor expanded in ux around 0 76.4%
mul-1-neg76.4%
sub-neg76.4%
metadata-eval76.4%
+-commutative76.4%
Simplified76.4%
Final simplification90.2%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* uy 2.0) 0.0015999999595806003)
(sqrt
(+ (* (pow ux 2.0) (+ -1.0 (* 2.0 maxCos))) (* ux (- 2.0 (* 2.0 maxCos)))))
(* (cos (* (* uy 2.0) PI)) (sqrt (+ (* 2.0 ux) (* (* ux maxCos) -2.0))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if ((uy * 2.0f) <= 0.0015999999595806003f) {
tmp = sqrtf(((powf(ux, 2.0f) * (-1.0f + (2.0f * maxCos))) + (ux * (2.0f - (2.0f * maxCos)))));
} else {
tmp = cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf(((2.0f * ux) + ((ux * maxCos) * -2.0f)));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (Float32(uy * Float32(2.0)) <= Float32(0.0015999999595806003)) tmp = sqrt(Float32(Float32((ux ^ Float32(2.0)) * Float32(Float32(-1.0) + Float32(Float32(2.0) * maxCos))) + Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))))); else tmp = Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(Float32(2.0) * ux) + Float32(Float32(ux * maxCos) * Float32(-2.0))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if ((uy * single(2.0)) <= single(0.0015999999595806003)) tmp = sqrt((((ux ^ single(2.0)) * (single(-1.0) + (single(2.0) * maxCos))) + (ux * (single(2.0) - (single(2.0) * maxCos))))); else tmp = cos(((uy * single(2.0)) * single(pi))) * sqrt(((single(2.0) * ux) + ((ux * maxCos) * single(-2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \cdot 2 \leq 0.0015999999595806003:\\
\;\;\;\;\sqrt{{ux}^{2} \cdot \left(-1 + 2 \cdot maxCos\right) + ux \cdot \left(2 - 2 \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux + \left(ux \cdot maxCos\right) \cdot -2}\\
\end{array}
\end{array}
if (*.f32 uy 2) < 0.00159999996Initial program 53.7%
associate-*l*53.7%
sub-neg53.7%
+-commutative53.7%
distribute-rgt-neg-in53.7%
fma-def53.8%
Simplified53.9%
Taylor expanded in ux around -inf 99.3%
+-commutative99.3%
mul-1-neg99.3%
unsub-neg99.3%
associate-*r*99.3%
sub-neg99.3%
metadata-eval99.3%
mul-1-neg99.3%
sub-neg99.3%
+-commutative99.3%
sub-neg99.3%
mul-1-neg99.3%
unsub-neg99.3%
mul-1-neg99.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
pow1/299.3%
pow-to-exp96.4%
Applied egg-rr96.4%
Taylor expanded in maxCos around 0 96.0%
Taylor expanded in uy around 0 97.1%
if 0.00159999996 < (*.f32 uy 2) Initial program 56.7%
Taylor expanded in ux around 0 46.1%
Taylor expanded in maxCos around 0 76.4%
Final simplification89.9%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* uy 2.0) 0.0015999999595806003)
(sqrt
(+ (* (pow ux 2.0) (+ -1.0 (* 2.0 maxCos))) (* ux (- 2.0 (* 2.0 maxCos)))))
(*
(cos (* uy (* 2.0 PI)))
(sqrt (* ux (- (+ 1.0 (- 1.0 maxCos)) maxCos))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if ((uy * 2.0f) <= 0.0015999999595806003f) {
tmp = sqrtf(((powf(ux, 2.0f) * (-1.0f + (2.0f * maxCos))) + (ux * (2.0f - (2.0f * maxCos)))));
} else {
tmp = cosf((uy * (2.0f * ((float) M_PI)))) * sqrtf((ux * ((1.0f + (1.0f - maxCos)) - maxCos)));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (Float32(uy * Float32(2.0)) <= Float32(0.0015999999595806003)) tmp = sqrt(Float32(Float32((ux ^ Float32(2.0)) * Float32(Float32(-1.0) + Float32(Float32(2.0) * maxCos))) + Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))))); else tmp = Float32(cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(Float32(ux * Float32(Float32(Float32(1.0) + Float32(Float32(1.0) - maxCos)) - maxCos)))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if ((uy * single(2.0)) <= single(0.0015999999595806003)) tmp = sqrt((((ux ^ single(2.0)) * (single(-1.0) + (single(2.0) * maxCos))) + (ux * (single(2.0) - (single(2.0) * maxCos))))); else tmp = cos((uy * (single(2.0) * single(pi)))) * sqrt((ux * ((single(1.0) + (single(1.0) - maxCos)) - maxCos))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \cdot 2 \leq 0.0015999999595806003:\\
\;\;\;\;\sqrt{{ux}^{2} \cdot \left(-1 + 2 \cdot maxCos\right) + ux \cdot \left(2 - 2 \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 - maxCos\right)\right) - maxCos\right)}\\
\end{array}
\end{array}
if (*.f32 uy 2) < 0.00159999996Initial program 53.7%
associate-*l*53.7%
sub-neg53.7%
+-commutative53.7%
distribute-rgt-neg-in53.7%
fma-def53.8%
Simplified53.9%
Taylor expanded in ux around -inf 99.3%
+-commutative99.3%
mul-1-neg99.3%
unsub-neg99.3%
associate-*r*99.3%
sub-neg99.3%
metadata-eval99.3%
mul-1-neg99.3%
sub-neg99.3%
+-commutative99.3%
sub-neg99.3%
mul-1-neg99.3%
unsub-neg99.3%
mul-1-neg99.3%
sub-neg99.3%
metadata-eval99.3%
Simplified99.3%
pow1/299.3%
pow-to-exp96.4%
Applied egg-rr96.4%
Taylor expanded in maxCos around 0 96.0%
Taylor expanded in uy around 0 97.1%
if 0.00159999996 < (*.f32 uy 2) Initial program 56.7%
associate-*l*56.7%
sub-neg56.7%
+-commutative56.7%
distribute-rgt-neg-in56.7%
fma-def56.7%
Simplified57.2%
Taylor expanded in ux around 0 76.4%
mul-1-neg76.4%
sub-neg76.4%
metadata-eval76.4%
+-commutative76.4%
Simplified76.4%
Final simplification89.9%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.0007200000109151006)
(* (cos (* (* uy 2.0) PI)) (sqrt (+ (* 2.0 ux) (* (* ux maxCos) -2.0))))
(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.0007200000109151006f) {
tmp = cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf(((2.0f * ux) + ((ux * maxCos) * -2.0f)));
} else {
tmp = sqrtf((1.0f + ((1.0f + (ux * (maxCos + -1.0f))) * (-1.0f + (ux * (1.0f - maxCos))))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.0007200000109151006)) tmp = Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(Float32(2.0) * ux) + Float32(Float32(ux * maxCos) * Float32(-2.0))))); 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.0007200000109151006)) tmp = cos(((uy * single(2.0)) * single(pi))) * sqrt(((single(2.0) * ux) + ((ux * maxCos) * single(-2.0)))); 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.0007200000109151006:\\
\;\;\;\;\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux + \left(ux \cdot maxCos\right) \cdot -2}\\
\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 < 7.20000011e-4Initial program 38.4%
Taylor expanded in ux around 0 42.0%
Taylor expanded in maxCos around 0 91.0%
if 7.20000011e-4 < ux Initial program 90.6%
associate-*l*90.6%
sub-neg90.6%
+-commutative90.6%
distribute-rgt-neg-in90.6%
fma-def90.7%
Simplified90.9%
Taylor expanded in uy around 0 75.0%
Simplified75.0%
Taylor expanded in ux around 0 75.0%
Final simplification86.0%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.0007200000109151006)
(* (cos (* (* uy 2.0) PI)) (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.0007200000109151006f) {
tmp = cosf(((uy * 2.0f) * ((float) M_PI))) * 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;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.0007200000109151006)) tmp = Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * 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.0007200000109151006)) tmp = cos(((uy * single(2.0)) * single(pi))) * 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.0007200000109151006:\\
\;\;\;\;\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \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 < 7.20000011e-4Initial program 38.4%
Taylor expanded in ux around 0 90.9%
if 7.20000011e-4 < ux Initial program 90.6%
associate-*l*90.6%
sub-neg90.6%
+-commutative90.6%
distribute-rgt-neg-in90.6%
fma-def90.7%
Simplified90.9%
Taylor expanded in uy around 0 75.0%
Simplified75.0%
Taylor expanded in ux around 0 75.0%
Final simplification85.9%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.0005000000237487257)
(* (cos (* (* uy 2.0) PI)) (sqrt (* 2.0 ux)))
(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.0005000000237487257f) {
tmp = cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((2.0f * ux));
} else {
tmp = sqrtf((1.0f + ((1.0f + (ux * (maxCos + -1.0f))) * (-1.0f + (ux * (1.0f - maxCos))))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.0005000000237487257)) tmp = Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(2.0) * ux))); 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.0005000000237487257)) tmp = cos(((uy * single(2.0)) * single(pi))) * sqrt((single(2.0) * ux)); 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.0005000000237487257:\\
\;\;\;\;\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux}\\
\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 < 5.00000024e-4Initial program 37.0%
Taylor expanded in ux around 0 41.1%
Taylor expanded in maxCos around 0 86.3%
*-commutative86.3%
Simplified86.3%
if 5.00000024e-4 < ux Initial program 89.7%
associate-*l*89.7%
sub-neg89.7%
+-commutative89.7%
distribute-rgt-neg-in89.7%
fma-def89.8%
Simplified90.0%
Taylor expanded in uy around 0 74.2%
Simplified74.2%
Taylor expanded in ux around 0 74.4%
Final simplification82.3%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.00019999999494757503)
(sqrt (+ (* 2.0 ux) (* (* ux maxCos) -2.0)))
(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.00019999999494757503f) {
tmp = sqrtf(((2.0f * ux) + ((ux * maxCos) * -2.0f)));
} 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.00019999999494757503e0) then
tmp = sqrt(((2.0e0 * ux) + ((ux * maxcos) * (-2.0e0))))
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.00019999999494757503)) tmp = sqrt(Float32(Float32(Float32(2.0) * ux) + Float32(Float32(ux * maxCos) * Float32(-2.0)))); 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.00019999999494757503)) tmp = sqrt(((single(2.0) * ux) + ((ux * maxCos) * single(-2.0)))); 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.00019999999494757503:\\
\;\;\;\;\sqrt{2 \cdot ux + \left(ux \cdot maxCos\right) \cdot -2}\\
\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.99999995e-4Initial program 35.5%
Taylor expanded in ux around 0 39.9%
Taylor expanded in maxCos around 0 92.8%
Taylor expanded in uy around 0 77.1%
if 1.99999995e-4 < ux Initial program 88.5%
associate-*l*88.5%
sub-neg88.5%
+-commutative88.5%
distribute-rgt-neg-in88.5%
fma-def88.6%
Simplified88.8%
Taylor expanded in uy around 0 72.3%
Simplified72.3%
Taylor expanded in ux around 0 72.5%
Final simplification75.4%
(FPCore (ux uy maxCos) :precision binary32 (if (<= ux 0.00019999999494757503) (sqrt (+ (* 2.0 ux) (* (* ux maxCos) -2.0))) (sqrt (- 1.0 (* (- 1.0 ux) (+ 1.0 (* ux (+ maxCos -1.0))))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00019999999494757503f) {
tmp = sqrtf(((2.0f * ux) + ((ux * maxCos) * -2.0f)));
} else {
tmp = sqrtf((1.0f - ((1.0f - ux) * (1.0f + (ux * (maxCos + -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.00019999999494757503e0) then
tmp = sqrt(((2.0e0 * ux) + ((ux * maxcos) * (-2.0e0))))
else
tmp = sqrt((1.0e0 - ((1.0e0 - ux) * (1.0e0 + (ux * (maxcos + (-1.0e0)))))))
end if
code = tmp
end function
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.00019999999494757503)) tmp = sqrt(Float32(Float32(Float32(2.0) * ux) + Float32(Float32(ux * maxCos) * Float32(-2.0)))); else tmp = sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(1.0) - ux) * Float32(Float32(1.0) + Float32(ux * Float32(maxCos + Float32(-1.0))))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.00019999999494757503)) tmp = sqrt(((single(2.0) * ux) + ((ux * maxCos) * single(-2.0)))); else tmp = sqrt((single(1.0) - ((single(1.0) - ux) * (single(1.0) + (ux * (maxCos + single(-1.0))))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00019999999494757503:\\
\;\;\;\;\sqrt{2 \cdot ux + \left(ux \cdot maxCos\right) \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(1 + ux \cdot \left(maxCos + -1\right)\right)}\\
\end{array}
\end{array}
if ux < 1.99999995e-4Initial program 35.5%
Taylor expanded in ux around 0 39.9%
Taylor expanded in maxCos around 0 92.8%
Taylor expanded in uy around 0 77.1%
if 1.99999995e-4 < ux Initial program 88.5%
associate-*l*88.5%
sub-neg88.5%
+-commutative88.5%
distribute-rgt-neg-in88.5%
fma-def88.6%
Simplified88.8%
Taylor expanded in uy around 0 72.3%
Simplified72.3%
Taylor expanded in maxCos around 0 70.5%
Final simplification74.7%
(FPCore (ux uy maxCos) :precision binary32 (if (<= ux 0.00019999999494757503) (sqrt (+ (* 2.0 ux) (* (* ux maxCos) -2.0))) (sqrt (+ 1.0 (* (- 1.0 ux) (+ ux -1.0))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00019999999494757503f) {
tmp = sqrtf(((2.0f * ux) + ((ux * maxCos) * -2.0f)));
} 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.00019999999494757503e0) then
tmp = sqrt(((2.0e0 * ux) + ((ux * maxcos) * (-2.0e0))))
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.00019999999494757503)) tmp = sqrt(Float32(Float32(Float32(2.0) * ux) + Float32(Float32(ux * maxCos) * Float32(-2.0)))); 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.00019999999494757503)) tmp = sqrt(((single(2.0) * ux) + ((ux * maxCos) * single(-2.0)))); 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.00019999999494757503:\\
\;\;\;\;\sqrt{2 \cdot ux + \left(ux \cdot maxCos\right) \cdot -2}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 + \left(1 - ux\right) \cdot \left(ux + -1\right)}\\
\end{array}
\end{array}
if ux < 1.99999995e-4Initial program 35.5%
Taylor expanded in ux around 0 39.9%
Taylor expanded in maxCos around 0 92.8%
Taylor expanded in uy around 0 77.1%
if 1.99999995e-4 < ux Initial program 88.5%
associate-*l*88.5%
sub-neg88.5%
+-commutative88.5%
distribute-rgt-neg-in88.5%
fma-def88.6%
Simplified88.8%
Taylor expanded in uy around 0 72.3%
Simplified72.3%
Taylor expanded in maxCos around 0 70.3%
Final simplification74.6%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (+ (* 2.0 ux) (* (* ux maxCos) -2.0))))
float code(float ux, float uy, float maxCos) {
return sqrtf(((2.0f * ux) + ((ux * 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(((2.0e0 * ux) + ((ux * maxcos) * (-2.0e0))))
end function
function code(ux, uy, maxCos) return sqrt(Float32(Float32(Float32(2.0) * ux) + Float32(Float32(ux * maxCos) * Float32(-2.0)))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt(((single(2.0) * ux) + ((ux * maxCos) * single(-2.0)))); end
\begin{array}{l}
\\
\sqrt{2 \cdot ux + \left(ux \cdot maxCos\right) \cdot -2}
\end{array}
Initial program 54.7%
Taylor expanded in ux around 0 44.6%
Taylor expanded in maxCos around 0 78.3%
Taylor expanded in uy around 0 66.3%
Final simplification66.3%
(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.7%
associate-*l*54.7%
sub-neg54.7%
+-commutative54.7%
distribute-rgt-neg-in54.7%
fma-def54.8%
Simplified55.0%
Taylor expanded in uy around 0 46.9%
Simplified46.9%
Taylor expanded in ux around 0 66.3%
Final simplification66.3%
(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 54.7%
associate-*l*54.7%
sub-neg54.7%
+-commutative54.7%
distribute-rgt-neg-in54.7%
fma-def54.8%
Simplified55.0%
Taylor expanded in uy around 0 46.9%
Simplified46.9%
Taylor expanded in ux around 0 66.3%
Taylor expanded in maxCos around 0 63.7%
*-commutative63.7%
Simplified63.7%
Final simplification63.7%
herbie shell --seed 2024019
(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)))))))