
(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 16 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 (sin (* PI (* 2.0 uy))) 3.0)
(pow
(* (+ (* 2.0 ux) (* (pow ux 2.0) (+ maxCos -1.0))) (- 1.0 maxCos))
1.5))))
float code(float ux, float uy, float maxCos) {
return cbrtf((powf(sinf((((float) M_PI) * (2.0f * uy))), 3.0f) * powf((((2.0f * ux) + (powf(ux, 2.0f) * (maxCos + -1.0f))) * (1.0f - maxCos)), 1.5f)));
}
function code(ux, uy, maxCos) return cbrt(Float32((sin(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) ^ Float32(3.0)) * (Float32(Float32(Float32(Float32(2.0) * ux) + Float32((ux ^ Float32(2.0)) * Float32(maxCos + Float32(-1.0)))) * Float32(Float32(1.0) - maxCos)) ^ Float32(1.5)))) end
\begin{array}{l}
\\
\sqrt[3]{{\sin \left(\pi \cdot \left(2 \cdot uy\right)\right)}^{3} \cdot {\left(\left(2 \cdot ux + {ux}^{2} \cdot \left(maxCos + -1\right)\right) \cdot \left(1 - maxCos\right)\right)}^{1.5}}
\end{array}
Initial program 55.5%
associate-*l*55.5%
sub-neg55.5%
+-commutative55.5%
distribute-rgt-neg-in55.5%
fma-define55.6%
Simplified55.6%
Taylor expanded in ux around inf 98.5%
fma-define98.6%
+-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
distribute-lft-in98.6%
metadata-eval98.6%
+-commutative98.6%
associate--l+98.6%
mul-1-neg98.6%
sub-neg98.6%
*-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
add-exp-log92.2%
associate-*r*92.2%
*-commutative92.2%
count-292.2%
+-commutative92.2%
metadata-eval92.2%
sub-neg92.2%
*-commutative92.2%
sub-neg92.2%
metadata-eval92.2%
Applied egg-rr92.2%
Applied egg-rr98.6%
fma-undefine98.6%
associate-*r*98.6%
*-commutative98.6%
associate-*r*98.6%
distribute-rgt-out98.6%
+-commutative98.6%
metadata-eval98.6%
sub-neg98.6%
*-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Final simplification98.6%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sin (* uy (* PI 2.0)))
(sqrt
(fma
ux
(+ (- 1.0 maxCos) (- 1.0 maxCos))
(* (pow ux 2.0) (* (+ maxCos -1.0) (- 1.0 maxCos)))))))
float code(float ux, float uy, float maxCos) {
return sinf((uy * (((float) M_PI) * 2.0f))) * sqrtf(fmaf(ux, ((1.0f - maxCos) + (1.0f - maxCos)), (powf(ux, 2.0f) * ((maxCos + -1.0f) * (1.0f - maxCos)))));
}
function code(ux, uy, maxCos) return Float32(sin(Float32(uy * Float32(Float32(pi) * Float32(2.0)))) * sqrt(fma(ux, Float32(Float32(Float32(1.0) - maxCos) + Float32(Float32(1.0) - maxCos)), Float32((ux ^ Float32(2.0)) * Float32(Float32(maxCos + Float32(-1.0)) * Float32(Float32(1.0) - maxCos)))))) end
\begin{array}{l}
\\
\sin \left(uy \cdot \left(\pi \cdot 2\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \left(1 - maxCos\right) + \left(1 - maxCos\right), {ux}^{2} \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)\right)}
\end{array}
Initial program 55.5%
associate-*l*55.5%
sub-neg55.5%
+-commutative55.5%
distribute-rgt-neg-in55.5%
fma-define55.6%
Simplified55.6%
Taylor expanded in ux around inf 98.5%
fma-define98.6%
+-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
distribute-lft-in98.6%
metadata-eval98.6%
+-commutative98.6%
associate--l+98.6%
mul-1-neg98.6%
sub-neg98.6%
*-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Final simplification98.6%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* PI (* 2.0 uy))) (sqrt (* (+ (* 2.0 ux) (* (pow ux 2.0) (+ maxCos -1.0))) (- 1.0 maxCos)))))
float code(float ux, float uy, float maxCos) {
return sinf((((float) M_PI) * (2.0f * uy))) * sqrtf((((2.0f * ux) + (powf(ux, 2.0f) * (maxCos + -1.0f))) * (1.0f - maxCos)));
}
function code(ux, uy, maxCos) return Float32(sin(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) * sqrt(Float32(Float32(Float32(Float32(2.0) * ux) + Float32((ux ^ Float32(2.0)) * Float32(maxCos + Float32(-1.0)))) * Float32(Float32(1.0) - maxCos)))) end
function tmp = code(ux, uy, maxCos) tmp = sin((single(pi) * (single(2.0) * uy))) * sqrt((((single(2.0) * ux) + ((ux ^ single(2.0)) * (maxCos + single(-1.0)))) * (single(1.0) - maxCos))); end
\begin{array}{l}
\\
\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{\left(2 \cdot ux + {ux}^{2} \cdot \left(maxCos + -1\right)\right) \cdot \left(1 - maxCos\right)}
\end{array}
Initial program 55.5%
associate-*l*55.5%
sub-neg55.5%
+-commutative55.5%
distribute-rgt-neg-in55.5%
fma-define55.6%
Simplified55.6%
Taylor expanded in ux around inf 98.5%
fma-define98.6%
+-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
distribute-lft-in98.6%
metadata-eval98.6%
+-commutative98.6%
associate--l+98.6%
mul-1-neg98.6%
sub-neg98.6%
*-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
add-exp-log92.2%
associate-*r*92.2%
*-commutative92.2%
count-292.2%
+-commutative92.2%
metadata-eval92.2%
sub-neg92.2%
*-commutative92.2%
sub-neg92.2%
metadata-eval92.2%
Applied egg-rr92.2%
Taylor expanded in uy around inf 98.5%
associate-*r*98.5%
*-commutative98.5%
associate-*r*98.5%
*-commutative98.5%
sub-neg98.5%
metadata-eval98.5%
+-commutative98.5%
associate-*r*98.5%
distribute-rgt-out98.5%
+-commutative98.5%
metadata-eval98.5%
sub-neg98.5%
*-commutative98.5%
sub-neg98.5%
metadata-eval98.5%
+-commutative98.5%
Simplified98.5%
Final simplification98.5%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= maxCos 6.000000212225132e-7)
(* (sin (* PI (* 2.0 uy))) (sqrt (- (* 2.0 ux) (pow ux 2.0))))
(*
2.0
(*
(* PI uy)
(sqrt
(+
(+ (* 2.0 ux) (* -2.0 (* maxCos ux)))
(* (pow ux 2.0) (* (+ maxCos -1.0) (- 1.0 maxCos)))))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (maxCos <= 6.000000212225132e-7f) {
tmp = sinf((((float) M_PI) * (2.0f * uy))) * sqrtf(((2.0f * ux) - powf(ux, 2.0f)));
} else {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf((((2.0f * ux) + (-2.0f * (maxCos * ux))) + (powf(ux, 2.0f) * ((maxCos + -1.0f) * (1.0f - maxCos))))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (maxCos <= Float32(6.000000212225132e-7)) tmp = Float32(sin(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) * sqrt(Float32(Float32(Float32(2.0) * ux) - (ux ^ Float32(2.0))))); else tmp = Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * sqrt(Float32(Float32(Float32(Float32(2.0) * ux) + Float32(Float32(-2.0) * Float32(maxCos * ux))) + Float32((ux ^ Float32(2.0)) * Float32(Float32(maxCos + Float32(-1.0)) * Float32(Float32(1.0) - maxCos))))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (maxCos <= single(6.000000212225132e-7)) tmp = sin((single(pi) * (single(2.0) * uy))) * sqrt(((single(2.0) * ux) - (ux ^ single(2.0)))); else tmp = single(2.0) * ((single(pi) * uy) * sqrt((((single(2.0) * ux) + (single(-2.0) * (maxCos * ux))) + ((ux ^ single(2.0)) * ((maxCos + single(-1.0)) * (single(1.0) - maxCos)))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 6.000000212225132 \cdot 10^{-7}:\\
\;\;\;\;\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{2 \cdot ux - {ux}^{2}}\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{\left(2 \cdot ux + -2 \cdot \left(maxCos \cdot ux\right)\right) + {ux}^{2} \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right)}\right)\\
\end{array}
\end{array}
if maxCos < 6.0000002e-7Initial program 57.3%
associate-*l*57.3%
sub-neg57.3%
+-commutative57.3%
distribute-rgt-neg-in57.3%
fma-define57.3%
Simplified57.3%
Taylor expanded in ux around inf 98.6%
fma-define98.6%
+-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
distribute-lft-in98.6%
metadata-eval98.6%
+-commutative98.6%
associate--l+98.6%
mul-1-neg98.6%
sub-neg98.6%
*-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in maxCos around 0 98.4%
associate-*r*98.4%
*-commutative98.4%
*-commutative98.4%
*-commutative98.4%
+-commutative98.4%
mul-1-neg98.4%
unsub-neg98.4%
Simplified98.4%
if 6.0000002e-7 < maxCos Initial program 43.4%
associate-*l*43.4%
sub-neg43.4%
+-commutative43.4%
distribute-rgt-neg-in43.4%
fma-define43.7%
Simplified44.3%
Taylor expanded in ux around inf 98.4%
fma-define98.5%
+-commutative98.5%
sub-neg98.5%
metadata-eval98.5%
distribute-lft-in98.5%
metadata-eval98.5%
+-commutative98.5%
associate--l+98.4%
mul-1-neg98.4%
sub-neg98.4%
*-commutative98.4%
sub-neg98.4%
metadata-eval98.4%
+-commutative98.4%
Simplified98.4%
Taylor expanded in uy around 0 92.9%
Taylor expanded in maxCos around 0 92.9%
Final simplification97.8%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* ux (- 2.0 (* 2.0 maxCos)))))
(if (<= (* 2.0 uy) 0.00139999995008111)
(*
2.0
(*
(* PI uy)
(sqrt (+ (* (pow ux 2.0) (* (+ maxCos -1.0) (- 1.0 maxCos))) t_0))))
(* (sin (* PI (* 2.0 uy))) (sqrt t_0)))))
float code(float ux, float uy, float maxCos) {
float t_0 = ux * (2.0f - (2.0f * maxCos));
float tmp;
if ((2.0f * uy) <= 0.00139999995008111f) {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf(((powf(ux, 2.0f) * ((maxCos + -1.0f) * (1.0f - maxCos))) + t_0)));
} else {
tmp = sinf((((float) M_PI) * (2.0f * uy))) * sqrtf(t_0);
}
return tmp;
}
function code(ux, uy, maxCos) t_0 = Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))) tmp = Float32(0.0) if (Float32(Float32(2.0) * uy) <= Float32(0.00139999995008111)) tmp = Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * sqrt(Float32(Float32((ux ^ Float32(2.0)) * Float32(Float32(maxCos + Float32(-1.0)) * Float32(Float32(1.0) - maxCos))) + t_0)))); else tmp = Float32(sin(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) * sqrt(t_0)); end return tmp end
function tmp_2 = code(ux, uy, maxCos) t_0 = ux * (single(2.0) - (single(2.0) * maxCos)); tmp = single(0.0); if ((single(2.0) * uy) <= single(0.00139999995008111)) tmp = single(2.0) * ((single(pi) * uy) * sqrt((((ux ^ single(2.0)) * ((maxCos + single(-1.0)) * (single(1.0) - maxCos))) + t_0))); else tmp = sin((single(pi) * (single(2.0) * uy))) * sqrt(t_0); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := ux \cdot \left(2 - 2 \cdot maxCos\right)\\
\mathbf{if}\;2 \cdot uy \leq 0.00139999995008111:\\
\;\;\;\;2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{{ux}^{2} \cdot \left(\left(maxCos + -1\right) \cdot \left(1 - maxCos\right)\right) + t\_0}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{t\_0}\\
\end{array}
\end{array}
if (*.f32 uy 2) < 0.00139999995Initial program 56.3%
associate-*l*56.3%
sub-neg56.3%
+-commutative56.3%
distribute-rgt-neg-in56.3%
fma-define56.4%
Simplified56.4%
Taylor expanded in ux around inf 98.6%
fma-define98.6%
+-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
distribute-lft-in98.6%
metadata-eval98.6%
+-commutative98.6%
associate--l+98.6%
mul-1-neg98.6%
sub-neg98.6%
*-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in uy around 0 97.9%
if 0.00139999995 < (*.f32 uy 2) Initial program 53.4%
Taylor expanded in ux around 0 79.2%
Final simplification92.9%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* PI (* 2.0 uy))))
(if (<= (* 2.0 uy) 0.00139999995008111)
(*
t_0
(sqrt
(* (+ (* 2.0 ux) (* (pow ux 2.0) (+ maxCos -1.0))) (- 1.0 maxCos))))
(* (sin t_0) (sqrt (* ux (- 2.0 (* 2.0 maxCos))))))))
float code(float ux, float uy, float maxCos) {
float t_0 = ((float) M_PI) * (2.0f * uy);
float tmp;
if ((2.0f * uy) <= 0.00139999995008111f) {
tmp = t_0 * sqrtf((((2.0f * ux) + (powf(ux, 2.0f) * (maxCos + -1.0f))) * (1.0f - maxCos)));
} else {
tmp = sinf(t_0) * sqrtf((ux * (2.0f - (2.0f * maxCos))));
}
return tmp;
}
function code(ux, uy, maxCos) t_0 = Float32(Float32(pi) * Float32(Float32(2.0) * uy)) tmp = Float32(0.0) if (Float32(Float32(2.0) * uy) <= Float32(0.00139999995008111)) tmp = Float32(t_0 * sqrt(Float32(Float32(Float32(Float32(2.0) * ux) + Float32((ux ^ Float32(2.0)) * Float32(maxCos + Float32(-1.0)))) * Float32(Float32(1.0) - maxCos)))); else tmp = Float32(sin(t_0) * 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(pi) * (single(2.0) * uy); tmp = single(0.0); if ((single(2.0) * uy) <= single(0.00139999995008111)) tmp = t_0 * sqrt((((single(2.0) * ux) + ((ux ^ single(2.0)) * (maxCos + single(-1.0)))) * (single(1.0) - maxCos))); else tmp = sin(t_0) * sqrt((ux * (single(2.0) - (single(2.0) * maxCos)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \pi \cdot \left(2 \cdot uy\right)\\
\mathbf{if}\;2 \cdot uy \leq 0.00139999995008111:\\
\;\;\;\;t\_0 \cdot \sqrt{\left(2 \cdot ux + {ux}^{2} \cdot \left(maxCos + -1\right)\right) \cdot \left(1 - maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin t\_0 \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\\
\end{array}
\end{array}
if (*.f32 uy 2) < 0.00139999995Initial program 56.3%
associate-*l*56.3%
sub-neg56.3%
+-commutative56.3%
distribute-rgt-neg-in56.3%
fma-define56.4%
Simplified56.4%
Taylor expanded in ux around inf 98.6%
fma-define98.6%
+-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
distribute-lft-in98.6%
metadata-eval98.6%
+-commutative98.6%
associate--l+98.6%
mul-1-neg98.6%
sub-neg98.6%
*-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
add-exp-log92.9%
associate-*r*92.9%
*-commutative92.9%
count-292.9%
+-commutative92.9%
metadata-eval92.9%
sub-neg92.9%
*-commutative92.9%
sub-neg92.9%
metadata-eval92.9%
Applied egg-rr92.9%
Taylor expanded in uy around 0 97.9%
associate-*r*97.9%
associate-*r*97.9%
*-commutative97.9%
*-commutative97.9%
Simplified97.9%
if 0.00139999995 < (*.f32 uy 2) Initial program 53.4%
Taylor expanded in ux around 0 79.2%
Final simplification92.9%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* ux (- 2.0 (* 2.0 maxCos)))))
(if (<= (* 2.0 uy) 0.00139999995008111)
(* 2.0 (* (* PI uy) (sqrt (- t_0 (pow ux 2.0)))))
(* (sin (* PI (* 2.0 uy))) (sqrt t_0)))))
float code(float ux, float uy, float maxCos) {
float t_0 = ux * (2.0f - (2.0f * maxCos));
float tmp;
if ((2.0f * uy) <= 0.00139999995008111f) {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf((t_0 - powf(ux, 2.0f))));
} else {
tmp = sinf((((float) M_PI) * (2.0f * uy))) * sqrtf(t_0);
}
return tmp;
}
function code(ux, uy, maxCos) t_0 = Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))) tmp = Float32(0.0) if (Float32(Float32(2.0) * uy) <= Float32(0.00139999995008111)) tmp = Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * sqrt(Float32(t_0 - (ux ^ Float32(2.0)))))); else tmp = Float32(sin(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) * sqrt(t_0)); end return tmp end
function tmp_2 = code(ux, uy, maxCos) t_0 = ux * (single(2.0) - (single(2.0) * maxCos)); tmp = single(0.0); if ((single(2.0) * uy) <= single(0.00139999995008111)) tmp = single(2.0) * ((single(pi) * uy) * sqrt((t_0 - (ux ^ single(2.0))))); else tmp = sin((single(pi) * (single(2.0) * uy))) * sqrt(t_0); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := ux \cdot \left(2 - 2 \cdot maxCos\right)\\
\mathbf{if}\;2 \cdot uy \leq 0.00139999995008111:\\
\;\;\;\;2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{t\_0 - {ux}^{2}}\right)\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\pi \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{t\_0}\\
\end{array}
\end{array}
if (*.f32 uy 2) < 0.00139999995Initial program 56.3%
associate-*l*56.3%
sub-neg56.3%
+-commutative56.3%
distribute-rgt-neg-in56.3%
fma-define56.4%
Simplified56.4%
Taylor expanded in ux around inf 98.6%
fma-define98.6%
+-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
distribute-lft-in98.6%
metadata-eval98.6%
+-commutative98.6%
associate--l+98.6%
mul-1-neg98.6%
sub-neg98.6%
*-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in uy around 0 97.9%
Taylor expanded in maxCos around 0 97.0%
if 0.00139999995 < (*.f32 uy 2) Initial program 53.4%
Taylor expanded in ux around 0 79.2%
Final simplification92.3%
(FPCore (ux uy maxCos) :precision binary32 (if (<= (* 2.0 uy) 0.00139999995008111) (* 2.0 (* (sqrt (- (* 2.0 ux) (pow ux 2.0))) (* PI uy))) (* (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.00139999995008111f) {
tmp = 2.0f * (sqrtf(((2.0f * ux) - powf(ux, 2.0f))) * (((float) M_PI) * uy));
} 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.00139999995008111)) tmp = Float32(Float32(2.0) * Float32(sqrt(Float32(Float32(Float32(2.0) * ux) - (ux ^ Float32(2.0)))) * Float32(Float32(pi) * uy))); 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.00139999995008111)) tmp = single(2.0) * (sqrt(((single(2.0) * ux) - (ux ^ single(2.0)))) * (single(pi) * uy)); 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.00139999995008111:\\
\;\;\;\;2 \cdot \left(\sqrt{2 \cdot ux - {ux}^{2}} \cdot \left(\pi \cdot uy\right)\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.00139999995Initial program 56.3%
associate-*l*56.3%
sub-neg56.3%
+-commutative56.3%
distribute-rgt-neg-in56.3%
fma-define56.4%
Simplified56.4%
Taylor expanded in ux around inf 98.6%
fma-define98.6%
+-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
distribute-lft-in98.6%
metadata-eval98.6%
+-commutative98.6%
associate--l+98.6%
mul-1-neg98.6%
sub-neg98.6%
*-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in uy around 0 97.9%
Taylor expanded in maxCos around 0 92.6%
+-commutative92.6%
mul-1-neg92.6%
unsub-neg92.6%
Simplified92.6%
if 0.00139999995 < (*.f32 uy 2) Initial program 53.4%
Taylor expanded in ux around 0 79.2%
Final simplification89.0%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* PI (* 2.0 uy)))))
(if (<= ux 0.00019449999672360718)
(* t_0 (sqrt (* ux (- 2.0 (* 2.0 maxCos)))))
(* t_0 (sqrt (+ 1.0 (* (- 1.0 ux) (+ ux -1.0))))))))
float code(float ux, float uy, float maxCos) {
float t_0 = sinf((((float) M_PI) * (2.0f * uy)));
float tmp;
if (ux <= 0.00019449999672360718f) {
tmp = t_0 * sqrtf((ux * (2.0f - (2.0f * maxCos))));
} else {
tmp = t_0 * sqrtf((1.0f + ((1.0f - ux) * (ux + -1.0f))));
}
return tmp;
}
function code(ux, uy, maxCos) t_0 = sin(Float32(Float32(pi) * Float32(Float32(2.0) * uy))) tmp = Float32(0.0) if (ux <= Float32(0.00019449999672360718)) tmp = Float32(t_0 * sqrt(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))))); else tmp = Float32(t_0 * 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) t_0 = sin((single(pi) * (single(2.0) * uy))); tmp = single(0.0); if (ux <= single(0.00019449999672360718)) tmp = t_0 * sqrt((ux * (single(2.0) - (single(2.0) * maxCos)))); else tmp = t_0 * sqrt((single(1.0) + ((single(1.0) - ux) * (ux + single(-1.0))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\pi \cdot \left(2 \cdot uy\right)\right)\\
\mathbf{if}\;ux \leq 0.00019449999672360718:\\
\;\;\;\;t\_0 \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{1 + \left(1 - ux\right) \cdot \left(ux + -1\right)}\\
\end{array}
\end{array}
if ux < 1.94499997e-4Initial program 38.0%
Taylor expanded in ux around 0 92.4%
if 1.94499997e-4 < ux Initial program 87.8%
associate-*l*87.8%
sub-neg87.8%
+-commutative87.8%
distribute-rgt-neg-in87.8%
fma-define87.8%
Simplified88.0%
Taylor expanded in uy around inf 88.0%
Simplified88.0%
Taylor expanded in maxCos around 0 84.6%
associate-*r*84.6%
*-commutative84.6%
mul-1-neg84.6%
sub-neg84.6%
Simplified84.6%
Final simplification89.6%
(FPCore (ux uy maxCos) :precision binary32 (if (<= (* 2.0 uy) 0.00139999995008111) (* 2.0 (* uy (* PI (sqrt (- (* 2.0 ux) (pow ux 2.0)))))) (* (sin (* uy (* PI 2.0))) (sqrt (* 2.0 ux)))))
float code(float ux, float uy, float maxCos) {
float tmp;
if ((2.0f * uy) <= 0.00139999995008111f) {
tmp = 2.0f * (uy * (((float) M_PI) * sqrtf(((2.0f * ux) - powf(ux, 2.0f)))));
} else {
tmp = sinf((uy * (((float) M_PI) * 2.0f))) * sqrtf((2.0f * ux));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (Float32(Float32(2.0) * uy) <= Float32(0.00139999995008111)) tmp = Float32(Float32(2.0) * Float32(uy * Float32(Float32(pi) * sqrt(Float32(Float32(Float32(2.0) * ux) - (ux ^ Float32(2.0))))))); else tmp = Float32(sin(Float32(uy * Float32(Float32(pi) * Float32(2.0)))) * sqrt(Float32(Float32(2.0) * ux))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if ((single(2.0) * uy) <= single(0.00139999995008111)) tmp = single(2.0) * (uy * (single(pi) * sqrt(((single(2.0) * ux) - (ux ^ single(2.0)))))); else tmp = sin((uy * (single(pi) * single(2.0)))) * sqrt((single(2.0) * ux)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.00139999995008111:\\
\;\;\;\;2 \cdot \left(uy \cdot \left(\pi \cdot \sqrt{2 \cdot ux - {ux}^{2}}\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sin \left(uy \cdot \left(\pi \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux}\\
\end{array}
\end{array}
if (*.f32 uy 2) < 0.00139999995Initial program 56.3%
associate-*l*56.3%
sub-neg56.3%
+-commutative56.3%
distribute-rgt-neg-in56.3%
fma-define56.4%
Simplified56.4%
Taylor expanded in ux around inf 98.6%
fma-define98.6%
+-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
distribute-lft-in98.6%
metadata-eval98.6%
+-commutative98.6%
associate--l+98.6%
mul-1-neg98.6%
sub-neg98.6%
*-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in uy around 0 97.9%
Taylor expanded in maxCos around 0 92.6%
associate-*l*92.3%
+-commutative92.3%
mul-1-neg92.3%
unsub-neg92.3%
Simplified92.3%
if 0.00139999995 < (*.f32 uy 2) Initial program 53.4%
associate-*l*53.4%
sub-neg53.4%
+-commutative53.4%
distribute-rgt-neg-in53.4%
fma-define53.3%
Simplified53.5%
Taylor expanded in maxCos around 0 52.1%
Taylor expanded in ux around 0 78.3%
Final simplification88.6%
(FPCore (ux uy maxCos) :precision binary32 (if (<= (* 2.0 uy) 0.00139999995008111) (* 2.0 (* (sqrt (- (* 2.0 ux) (pow ux 2.0))) (* PI uy))) (* (sin (* uy (* PI 2.0))) (sqrt (* 2.0 ux)))))
float code(float ux, float uy, float maxCos) {
float tmp;
if ((2.0f * uy) <= 0.00139999995008111f) {
tmp = 2.0f * (sqrtf(((2.0f * ux) - powf(ux, 2.0f))) * (((float) M_PI) * uy));
} else {
tmp = sinf((uy * (((float) M_PI) * 2.0f))) * sqrtf((2.0f * ux));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (Float32(Float32(2.0) * uy) <= Float32(0.00139999995008111)) tmp = Float32(Float32(2.0) * Float32(sqrt(Float32(Float32(Float32(2.0) * ux) - (ux ^ Float32(2.0)))) * Float32(Float32(pi) * uy))); else tmp = Float32(sin(Float32(uy * Float32(Float32(pi) * Float32(2.0)))) * sqrt(Float32(Float32(2.0) * ux))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if ((single(2.0) * uy) <= single(0.00139999995008111)) tmp = single(2.0) * (sqrt(((single(2.0) * ux) - (ux ^ single(2.0)))) * (single(pi) * uy)); else tmp = sin((uy * (single(pi) * single(2.0)))) * sqrt((single(2.0) * ux)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.00139999995008111:\\
\;\;\;\;2 \cdot \left(\sqrt{2 \cdot ux - {ux}^{2}} \cdot \left(\pi \cdot uy\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sin \left(uy \cdot \left(\pi \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux}\\
\end{array}
\end{array}
if (*.f32 uy 2) < 0.00139999995Initial program 56.3%
associate-*l*56.3%
sub-neg56.3%
+-commutative56.3%
distribute-rgt-neg-in56.3%
fma-define56.4%
Simplified56.4%
Taylor expanded in ux around inf 98.6%
fma-define98.6%
+-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
distribute-lft-in98.6%
metadata-eval98.6%
+-commutative98.6%
associate--l+98.6%
mul-1-neg98.6%
sub-neg98.6%
*-commutative98.6%
sub-neg98.6%
metadata-eval98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in uy around 0 97.9%
Taylor expanded in maxCos around 0 92.6%
+-commutative92.6%
mul-1-neg92.6%
unsub-neg92.6%
Simplified92.6%
if 0.00139999995 < (*.f32 uy 2) Initial program 53.4%
associate-*l*53.4%
sub-neg53.4%
+-commutative53.4%
distribute-rgt-neg-in53.4%
fma-define53.3%
Simplified53.5%
Taylor expanded in maxCos around 0 52.1%
Taylor expanded in ux around 0 78.3%
Final simplification88.8%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.0004349999944679439)
(* (sin (* uy (* PI 2.0))) (sqrt (* 2.0 ux)))
(*
2.0
(*
(* PI uy)
(sqrt
(+
1.0
(* (+ 1.0 (* ux (+ maxCos -1.0))) (+ ux (- -1.0 (* maxCos ux))))))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.0004349999944679439f) {
tmp = sinf((uy * (((float) M_PI) * 2.0f))) * sqrtf((2.0f * ux));
} else {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf((1.0f + ((1.0f + (ux * (maxCos + -1.0f))) * (ux + (-1.0f - (maxCos * ux)))))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.0004349999944679439)) tmp = Float32(sin(Float32(uy * Float32(Float32(pi) * Float32(2.0)))) * sqrt(Float32(Float32(2.0) * ux))); 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(maxCos * ux)))))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.0004349999944679439)) tmp = sin((uy * (single(pi) * single(2.0)))) * sqrt((single(2.0) * ux)); else tmp = single(2.0) * ((single(pi) * uy) * sqrt((single(1.0) + ((single(1.0) + (ux * (maxCos + single(-1.0)))) * (ux + (single(-1.0) - (maxCos * ux))))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.0004349999944679439:\\
\;\;\;\;\sin \left(uy \cdot \left(\pi \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux}\\
\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 - maxCos \cdot ux\right)\right)}\right)\\
\end{array}
\end{array}
if ux < 4.34999994e-4Initial program 39.8%
associate-*l*39.8%
sub-neg39.8%
+-commutative39.8%
distribute-rgt-neg-in39.8%
fma-define39.8%
Simplified39.9%
Taylor expanded in maxCos around 0 39.6%
Taylor expanded in ux around 0 87.3%
if 4.34999994e-4 < ux Initial program 88.9%
associate-*l*88.9%
sub-neg88.9%
+-commutative88.9%
distribute-rgt-neg-in88.9%
fma-define89.0%
Simplified89.1%
Taylor expanded in uy around 0 77.9%
Simplified77.9%
Taylor expanded in uy around 0 77.9%
Final simplification84.3%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.0001900000061141327)
(* 2.0 (* (* PI uy) (sqrt (* ux (- 2.0 (* 2.0 maxCos))))))
(*
2.0
(*
(* PI uy)
(sqrt
(+
1.0
(* (+ 1.0 (* ux (+ maxCos -1.0))) (+ ux (- -1.0 (* maxCos ux))))))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.0001900000061141327f) {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf((ux * (2.0f - (2.0f * maxCos)))));
} else {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf((1.0f + ((1.0f + (ux * (maxCos + -1.0f))) * (ux + (-1.0f - (maxCos * ux)))))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.0001900000061141327)) tmp = Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * sqrt(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * 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(maxCos * ux)))))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.0001900000061141327)) tmp = single(2.0) * ((single(pi) * uy) * sqrt((ux * (single(2.0) - (single(2.0) * 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) - (maxCos * ux))))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.0001900000061141327:\\
\;\;\;\;2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{ux \cdot \left(2 - 2 \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 - maxCos \cdot ux\right)\right)}\right)\\
\end{array}
\end{array}
if ux < 1.90000006e-4Initial program 37.9%
associate-*l*37.9%
sub-neg37.9%
+-commutative37.9%
distribute-rgt-neg-in37.9%
fma-define37.9%
Simplified37.9%
Taylor expanded in uy around 0 37.0%
Simplified37.0%
Taylor expanded in ux around 0 82.7%
if 1.90000006e-4 < ux Initial program 87.6%
associate-*l*87.6%
sub-neg87.6%
+-commutative87.6%
distribute-rgt-neg-in87.6%
fma-define87.7%
Simplified87.8%
Taylor expanded in uy around 0 75.9%
Simplified75.9%
Taylor expanded in uy around 0 75.9%
Final simplification80.3%
(FPCore (ux uy maxCos) :precision binary32 (if (<= ux 0.0001900000061141327) (* 2.0 (* (* PI uy) (sqrt (* ux (- 2.0 (* 2.0 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.0001900000061141327f) {
tmp = 2.0f * ((((float) M_PI) * uy) * sqrtf((ux * (2.0f - (2.0f * 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.0001900000061141327)) tmp = Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * sqrt(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * 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.0001900000061141327)) tmp = single(2.0) * ((single(pi) * uy) * sqrt((ux * (single(2.0) - (single(2.0) * 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.0001900000061141327:\\
\;\;\;\;2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{ux \cdot \left(2 - 2 \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.90000006e-4Initial program 37.9%
associate-*l*37.9%
sub-neg37.9%
+-commutative37.9%
distribute-rgt-neg-in37.9%
fma-define37.9%
Simplified37.9%
Taylor expanded in uy around 0 37.0%
Simplified37.0%
Taylor expanded in ux around 0 82.7%
if 1.90000006e-4 < ux Initial program 87.6%
associate-*l*87.6%
sub-neg87.6%
+-commutative87.6%
distribute-rgt-neg-in87.6%
fma-define87.7%
Simplified87.8%
Taylor expanded in uy around 0 75.9%
Simplified75.9%
Taylor expanded in maxCos around 0 73.4%
Final simplification79.4%
(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 55.5%
associate-*l*55.5%
sub-neg55.5%
+-commutative55.5%
distribute-rgt-neg-in55.5%
fma-define55.6%
Simplified55.6%
Taylor expanded in uy around 0 50.8%
Simplified50.8%
Taylor expanded in ux around 0 71.2%
Final simplification71.2%
(FPCore (ux uy maxCos) :precision binary32 (* 2.0 (* (* PI uy) (sqrt (* 2.0 ux)))))
float code(float ux, float uy, float maxCos) {
return 2.0f * ((((float) M_PI) * uy) * sqrtf((2.0f * ux)));
}
function code(ux, uy, maxCos) return Float32(Float32(2.0) * Float32(Float32(Float32(pi) * uy) * sqrt(Float32(Float32(2.0) * ux)))) end
function tmp = code(ux, uy, maxCos) tmp = single(2.0) * ((single(pi) * uy) * sqrt((single(2.0) * ux))); end
\begin{array}{l}
\\
2 \cdot \left(\left(\pi \cdot uy\right) \cdot \sqrt{2 \cdot ux}\right)
\end{array}
Initial program 55.5%
associate-*l*55.5%
sub-neg55.5%
+-commutative55.5%
distribute-rgt-neg-in55.5%
fma-define55.6%
Simplified55.6%
Taylor expanded in uy around 0 50.8%
Simplified50.8%
Taylor expanded in ux around 0 71.2%
Taylor expanded in maxCos around 0 68.2%
Final simplification68.2%
herbie shell --seed 2024039
(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)))))))