
(FPCore (ux uy maxCos) :precision binary32 (let* ((t_0 (+ (- 1.0 ux) (* ux maxCos)))) (* (sin (* (* 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 sinf(((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(sin(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 = sin(((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\\
\sin \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)))) (* (sin (* (* 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 sinf(((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(sin(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 = sin(((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\\
\sin \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 (- 1.0 maxCos))
(* (pow ux 2.0) (* (- 1.0 maxCos) (+ maxCos -1.0))))
1.5)
(pow (sin (* PI (* 2.0 uy))) 3.0))))
float code(float ux, float uy, float maxCos) {
return cbrtf((powf(fmaf(ux, (2.0f * (1.0f - maxCos)), (powf(ux, 2.0f) * ((1.0f - maxCos) * (maxCos + -1.0f)))), 1.5f) * powf(sinf((((float) M_PI) * (2.0f * uy))), 3.0f)));
}
function code(ux, uy, maxCos) return cbrt(Float32((fma(ux, Float32(Float32(2.0) * Float32(Float32(1.0) - maxCos)), Float32((ux ^ Float32(2.0)) * Float32(Float32(Float32(1.0) - maxCos) * Float32(maxCos + Float32(-1.0))))) ^ Float32(1.5)) * (sin(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) ^ Float32(3.0)))) end
\begin{array}{l}
\\
\sqrt[3]{{\left(\mathsf{fma}\left(ux, 2 \cdot \left(1 - maxCos\right), {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right)\right)\right)}^{1.5} \cdot {\sin \left(\pi \cdot \left(2 \cdot uy\right)\right)}^{3}}
\end{array}
Initial program 54.8%
associate-*l*54.8%
sub-neg54.8%
+-commutative54.8%
distribute-rgt-neg-in54.8%
fma-def54.8%
Simplified55.0%
Taylor expanded in ux around 0 98.2%
fma-def98.2%
+-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
+-commutative98.2%
distribute-lft-in98.2%
metadata-eval98.2%
associate--l+98.2%
mul-1-neg98.2%
sub-neg98.2%
*-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
+-commutative98.2%
Simplified98.2%
Applied egg-rr98.3%
Final simplification98.3%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sqrt
(fma
ux
(+ 2.0 (* maxCos -2.0))
(* (pow ux 2.0) (* (- 1.0 maxCos) (+ maxCos -1.0)))))
(sin (* 2.0 (expm1 (log1p (* PI uy)))))))
float code(float ux, float uy, float maxCos) {
return sqrtf(fmaf(ux, (2.0f + (maxCos * -2.0f)), (powf(ux, 2.0f) * ((1.0f - maxCos) * (maxCos + -1.0f))))) * sinf((2.0f * expm1f(log1pf((((float) M_PI) * uy)))));
}
function code(ux, uy, maxCos) return Float32(sqrt(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)))))) * sin(Float32(Float32(2.0) * expm1(log1p(Float32(Float32(pi) * uy)))))) end
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(ux, 2 + maxCos \cdot -2, {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right)\right)} \cdot \sin \left(2 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(\pi \cdot uy\right)\right)\right)
\end{array}
Initial program 54.8%
associate-*l*54.8%
sub-neg54.8%
+-commutative54.8%
distribute-rgt-neg-in54.8%
fma-def54.8%
Simplified55.0%
Taylor expanded in ux around 0 98.2%
fma-def98.2%
+-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
+-commutative98.2%
distribute-lft-in98.2%
metadata-eval98.2%
associate--l+98.2%
mul-1-neg98.2%
sub-neg98.2%
*-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
+-commutative98.2%
Simplified98.2%
Taylor expanded in uy around inf 98.2%
*-commutative98.2%
fma-def98.2%
cancel-sign-sub-inv98.2%
metadata-eval98.2%
*-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
Simplified98.2%
expm1-log1p-u98.2%
*-commutative98.2%
Applied egg-rr98.2%
Final simplification98.2%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sqrt
(fma
ux
(+ 2.0 (* maxCos -2.0))
(* (pow ux 2.0) (* (- 1.0 maxCos) (+ maxCos -1.0)))))
(sin (* 2.0 (* PI uy)))))
float code(float ux, float uy, float maxCos) {
return sqrtf(fmaf(ux, (2.0f + (maxCos * -2.0f)), (powf(ux, 2.0f) * ((1.0f - maxCos) * (maxCos + -1.0f))))) * sinf((2.0f * (((float) M_PI) * uy)));
}
function code(ux, uy, maxCos) return Float32(sqrt(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)))))) * sin(Float32(Float32(2.0) * Float32(Float32(pi) * uy)))) end
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(ux, 2 + maxCos \cdot -2, {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right)\right)} \cdot \sin \left(2 \cdot \left(\pi \cdot uy\right)\right)
\end{array}
Initial program 54.8%
associate-*l*54.8%
sub-neg54.8%
+-commutative54.8%
distribute-rgt-neg-in54.8%
fma-def54.8%
Simplified55.0%
Taylor expanded in ux around 0 98.2%
fma-def98.2%
+-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
+-commutative98.2%
distribute-lft-in98.2%
metadata-eval98.2%
associate--l+98.2%
mul-1-neg98.2%
sub-neg98.2%
*-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
+-commutative98.2%
Simplified98.2%
Taylor expanded in uy around inf 98.2%
*-commutative98.2%
fma-def98.2%
cancel-sign-sub-inv98.2%
metadata-eval98.2%
*-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
Simplified98.2%
Final simplification98.2%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= maxCos 6.199999916134402e-5)
(* (sin (* 2.0 (* PI uy))) (sqrt (- (* ux 2.0) (pow ux 2.0))))
(*
2.0
(*
uy
(*
PI
(sqrt
(fma
(pow ux 2.0)
(* (- 1.0 maxCos) (+ maxCos -1.0))
(* ux (+ 2.0 (* maxCos -2.0))))))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (maxCos <= 6.199999916134402e-5f) {
tmp = sinf((2.0f * (((float) M_PI) * uy))) * sqrtf(((ux * 2.0f) - powf(ux, 2.0f)));
} else {
tmp = 2.0f * (uy * (((float) M_PI) * sqrtf(fmaf(powf(ux, 2.0f), ((1.0f - maxCos) * (maxCos + -1.0f)), (ux * (2.0f + (maxCos * -2.0f)))))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (maxCos <= Float32(6.199999916134402e-5)) tmp = Float32(sin(Float32(Float32(2.0) * Float32(Float32(pi) * uy))) * sqrt(Float32(Float32(ux * Float32(2.0)) - (ux ^ Float32(2.0))))); else tmp = Float32(Float32(2.0) * Float32(uy * Float32(Float32(pi) * sqrt(fma((ux ^ Float32(2.0)), Float32(Float32(Float32(1.0) - maxCos) * Float32(maxCos + Float32(-1.0))), Float32(ux * Float32(Float32(2.0) + Float32(maxCos * Float32(-2.0))))))))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 6.199999916134402 \cdot 10^{-5}:\\
\;\;\;\;\sin \left(2 \cdot \left(\pi \cdot uy\right)\right) \cdot \sqrt{ux \cdot 2 - {ux}^{2}}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{\mathsf{fma}\left({ux}^{2}, \left(1 - maxCos\right) \cdot \left(maxCos + -1\right), ux \cdot \left(2 + maxCos \cdot -2\right)\right)}\right)\right)\\
\end{array}
\end{array}
if maxCos < 6.19999992e-5Initial program 54.8%
associate-*l*54.8%
sub-neg54.8%
+-commutative54.8%
distribute-rgt-neg-in54.8%
fma-def54.9%
Simplified55.0%
Taylor expanded in ux around 0 98.2%
fma-def98.2%
+-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
+-commutative98.2%
distribute-lft-in98.2%
metadata-eval98.2%
associate--l+98.2%
mul-1-neg98.2%
sub-neg98.2%
*-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
+-commutative98.2%
Simplified98.2%
Taylor expanded in maxCos around 0 96.7%
+-commutative96.7%
neg-mul-196.7%
unsub-neg96.7%
Simplified96.7%
if 6.19999992e-5 < maxCos Initial program 53.9%
associate-*l*53.9%
sub-neg53.9%
+-commutative53.9%
distribute-rgt-neg-in53.9%
fma-def53.5%
Simplified55.1%
Taylor expanded in ux around 0 98.0%
fma-def97.9%
+-commutative97.9%
sub-neg97.9%
metadata-eval97.9%
+-commutative97.9%
distribute-lft-in97.9%
metadata-eval97.9%
associate--l+98.1%
mul-1-neg98.1%
sub-neg98.1%
*-commutative98.1%
sub-neg98.1%
metadata-eval98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in uy around 0 85.3%
expm1-log1p-u85.3%
expm1-udef36.1%
Applied egg-rr36.1%
expm1-def86.0%
expm1-log1p86.0%
Simplified86.0%
Final simplification95.7%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sin (* uy (* 2.0 PI)))
(sqrt
(+
(* ux (- (+ 1.0 (- 1.0 maxCos)) maxCos))
(* (pow ux 2.0) (* (- 1.0 maxCos) (+ maxCos -1.0)))))))
float code(float ux, float uy, float maxCos) {
return sinf((uy * (2.0f * ((float) M_PI)))) * sqrtf(((ux * ((1.0f + (1.0f - maxCos)) - maxCos)) + (powf(ux, 2.0f) * ((1.0f - maxCos) * (maxCos + -1.0f)))));
}
function code(ux, uy, maxCos) return Float32(sin(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(Float32(Float32(ux * Float32(Float32(Float32(1.0) + Float32(Float32(1.0) - maxCos)) - maxCos)) + Float32((ux ^ Float32(2.0)) * Float32(Float32(Float32(1.0) - maxCos) * Float32(maxCos + Float32(-1.0))))))) end
function tmp = code(ux, uy, maxCos) tmp = sin((uy * (single(2.0) * single(pi)))) * sqrt(((ux * ((single(1.0) + (single(1.0) - maxCos)) - maxCos)) + ((ux ^ single(2.0)) * ((single(1.0) - maxCos) * (maxCos + single(-1.0)))))); end
\begin{array}{l}
\\
\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(\left(1 + \left(1 - maxCos\right)\right) - maxCos\right) + {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right)}
\end{array}
Initial program 54.8%
associate-*l*54.8%
sub-neg54.8%
+-commutative54.8%
distribute-rgt-neg-in54.8%
fma-def54.8%
Simplified55.0%
Taylor expanded in ux around 0 98.2%
Final simplification98.2%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sin (* 2.0 (* PI uy)))
(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 sinf((2.0f * (((float) M_PI) * uy))) * sqrtf(((powf(ux, 2.0f) * ((1.0f - maxCos) * (maxCos + -1.0f))) + (ux * (2.0f - (2.0f * maxCos)))));
}
function code(ux, uy, maxCos) return Float32(sin(Float32(Float32(2.0) * Float32(Float32(pi) * uy))) * 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 = sin((single(2.0) * (single(pi) * uy))) * 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}
\\
\sin \left(2 \cdot \left(\pi \cdot uy\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.8%
associate-*l*54.8%
sub-neg54.8%
+-commutative54.8%
distribute-rgt-neg-in54.8%
fma-def54.8%
Simplified55.0%
Taylor expanded in ux around 0 98.2%
fma-def98.2%
+-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
+-commutative98.2%
distribute-lft-in98.2%
metadata-eval98.2%
associate--l+98.2%
mul-1-neg98.2%
sub-neg98.2%
*-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
+-commutative98.2%
Simplified98.2%
Taylor expanded in uy around inf 98.2%
Final simplification98.2%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= maxCos 6.199999916134402e-5)
(* (sin (* 2.0 (* PI uy))) (sqrt (- (* ux 2.0) (pow ux 2.0))))
(*
2.0
(*
(* PI uy)
(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) {
float tmp;
if (maxCos <= 6.199999916134402e-5f) {
tmp = sinf((2.0f * (((float) M_PI) * uy))) * sqrtf(((ux * 2.0f) - powf(ux, 2.0f)));
} else {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf(((powf(ux, 2.0f) * ((1.0f - maxCos) * (maxCos + -1.0f))) + (ux * (2.0f - (2.0f * maxCos))))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (maxCos <= Float32(6.199999916134402e-5)) tmp = Float32(sin(Float32(Float32(2.0) * Float32(Float32(pi) * uy))) * sqrt(Float32(Float32(ux * Float32(2.0)) - (ux ^ Float32(2.0))))); else tmp = Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * 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 return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (maxCos <= single(6.199999916134402e-5)) tmp = sin((single(2.0) * (single(pi) * uy))) * sqrt(((ux * single(2.0)) - (ux ^ single(2.0)))); else tmp = single(2.0) * ((single(pi) * uy) * sqrt((((ux ^ single(2.0)) * ((single(1.0) - maxCos) * (maxCos + single(-1.0)))) + (ux * (single(2.0) - (single(2.0) * maxCos)))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 6.199999916134402 \cdot 10^{-5}:\\
\;\;\;\;\sin \left(2 \cdot \left(\pi \cdot uy\right)\right) \cdot \sqrt{ux \cdot 2 - {ux}^{2}}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\left(\pi \cdot uy\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)}\right)\\
\end{array}
\end{array}
if maxCos < 6.19999992e-5Initial program 54.8%
associate-*l*54.8%
sub-neg54.8%
+-commutative54.8%
distribute-rgt-neg-in54.8%
fma-def54.9%
Simplified55.0%
Taylor expanded in ux around 0 98.2%
fma-def98.2%
+-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
+-commutative98.2%
distribute-lft-in98.2%
metadata-eval98.2%
associate--l+98.2%
mul-1-neg98.2%
sub-neg98.2%
*-commutative98.2%
sub-neg98.2%
metadata-eval98.2%
+-commutative98.2%
Simplified98.2%
Taylor expanded in maxCos around 0 96.7%
+-commutative96.7%
neg-mul-196.7%
unsub-neg96.7%
Simplified96.7%
if 6.19999992e-5 < maxCos Initial program 53.9%
associate-*l*53.9%
sub-neg53.9%
+-commutative53.9%
distribute-rgt-neg-in53.9%
fma-def53.5%
Simplified55.1%
Taylor expanded in ux around 0 98.0%
fma-def97.9%
+-commutative97.9%
sub-neg97.9%
metadata-eval97.9%
+-commutative97.9%
distribute-lft-in97.9%
metadata-eval97.9%
associate--l+98.1%
mul-1-neg98.1%
sub-neg98.1%
*-commutative98.1%
sub-neg98.1%
metadata-eval98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in uy around 0 85.3%
Final simplification95.7%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* PI (* 2.0 uy))))
(t_1
(+
1.0
(* (+ (- 1.0 ux) (* ux maxCos)) (- (+ ux -1.0) (* ux maxCos))))))
(if (<= t_1 0.00039999998989515007)
(* t_0 (sqrt (+ (* ux 2.0) (* -2.0 (* ux maxCos)))))
(* t_0 (sqrt t_1)))))
float code(float ux, float uy, float maxCos) {
float t_0 = sinf((((float) M_PI) * (2.0f * uy)));
float t_1 = 1.0f + (((1.0f - ux) + (ux * maxCos)) * ((ux + -1.0f) - (ux * maxCos)));
float tmp;
if (t_1 <= 0.00039999998989515007f) {
tmp = t_0 * sqrtf(((ux * 2.0f) + (-2.0f * (ux * maxCos))));
} else {
tmp = t_0 * sqrtf(t_1);
}
return tmp;
}
function code(ux, uy, maxCos) t_0 = sin(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) t_1 = Float32(Float32(1.0) + Float32(Float32(Float32(Float32(1.0) - ux) + Float32(ux * maxCos)) * Float32(Float32(ux + Float32(-1.0)) - Float32(ux * maxCos)))) tmp = Float32(0.0) if (t_1 <= Float32(0.00039999998989515007)) tmp = Float32(t_0 * sqrt(Float32(Float32(ux * Float32(2.0)) + Float32(Float32(-2.0) * Float32(ux * maxCos))))); else tmp = Float32(t_0 * sqrt(t_1)); end return tmp end
function tmp_2 = code(ux, uy, maxCos) t_0 = sin((single(pi) * (single(2.0) * uy))); t_1 = single(1.0) + (((single(1.0) - ux) + (ux * maxCos)) * ((ux + single(-1.0)) - (ux * maxCos))); tmp = single(0.0); if (t_1 <= single(0.00039999998989515007)) tmp = t_0 * sqrt(((ux * single(2.0)) + (single(-2.0) * (ux * maxCos)))); else tmp = t_0 * sqrt(t_1); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\pi \cdot \left(2 \cdot uy\right)\right)\\
t_1 := 1 + \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(\left(ux + -1\right) - ux \cdot maxCos\right)\\
\mathbf{if}\;t_1 \leq 0.00039999998989515007:\\
\;\;\;\;t_0 \cdot \sqrt{ux \cdot 2 + -2 \cdot \left(ux \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \sqrt{t_1}\\
\end{array}
\end{array}
if (-.f32 1 (*.f32 (+.f32 (-.f32 1 ux) (*.f32 ux maxCos)) (+.f32 (-.f32 1 ux) (*.f32 ux maxCos)))) < 3.9999999e-4Initial program 35.7%
Taylor expanded in ux around 0 40.1%
Taylor expanded in maxCos around 0 92.4%
if 3.9999999e-4 < (-.f32 1 (*.f32 (+.f32 (-.f32 1 ux) (*.f32 ux maxCos)) (+.f32 (-.f32 1 ux) (*.f32 ux maxCos)))) Initial program 88.2%
Final simplification90.9%
(FPCore (ux uy maxCos) :precision binary32 (if (<= (* 2.0 uy) 0.00559999980032444) (* 2.0 (* (* PI uy) (sqrt (- (* ux 2.0) (pow ux 2.0))))) (* (sin (* PI (* 2.0 uy))) (sqrt (* ux (- 2.0 (* 2.0 maxCos)))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if ((2.0f * uy) <= 0.00559999980032444f) {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf(((ux * 2.0f) - powf(ux, 2.0f))));
} else {
tmp = sinf((((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(2.0) * uy) <= Float32(0.00559999980032444)) tmp = Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * sqrt(Float32(Float32(ux * Float32(2.0)) - (ux ^ Float32(2.0)))))); else tmp = Float32(sin(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(2.0) * uy) <= single(0.00559999980032444)) tmp = single(2.0) * ((single(pi) * uy) * sqrt(((ux * single(2.0)) - (ux ^ single(2.0))))); else tmp = sin((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}\;2 \cdot uy \leq 0.00559999980032444:\\
\;\;\;\;2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{ux \cdot 2 - {ux}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin \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 uy 2) < 0.0055999998Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.6%
Simplified54.8%
Taylor expanded in ux around 0 98.5%
fma-def98.4%
+-commutative98.4%
sub-neg98.4%
metadata-eval98.4%
+-commutative98.4%
distribute-lft-in98.4%
metadata-eval98.4%
associate--l+98.5%
mul-1-neg98.5%
sub-neg98.5%
*-commutative98.5%
sub-neg98.5%
metadata-eval98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in uy around 0 95.4%
Taylor expanded in maxCos around 0 90.7%
+-commutative90.7%
mul-1-neg90.7%
unsub-neg90.7%
Simplified90.7%
if 0.0055999998 < (*.f32 uy 2) Initial program 55.3%
Taylor expanded in ux around 0 77.4%
*-commutative77.4%
Simplified77.4%
Final simplification87.0%
(FPCore (ux uy maxCos) :precision binary32 (if (<= ux 0.0002500000118743628) (* (sin (* PI (* 2.0 uy))) (sqrt (+ (* ux 2.0) (* -2.0 (* ux maxCos))))) (* 2.0 (* (* PI uy) (sqrt (- (* ux 2.0) (pow ux 2.0)))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.0002500000118743628f) {
tmp = sinf((((float) M_PI) * (2.0f * uy))) * sqrtf(((ux * 2.0f) + (-2.0f * (ux * maxCos))));
} else {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf(((ux * 2.0f) - powf(ux, 2.0f))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.0002500000118743628)) tmp = Float32(sin(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) * sqrt(Float32(Float32(ux * Float32(2.0)) + Float32(Float32(-2.0) * Float32(ux * maxCos))))); else tmp = Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * 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 (ux <= single(0.0002500000118743628)) tmp = sin((single(pi) * (single(2.0) * uy))) * sqrt(((ux * single(2.0)) + (single(-2.0) * (ux * maxCos)))); else tmp = single(2.0) * ((single(pi) * uy) * sqrt(((ux * single(2.0)) - (ux ^ single(2.0))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.0002500000118743628:\\
\;\;\;\;\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{ux \cdot 2 + -2 \cdot \left(ux \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{ux \cdot 2 - {ux}^{2}}\right)\\
\end{array}
\end{array}
if ux < 2.50000012e-4Initial program 36.4%
Taylor expanded in ux around 0 40.7%
Taylor expanded in maxCos around 0 92.0%
if 2.50000012e-4 < ux Initial program 88.7%
associate-*l*88.7%
sub-neg88.7%
+-commutative88.7%
distribute-rgt-neg-in88.7%
fma-def88.8%
Simplified89.0%
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%
*-commutative98.1%
sub-neg98.1%
metadata-eval98.1%
+-commutative98.1%
Simplified98.1%
Taylor expanded in uy around 0 80.5%
Taylor expanded in maxCos around 0 78.0%
+-commutative78.0%
mul-1-neg78.0%
unsub-neg78.0%
Simplified78.0%
Final simplification87.1%
(FPCore (ux uy maxCos) :precision binary32 (if (<= ux 0.00019999999494757503) (* (sin (* PI (* 2.0 uy))) (sqrt (+ (* ux 2.0) (* -2.0 (* ux maxCos))))) (* (sin (* uy (* 2.0 PI))) (sqrt (+ 1.0 (* (- 1.0 ux) (+ ux -1.0)))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00019999999494757503f) {
tmp = sinf((((float) M_PI) * (2.0f * uy))) * sqrtf(((ux * 2.0f) + (-2.0f * (ux * maxCos))));
} else {
tmp = sinf((uy * (2.0f * ((float) M_PI)))) * sqrtf((1.0f + ((1.0f - ux) * (ux + -1.0f))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.00019999999494757503)) tmp = Float32(sin(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) * sqrt(Float32(Float32(ux * Float32(2.0)) + Float32(Float32(-2.0) * Float32(ux * maxCos))))); else tmp = Float32(sin(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * 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 = sin((single(pi) * (single(2.0) * uy))) * sqrt(((ux * single(2.0)) + (single(-2.0) * (ux * maxCos)))); else tmp = sin((uy * (single(2.0) * single(pi)))) * 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:\\
\;\;\;\;\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{ux \cdot 2 + -2 \cdot \left(ux \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{1 + \left(1 - ux\right) \cdot \left(ux + -1\right)}\\
\end{array}
\end{array}
if ux < 1.99999995e-4Initial program 35.7%
Taylor expanded in ux around 0 40.1%
Taylor expanded in maxCos around 0 92.4%
if 1.99999995e-4 < ux Initial program 88.2%
associate-*l*88.2%
sub-neg88.2%
+-commutative88.2%
distribute-rgt-neg-in88.2%
fma-def88.3%
Simplified88.5%
Taylor expanded in maxCos around 0 85.2%
Final simplification89.8%
(FPCore (ux uy maxCos) :precision binary32 (if (<= (* 2.0 uy) 0.007000000216066837) (* 2.0 (* uy (* PI (sqrt (- (* ux 2.0) (pow ux 2.0)))))) (* (sin (* PI (* 2.0 uy))) (sqrt (* ux 2.0)))))
float code(float ux, float uy, float maxCos) {
float tmp;
if ((2.0f * uy) <= 0.007000000216066837f) {
tmp = 2.0f * (uy * (((float) M_PI) * sqrtf(((ux * 2.0f) - powf(ux, 2.0f)))));
} else {
tmp = sinf((((float) M_PI) * (2.0f * uy))) * sqrtf((ux * 2.0f));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (Float32(Float32(2.0) * uy) <= Float32(0.007000000216066837)) tmp = Float32(Float32(2.0) * Float32(uy * Float32(Float32(pi) * sqrt(Float32(Float32(ux * Float32(2.0)) - (ux ^ Float32(2.0))))))); else tmp = Float32(sin(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) * sqrt(Float32(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.007000000216066837)) tmp = single(2.0) * (uy * (single(pi) * sqrt(((ux * single(2.0)) - (ux ^ single(2.0)))))); else tmp = sin((single(pi) * (single(2.0) * uy))) * sqrt((ux * single(2.0))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.007000000216066837:\\
\;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{ux \cdot 2 - {ux}^{2}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{ux \cdot 2}\\
\end{array}
\end{array}
if (*.f32 uy 2) < 0.00700000022Initial program 54.8%
associate-*l*54.8%
sub-neg54.8%
+-commutative54.8%
distribute-rgt-neg-in54.8%
fma-def54.9%
Simplified55.1%
Taylor expanded in ux around 0 98.4%
fma-def98.4%
+-commutative98.4%
sub-neg98.4%
metadata-eval98.4%
+-commutative98.4%
distribute-lft-in98.4%
metadata-eval98.4%
associate--l+98.5%
mul-1-neg98.5%
sub-neg98.5%
*-commutative98.5%
sub-neg98.5%
metadata-eval98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in uy around 0 95.0%
Taylor expanded in maxCos around 0 90.2%
associate-*l*90.1%
+-commutative90.1%
mul-1-neg90.1%
unsub-neg90.1%
Simplified90.1%
if 0.00700000022 < (*.f32 uy 2) Initial program 54.5%
Taylor expanded in ux around 0 45.8%
Taylor expanded in maxCos around 0 73.3%
Final simplification85.6%
(FPCore (ux uy maxCos) :precision binary32 (if (<= (* 2.0 uy) 0.007000000216066837) (* 2.0 (* (* PI uy) (sqrt (- (* ux 2.0) (pow ux 2.0))))) (* (sin (* PI (* 2.0 uy))) (sqrt (* ux 2.0)))))
float code(float ux, float uy, float maxCos) {
float tmp;
if ((2.0f * uy) <= 0.007000000216066837f) {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf(((ux * 2.0f) - powf(ux, 2.0f))));
} else {
tmp = sinf((((float) M_PI) * (2.0f * uy))) * sqrtf((ux * 2.0f));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (Float32(Float32(2.0) * uy) <= Float32(0.007000000216066837)) tmp = Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * sqrt(Float32(Float32(ux * Float32(2.0)) - (ux ^ Float32(2.0)))))); else tmp = Float32(sin(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) * sqrt(Float32(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.007000000216066837)) tmp = single(2.0) * ((single(pi) * uy) * sqrt(((ux * single(2.0)) - (ux ^ single(2.0))))); else tmp = sin((single(pi) * (single(2.0) * uy))) * sqrt((ux * single(2.0))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.007000000216066837:\\
\;\;\;\;2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{ux \cdot 2 - {ux}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{ux \cdot 2}\\
\end{array}
\end{array}
if (*.f32 uy 2) < 0.00700000022Initial program 54.8%
associate-*l*54.8%
sub-neg54.8%
+-commutative54.8%
distribute-rgt-neg-in54.8%
fma-def54.9%
Simplified55.1%
Taylor expanded in ux around 0 98.4%
fma-def98.4%
+-commutative98.4%
sub-neg98.4%
metadata-eval98.4%
+-commutative98.4%
distribute-lft-in98.4%
metadata-eval98.4%
associate--l+98.5%
mul-1-neg98.5%
sub-neg98.5%
*-commutative98.5%
sub-neg98.5%
metadata-eval98.5%
+-commutative98.5%
Simplified98.5%
Taylor expanded in uy around 0 95.0%
Taylor expanded in maxCos around 0 90.2%
+-commutative90.2%
mul-1-neg90.2%
unsub-neg90.2%
Simplified90.2%
if 0.00700000022 < (*.f32 uy 2) Initial program 54.5%
Taylor expanded in ux around 0 45.8%
Taylor expanded in maxCos around 0 73.3%
Final simplification85.7%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.0007200000109151006)
(* (sin (* PI (* 2.0 uy))) (sqrt (* ux 2.0)))
(*
2.0
(*
(* PI uy)
(sqrt
(+
1.0
(* (+ 1.0 (* ux (+ maxCos -1.0))) (+ ux (- -1.0 (* ux maxCos))))))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.0007200000109151006f) {
tmp = sinf((((float) M_PI) * (2.0f * uy))) * sqrtf((ux * 2.0f));
} else {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf((1.0f + ((1.0f + (ux * (maxCos + -1.0f))) * (ux + (-1.0f - (ux * maxCos)))))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.0007200000109151006)) tmp = Float32(sin(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) * sqrt(Float32(ux * Float32(2.0)))); else tmp = Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * sqrt(Float32(Float32(1.0) + Float32(Float32(Float32(1.0) + Float32(ux * Float32(maxCos + Float32(-1.0)))) * Float32(ux + Float32(Float32(-1.0) - Float32(ux * maxCos)))))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.0007200000109151006)) tmp = sin((single(pi) * (single(2.0) * uy))) * sqrt((ux * single(2.0))); else tmp = single(2.0) * ((single(pi) * uy) * sqrt((single(1.0) + ((single(1.0) + (ux * (maxCos + single(-1.0)))) * (ux + (single(-1.0) - (ux * maxCos))))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.0007200000109151006:\\
\;\;\;\;\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{ux \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right) \cdot \left(ux + \left(-1 - ux \cdot maxCos\right)\right)}\right)\\
\end{array}
\end{array}
if ux < 7.20000011e-4Initial program 38.6%
Taylor expanded in ux around 0 42.1%
Taylor expanded in maxCos around 0 85.2%
if 7.20000011e-4 < ux Initial program 90.4%
associate-*l*90.4%
sub-neg90.4%
+-commutative90.4%
distribute-rgt-neg-in90.4%
fma-def90.4%
Simplified90.6%
Taylor expanded in uy around 0 76.6%
Simplified76.6%
Taylor expanded in uy around 0 76.6%
Final simplification82.5%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.00019999999494757503)
(* 2.0 (* (* PI uy) (sqrt (+ (* ux 2.0) (* -2.0 (* ux maxCos))))))
(*
2.0
(*
(* PI uy)
(sqrt
(+
1.0
(* (+ 1.0 (* ux (+ maxCos -1.0))) (+ ux (- -1.0 (* ux maxCos))))))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00019999999494757503f) {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf(((ux * 2.0f) + (-2.0f * (ux * maxCos)))));
} else {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf((1.0f + ((1.0f + (ux * (maxCos + -1.0f))) * (ux + (-1.0f - (ux * maxCos)))))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.00019999999494757503)) tmp = Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * sqrt(Float32(Float32(ux * Float32(2.0)) + Float32(Float32(-2.0) * Float32(ux * maxCos)))))); else tmp = Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * sqrt(Float32(Float32(1.0) + Float32(Float32(Float32(1.0) + Float32(ux * Float32(maxCos + Float32(-1.0)))) * Float32(ux + Float32(Float32(-1.0) - Float32(ux * maxCos)))))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.00019999999494757503)) tmp = single(2.0) * ((single(pi) * uy) * sqrt(((ux * single(2.0)) + (single(-2.0) * (ux * maxCos))))); else tmp = single(2.0) * ((single(pi) * uy) * sqrt((single(1.0) + ((single(1.0) + (ux * (maxCos + single(-1.0)))) * (ux + (single(-1.0) - (ux * maxCos))))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00019999999494757503:\\
\;\;\;\;2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{ux \cdot 2 + -2 \cdot \left(ux \cdot maxCos\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{1 + \left(1 + ux \cdot \left(maxCos + -1\right)\right) \cdot \left(ux + \left(-1 - ux \cdot maxCos\right)\right)}\right)\\
\end{array}
\end{array}
if ux < 1.99999995e-4Initial program 35.7%
associate-*l*35.7%
sub-neg35.7%
+-commutative35.7%
distribute-rgt-neg-in35.7%
fma-def35.7%
Simplified35.9%
Taylor expanded in uy around 0 33.3%
Simplified33.3%
Taylor expanded in ux around 0 78.6%
Taylor expanded in maxCos around 0 78.6%
if 1.99999995e-4 < ux Initial program 88.2%
associate-*l*88.2%
sub-neg88.2%
+-commutative88.2%
distribute-rgt-neg-in88.2%
fma-def88.3%
Simplified88.5%
Taylor expanded in uy around 0 73.9%
Simplified73.9%
Taylor expanded in uy around 0 73.9%
Final simplification76.9%
(FPCore (ux uy maxCos) :precision binary32 (if (<= ux 0.00019999999494757503) (* 2.0 (* (* PI uy) (sqrt (+ (* ux 2.0) (* -2.0 (* ux maxCos)))))) (* 2.0 (* (* PI uy) (sqrt (+ 1.0 (* (- 1.0 ux) (+ ux -1.0))))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00019999999494757503f) {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf(((ux * 2.0f) + (-2.0f * (ux * maxCos)))));
} else {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf((1.0f + ((1.0f - ux) * (ux + -1.0f)))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.00019999999494757503)) tmp = Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * sqrt(Float32(Float32(ux * Float32(2.0)) + Float32(Float32(-2.0) * Float32(ux * maxCos)))))); else tmp = Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * 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 = single(2.0) * ((single(pi) * uy) * sqrt(((ux * single(2.0)) + (single(-2.0) * (ux * maxCos))))); else tmp = single(2.0) * ((single(pi) * uy) * 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:\\
\;\;\;\;2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{ux \cdot 2 + -2 \cdot \left(ux \cdot maxCos\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{1 + \left(1 - ux\right) \cdot \left(ux + -1\right)}\right)\\
\end{array}
\end{array}
if ux < 1.99999995e-4Initial program 35.7%
associate-*l*35.7%
sub-neg35.7%
+-commutative35.7%
distribute-rgt-neg-in35.7%
fma-def35.7%
Simplified35.9%
Taylor expanded in uy around 0 33.3%
Simplified33.3%
Taylor expanded in ux around 0 78.6%
Taylor expanded in maxCos around 0 78.6%
if 1.99999995e-4 < ux Initial program 88.2%
associate-*l*88.2%
sub-neg88.2%
+-commutative88.2%
distribute-rgt-neg-in88.2%
fma-def88.3%
Simplified88.5%
Taylor expanded in uy around 0 73.9%
Simplified73.9%
Taylor expanded in maxCos around 0 71.8%
Final simplification76.1%
(FPCore (ux uy maxCos) :precision binary32 (* 2.0 (* (* PI uy) (sqrt (+ (* ux 2.0) (* -2.0 (* ux maxCos)))))))
float code(float ux, float uy, float maxCos) {
return 2.0f * ((((float) M_PI) * uy) * sqrtf(((ux * 2.0f) + (-2.0f * (ux * maxCos)))));
}
function code(ux, uy, maxCos) return Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * sqrt(Float32(Float32(ux * Float32(2.0)) + Float32(Float32(-2.0) * Float32(ux * maxCos)))))) end
function tmp = code(ux, uy, maxCos) tmp = single(2.0) * ((single(pi) * uy) * sqrt(((ux * single(2.0)) + (single(-2.0) * (ux * maxCos))))); end
\begin{array}{l}
\\
2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{ux \cdot 2 + -2 \cdot \left(ux \cdot maxCos\right)}\right)
\end{array}
Initial program 54.8%
associate-*l*54.8%
sub-neg54.8%
+-commutative54.8%
distribute-rgt-neg-in54.8%
fma-def54.8%
Simplified55.0%
Taylor expanded in uy around 0 48.0%
Simplified48.0%
Taylor expanded in ux around 0 67.5%
Taylor expanded in maxCos around 0 67.5%
Final simplification67.5%
(FPCore (ux uy maxCos) :precision binary32 (* 2.0 (* (* PI uy) (sqrt (* ux (- 2.0 (* 2.0 maxCos)))))))
float code(float ux, float uy, float maxCos) {
return 2.0f * ((((float) M_PI) * uy) * sqrtf((ux * (2.0f - (2.0f * maxCos)))));
}
function code(ux, uy, maxCos) return Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * sqrt(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos)))))) end
function tmp = code(ux, uy, maxCos) tmp = single(2.0) * ((single(pi) * uy) * sqrt((ux * (single(2.0) - (single(2.0) * maxCos))))); end
\begin{array}{l}
\\
2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\right)
\end{array}
Initial program 54.8%
associate-*l*54.8%
sub-neg54.8%
+-commutative54.8%
distribute-rgt-neg-in54.8%
fma-def54.8%
Simplified55.0%
Taylor expanded in uy around 0 48.0%
Simplified48.0%
Taylor expanded in ux around 0 67.5%
Final simplification67.5%
(FPCore (ux uy maxCos) :precision binary32 (* 2.0 (* (* PI uy) (sqrt (* ux 2.0)))))
float code(float ux, float uy, float maxCos) {
return 2.0f * ((((float) M_PI) * uy) * sqrtf((ux * 2.0f)));
}
function code(ux, uy, maxCos) return Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * sqrt(Float32(ux * Float32(2.0))))) end
function tmp = code(ux, uy, maxCos) tmp = single(2.0) * ((single(pi) * uy) * sqrt((ux * single(2.0)))); end
\begin{array}{l}
\\
2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{ux \cdot 2}\right)
\end{array}
Initial program 54.8%
associate-*l*54.8%
sub-neg54.8%
+-commutative54.8%
distribute-rgt-neg-in54.8%
fma-def54.8%
Simplified55.0%
Taylor expanded in uy around 0 48.0%
Simplified48.0%
Taylor expanded in ux around 0 67.5%
Taylor expanded in maxCos around 0 64.8%
*-commutative64.8%
Simplified64.8%
Final simplification64.8%
herbie shell --seed 2024019
(FPCore (ux uy maxCos)
:name "UniformSampleCone, y"
: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)))
(* (sin (* (* uy 2.0) PI)) (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (+ (- 1.0 ux) (* ux maxCos)))))))