
(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 (* uy (* 2.0 PI)))
(sqrt
(fma
ux
(+ (- 1.0 maxCos) (- 1.0 maxCos))
(* (pow ux 2.0) (* (- 1.0 maxCos) (+ maxCos -1.0)))))))
float code(float ux, float uy, float maxCos) {
return cosf((uy * (2.0f * ((float) M_PI)))) * sqrtf(fmaf(ux, ((1.0f - maxCos) + (1.0f - maxCos)), (powf(ux, 2.0f) * ((1.0f - maxCos) * (maxCos + -1.0f)))));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(fma(ux, Float32(Float32(Float32(1.0) - maxCos) + Float32(Float32(1.0) - maxCos)), Float32((ux ^ Float32(2.0)) * Float32(Float32(Float32(1.0) - maxCos) * Float32(maxCos + Float32(-1.0))))))) end
\begin{array}{l}
\\
\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, \left(1 - maxCos\right) + \left(1 - maxCos\right), {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right)\right)}
\end{array}
Initial program 54.6%
associate-*l*54.6%
sub-neg54.6%
+-commutative54.6%
distribute-rgt-neg-in54.6%
fma-define54.9%
Simplified55.0%
Taylor expanded in ux around inf 99.2%
fma-define99.2%
+-commutative99.2%
sub-neg99.2%
metadata-eval99.2%
+-commutative99.2%
distribute-lft-in99.2%
metadata-eval99.2%
associate--l+99.2%
mul-1-neg99.2%
sub-neg99.2%
*-commutative99.2%
sub-neg99.2%
metadata-eval99.2%
+-commutative99.2%
Simplified99.2%
Final simplification99.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (cos (* PI (* uy 2.0)))))
(if (<= t_0 0.9999849796295166)
(* t_0 (sqrt (+ (* 2.0 ux) (* -2.0 (* ux maxCos)))))
(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 t_0 = cosf((((float) M_PI) * (uy * 2.0f)));
float tmp;
if (t_0 <= 0.9999849796295166f) {
tmp = t_0 * sqrtf(((2.0f * ux) + (-2.0f * (ux * maxCos))));
} else {
tmp = sqrtf(((powf(ux, 2.0f) * ((1.0f - maxCos) * (maxCos + -1.0f))) + (ux * (2.0f - (2.0f * maxCos)))));
}
return tmp;
}
function code(ux, uy, maxCos) t_0 = cos(Float32(Float32(pi) * Float32(uy * Float32(2.0)))) tmp = Float32(0.0) if (t_0 <= Float32(0.9999849796295166)) tmp = Float32(t_0 * sqrt(Float32(Float32(Float32(2.0) * ux) + Float32(Float32(-2.0) * Float32(ux * maxCos))))); else 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))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) t_0 = cos((single(pi) * (uy * single(2.0)))); tmp = single(0.0); if (t_0 <= single(0.9999849796295166)) tmp = t_0 * sqrt(((single(2.0) * ux) + (single(-2.0) * (ux * maxCos)))); else tmp = 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}
t_0 := \cos \left(\pi \cdot \left(uy \cdot 2\right)\right)\\
\mathbf{if}\;t\_0 \leq 0.9999849796295166:\\
\;\;\;\;t\_0 \cdot \sqrt{2 \cdot ux + -2 \cdot \left(ux \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\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}
\end{array}
if (cos.f32 (*.f32 (*.f32 uy 2) (PI.f32))) < 0.99998498Initial program 54.5%
Taylor expanded in ux around 0 79.6%
Taylor expanded in maxCos around 0 79.6%
if 0.99998498 < (cos.f32 (*.f32 (*.f32 uy 2) (PI.f32))) Initial program 54.6%
associate-*l*54.6%
sub-neg54.6%
+-commutative54.6%
distribute-rgt-neg-in54.6%
fma-define54.9%
Simplified55.0%
Taylor expanded in ux around inf 99.5%
fma-define99.6%
+-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
distribute-lft-in99.6%
metadata-eval99.6%
associate--l+99.6%
mul-1-neg99.6%
sub-neg99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in uy around 0 97.8%
Final simplification92.2%
(FPCore (ux uy maxCos)
:precision binary32
(*
(cos (* 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 cosf((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(cos(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 = cos((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}
\\
\cos \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.6%
associate-*l*54.6%
sub-neg54.6%
+-commutative54.6%
distribute-rgt-neg-in54.6%
fma-define54.9%
Simplified55.0%
Taylor expanded in ux around inf 99.2%
Final simplification99.2%
(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.6%
associate-*l*54.6%
sub-neg54.6%
+-commutative54.6%
distribute-rgt-neg-in54.6%
fma-define54.9%
Simplified55.0%
Taylor expanded in ux around inf 99.2%
fma-define99.2%
+-commutative99.2%
sub-neg99.2%
metadata-eval99.2%
+-commutative99.2%
distribute-lft-in99.2%
metadata-eval99.2%
associate--l+99.2%
mul-1-neg99.2%
sub-neg99.2%
*-commutative99.2%
sub-neg99.2%
metadata-eval99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in uy around inf 99.2%
Final simplification99.2%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* uy 2.0) 0.00011999999696854502)
(sqrt
(fma
ux
(+ 2.0 (* maxCos -2.0))
(* (pow ux 2.0) (* (- 1.0 maxCos) (+ maxCos -1.0)))))
(* (cos (* uy (* 2.0 PI))) (sqrt (- (* 2.0 ux) (pow ux 2.0))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if ((uy * 2.0f) <= 0.00011999999696854502f) {
tmp = sqrtf(fmaf(ux, (2.0f + (maxCos * -2.0f)), (powf(ux, 2.0f) * ((1.0f - maxCos) * (maxCos + -1.0f)))));
} else {
tmp = cosf((uy * (2.0f * ((float) M_PI)))) * sqrtf(((2.0f * ux) - powf(ux, 2.0f)));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (Float32(uy * Float32(2.0)) <= Float32(0.00011999999696854502)) tmp = 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)))))); else tmp = Float32(cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(Float32(Float32(Float32(2.0) * ux) - (ux ^ Float32(2.0))))); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \cdot 2 \leq 0.00011999999696854502:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(ux, 2 + maxCos \cdot -2, {ux}^{2} \cdot \left(\left(1 - maxCos\right) \cdot \left(maxCos + -1\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{2 \cdot ux - {ux}^{2}}\\
\end{array}
\end{array}
if (*.f32 uy 2) < 1.19999997e-4Initial program 54.3%
associate-*l*54.3%
sub-neg54.3%
+-commutative54.3%
distribute-rgt-neg-in54.3%
fma-define54.6%
Simplified54.8%
Taylor expanded in ux around inf 99.5%
fma-define99.6%
+-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
distribute-lft-in99.6%
metadata-eval99.6%
associate--l+99.6%
mul-1-neg99.6%
sub-neg99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in uy around 0 99.6%
sub-neg99.6%
metadata-eval99.6%
distribute-rgt-neg-in99.6%
mul-1-neg99.6%
distribute-lft-in99.6%
mul-1-neg99.6%
sub-neg99.6%
sub-neg99.6%
metadata-eval99.6%
fma-undefine99.6%
Simplified99.6%
if 1.19999997e-4 < (*.f32 uy 2) Initial program 55.0%
associate-*l*55.0%
sub-neg55.0%
+-commutative55.0%
distribute-rgt-neg-in55.0%
fma-define55.4%
Simplified55.4%
Taylor expanded in ux around inf 98.8%
fma-define98.8%
+-commutative98.8%
sub-neg98.8%
metadata-eval98.8%
+-commutative98.8%
distribute-lft-in98.8%
metadata-eval98.8%
associate--l+98.7%
mul-1-neg98.7%
sub-neg98.7%
*-commutative98.7%
sub-neg98.7%
metadata-eval98.7%
+-commutative98.7%
Simplified98.7%
Taylor expanded in maxCos around 0 93.7%
+-commutative93.7%
mul-1-neg93.7%
unsub-neg93.7%
*-commutative93.7%
Simplified93.7%
Final simplification97.2%
(FPCore (ux uy maxCos)
:precision binary32
(*
(cos (* uy (* 2.0 PI)))
(sqrt
(+
(* ux (+ 2.0 (* maxCos -2.0)))
(* (pow ux 2.0) (+ -1.0 (* 2.0 maxCos)))))))
float code(float ux, float uy, float maxCos) {
return cosf((uy * (2.0f * ((float) M_PI)))) * sqrtf(((ux * (2.0f + (maxCos * -2.0f))) + (powf(ux, 2.0f) * (-1.0f + (2.0f * maxCos)))));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(Float32(Float32(ux * Float32(Float32(2.0) + Float32(maxCos * Float32(-2.0)))) + Float32((ux ^ Float32(2.0)) * Float32(Float32(-1.0) + Float32(Float32(2.0) * maxCos)))))) end
function tmp = code(ux, uy, maxCos) tmp = cos((uy * (single(2.0) * single(pi)))) * sqrt(((ux * (single(2.0) + (maxCos * single(-2.0)))) + ((ux ^ single(2.0)) * (single(-1.0) + (single(2.0) * maxCos))))); end
\begin{array}{l}
\\
\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + maxCos \cdot -2\right) + {ux}^{2} \cdot \left(-1 + 2 \cdot maxCos\right)}
\end{array}
Initial program 54.6%
associate-*l*54.6%
sub-neg54.6%
+-commutative54.6%
distribute-rgt-neg-in54.6%
fma-define54.9%
Simplified55.0%
Taylor expanded in ux around inf 99.2%
Taylor expanded in maxCos around 0 99.2%
*-commutative99.2%
Simplified99.2%
Taylor expanded in maxCos around 0 98.4%
Final simplification98.4%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* uy 2.0) 0.00011999999696854502)
(sqrt
(+
(* (pow ux 2.0) (* (- 1.0 maxCos) (+ maxCos -1.0)))
(* ux (- 2.0 (* 2.0 maxCos)))))
(* (cos (* uy (* 2.0 PI))) (sqrt (- (* 2.0 ux) (pow ux 2.0))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if ((uy * 2.0f) <= 0.00011999999696854502f) {
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(((2.0f * ux) - powf(ux, 2.0f)));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (Float32(uy * Float32(2.0)) <= Float32(0.00011999999696854502)) 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(Float32(Float32(2.0) * ux) - (ux ^ 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.00011999999696854502)) 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(((single(2.0) * ux) - (ux ^ single(2.0)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \cdot 2 \leq 0.00011999999696854502:\\
\;\;\;\;\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{2 \cdot ux - {ux}^{2}}\\
\end{array}
\end{array}
if (*.f32 uy 2) < 1.19999997e-4Initial program 54.3%
associate-*l*54.3%
sub-neg54.3%
+-commutative54.3%
distribute-rgt-neg-in54.3%
fma-define54.6%
Simplified54.8%
Taylor expanded in ux around inf 99.5%
fma-define99.6%
+-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
distribute-lft-in99.6%
metadata-eval99.6%
associate--l+99.6%
mul-1-neg99.6%
sub-neg99.6%
*-commutative99.6%
sub-neg99.6%
metadata-eval99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in uy around 0 99.6%
if 1.19999997e-4 < (*.f32 uy 2) Initial program 55.0%
associate-*l*55.0%
sub-neg55.0%
+-commutative55.0%
distribute-rgt-neg-in55.0%
fma-define55.4%
Simplified55.4%
Taylor expanded in ux around inf 98.8%
fma-define98.8%
+-commutative98.8%
sub-neg98.8%
metadata-eval98.8%
+-commutative98.8%
distribute-lft-in98.8%
metadata-eval98.8%
associate--l+98.7%
mul-1-neg98.7%
sub-neg98.7%
*-commutative98.7%
sub-neg98.7%
metadata-eval98.7%
+-commutative98.7%
Simplified98.7%
Taylor expanded in maxCos around 0 93.7%
+-commutative93.7%
mul-1-neg93.7%
unsub-neg93.7%
*-commutative93.7%
Simplified93.7%
Final simplification97.2%
(FPCore (ux uy maxCos) :precision binary32 (* (cos (* uy (* 2.0 PI))) (sqrt (- (* ux (+ 2.0 (* maxCos -2.0))) (pow ux 2.0)))))
float code(float ux, float uy, float maxCos) {
return cosf((uy * (2.0f * ((float) M_PI)))) * sqrtf(((ux * (2.0f + (maxCos * -2.0f))) - powf(ux, 2.0f)));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(Float32(Float32(ux * Float32(Float32(2.0) + Float32(maxCos * Float32(-2.0)))) - (ux ^ Float32(2.0))))) end
function tmp = code(ux, uy, maxCos) tmp = cos((uy * (single(2.0) * single(pi)))) * sqrt(((ux * (single(2.0) + (maxCos * single(-2.0)))) - (ux ^ single(2.0)))); end
\begin{array}{l}
\\
\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 + maxCos \cdot -2\right) - {ux}^{2}}
\end{array}
Initial program 54.6%
associate-*l*54.6%
sub-neg54.6%
+-commutative54.6%
distribute-rgt-neg-in54.6%
fma-define54.9%
Simplified55.0%
Taylor expanded in ux around inf 99.2%
Taylor expanded in maxCos around 0 99.2%
*-commutative99.2%
Simplified99.2%
Taylor expanded in maxCos around 0 97.8%
Final simplification97.8%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.00031999999191612005)
(* (cos (* PI (* uy 2.0))) (sqrt (+ (* 2.0 ux) (* -2.0 (* ux maxCos)))))
(sqrt
(- 1.0 (* (+ 1.0 (* ux (+ maxCos -1.0))) (- (+ 1.0 (* ux maxCos)) ux))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00031999999191612005f) {
tmp = cosf((((float) M_PI) * (uy * 2.0f))) * sqrtf(((2.0f * ux) + (-2.0f * (ux * maxCos))));
} else {
tmp = sqrtf((1.0f - ((1.0f + (ux * (maxCos + -1.0f))) * ((1.0f + (ux * maxCos)) - ux))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.00031999999191612005)) tmp = Float32(cos(Float32(Float32(pi) * Float32(uy * Float32(2.0)))) * sqrt(Float32(Float32(Float32(2.0) * ux) + Float32(Float32(-2.0) * Float32(ux * maxCos))))); else tmp = sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(1.0) + Float32(ux * Float32(maxCos + Float32(-1.0)))) * Float32(Float32(Float32(1.0) + Float32(ux * maxCos)) - ux)))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.00031999999191612005)) tmp = cos((single(pi) * (uy * single(2.0)))) * sqrt(((single(2.0) * ux) + (single(-2.0) * (ux * maxCos)))); else tmp = sqrt((single(1.0) - ((single(1.0) + (ux * (maxCos + single(-1.0)))) * ((single(1.0) + (ux * maxCos)) - ux)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00031999999191612005:\\
\;\;\;\;\cos \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux + -2 \cdot \left(ux \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 + ux \cdot \left(maxCos + -1\right)\right) \cdot \left(\left(1 + ux \cdot maxCos\right) - ux\right)}\\
\end{array}
\end{array}
if ux < 3.19999992e-4Initial program 37.7%
Taylor expanded in ux around 0 92.1%
Taylor expanded in maxCos around 0 92.1%
if 3.19999992e-4 < ux Initial program 89.7%
associate-*l*89.7%
sub-neg89.7%
+-commutative89.7%
distribute-rgt-neg-in89.7%
fma-define90.4%
Simplified90.7%
Taylor expanded in uy around inf 90.0%
Simplified90.0%
Taylor expanded in uy around 0 76.5%
Final simplification87.1%
(FPCore (ux uy maxCos) :precision binary32 (if (<= ux 0.0001900000061141327) (* (cos (* PI (* uy 2.0))) (sqrt (+ (* 2.0 ux) (* -2.0 (* ux maxCos))))) (* (cos (* 2.0 (* uy PI))) (sqrt (+ 1.0 (- -1.0 (* ux (+ ux -2.0))))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.0001900000061141327f) {
tmp = cosf((((float) M_PI) * (uy * 2.0f))) * sqrtf(((2.0f * ux) + (-2.0f * (ux * maxCos))));
} else {
tmp = cosf((2.0f * (uy * ((float) M_PI)))) * sqrtf((1.0f + (-1.0f - (ux * (ux + -2.0f)))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.0001900000061141327)) tmp = Float32(cos(Float32(Float32(pi) * Float32(uy * Float32(2.0)))) * sqrt(Float32(Float32(Float32(2.0) * ux) + Float32(Float32(-2.0) * Float32(ux * maxCos))))); else tmp = Float32(cos(Float32(Float32(2.0) * Float32(uy * Float32(pi)))) * sqrt(Float32(Float32(1.0) + Float32(Float32(-1.0) - Float32(ux * Float32(ux + Float32(-2.0))))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.0001900000061141327)) tmp = cos((single(pi) * (uy * single(2.0)))) * sqrt(((single(2.0) * ux) + (single(-2.0) * (ux * maxCos)))); else tmp = cos((single(2.0) * (uy * single(pi)))) * sqrt((single(1.0) + (single(-1.0) - (ux * (ux + single(-2.0)))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.0001900000061141327:\\
\;\;\;\;\cos \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux + -2 \cdot \left(ux \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{1 + \left(-1 - ux \cdot \left(ux + -2\right)\right)}\\
\end{array}
\end{array}
if ux < 1.90000006e-4Initial program 36.3%
Taylor expanded in ux around 0 92.9%
Taylor expanded in maxCos around 0 92.9%
if 1.90000006e-4 < ux Initial program 88.8%
associate-*l*88.8%
sub-neg88.8%
+-commutative88.8%
distribute-rgt-neg-in88.8%
fma-define89.6%
Simplified89.8%
Taylor expanded in uy around inf 89.1%
Simplified89.1%
Taylor expanded in maxCos around 0 84.9%
Taylor expanded in ux around 0 86.8%
+-commutative86.8%
unpow286.8%
distribute-rgt-out86.8%
Simplified86.8%
Final simplification90.8%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.00031999999191612005)
(* (cos (* PI (* uy 2.0))) (sqrt (* ux (- 2.0 (* 2.0 maxCos)))))
(sqrt
(- 1.0 (* (+ 1.0 (* ux (+ maxCos -1.0))) (- (+ 1.0 (* ux maxCos)) ux))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00031999999191612005f) {
tmp = cosf((((float) M_PI) * (uy * 2.0f))) * sqrtf((ux * (2.0f - (2.0f * maxCos))));
} else {
tmp = sqrtf((1.0f - ((1.0f + (ux * (maxCos + -1.0f))) * ((1.0f + (ux * maxCos)) - ux))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.00031999999191612005)) tmp = Float32(cos(Float32(Float32(pi) * Float32(uy * Float32(2.0)))) * 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(Float32(1.0) + Float32(ux * maxCos)) - ux)))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.00031999999191612005)) tmp = cos((single(pi) * (uy * single(2.0)))) * 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 * maxCos)) - ux)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00031999999191612005:\\
\;\;\;\;\cos \left(\pi \cdot \left(uy \cdot 2\right)\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(\left(1 + ux \cdot maxCos\right) - ux\right)}\\
\end{array}
\end{array}
if ux < 3.19999992e-4Initial program 37.7%
Taylor expanded in ux around 0 92.1%
if 3.19999992e-4 < ux Initial program 89.7%
associate-*l*89.7%
sub-neg89.7%
+-commutative89.7%
distribute-rgt-neg-in89.7%
fma-define90.4%
Simplified90.7%
Taylor expanded in uy around inf 90.0%
Simplified90.0%
Taylor expanded in uy around 0 76.5%
Final simplification87.1%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.00031999999191612005)
(* (cos (* 2.0 (* uy PI))) (sqrt (* ux (- 2.0 maxCos))))
(sqrt
(- 1.0 (* (+ 1.0 (* ux (+ maxCos -1.0))) (- (+ 1.0 (* ux maxCos)) ux))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00031999999191612005f) {
tmp = cosf((2.0f * (uy * ((float) M_PI)))) * sqrtf((ux * (2.0f - maxCos)));
} else {
tmp = sqrtf((1.0f - ((1.0f + (ux * (maxCos + -1.0f))) * ((1.0f + (ux * maxCos)) - ux))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.00031999999191612005)) tmp = Float32(cos(Float32(Float32(2.0) * Float32(uy * Float32(pi)))) * sqrt(Float32(ux * 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(Float32(1.0) + Float32(ux * maxCos)) - ux)))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.00031999999191612005)) tmp = cos((single(2.0) * (uy * single(pi)))) * sqrt((ux * (single(2.0) - maxCos))); else tmp = sqrt((single(1.0) - ((single(1.0) + (ux * (maxCos + single(-1.0)))) * ((single(1.0) + (ux * maxCos)) - ux)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00031999999191612005:\\
\;\;\;\;\cos \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 - maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 + ux \cdot \left(maxCos + -1\right)\right) \cdot \left(\left(1 + ux \cdot maxCos\right) - ux\right)}\\
\end{array}
\end{array}
if ux < 3.19999992e-4Initial program 37.7%
associate-*l*37.7%
sub-neg37.7%
+-commutative37.7%
distribute-rgt-neg-in37.7%
fma-define37.9%
Simplified37.9%
Taylor expanded in uy around inf 37.7%
Simplified37.7%
Taylor expanded in maxCos around 0 37.2%
Taylor expanded in ux around 0 86.6%
if 3.19999992e-4 < ux Initial program 89.7%
associate-*l*89.7%
sub-neg89.7%
+-commutative89.7%
distribute-rgt-neg-in89.7%
fma-define90.4%
Simplified90.7%
Taylor expanded in uy around inf 90.0%
Simplified90.0%
Taylor expanded in uy around 0 76.5%
Final simplification83.3%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.00031999999191612005)
(* (cos (* PI (* uy 2.0))) (sqrt (* 2.0 ux)))
(sqrt
(- 1.0 (* (+ 1.0 (* ux (+ maxCos -1.0))) (- (+ 1.0 (* ux maxCos)) ux))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00031999999191612005f) {
tmp = cosf((((float) M_PI) * (uy * 2.0f))) * sqrtf((2.0f * ux));
} else {
tmp = sqrtf((1.0f - ((1.0f + (ux * (maxCos + -1.0f))) * ((1.0f + (ux * maxCos)) - ux))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.00031999999191612005)) tmp = Float32(cos(Float32(Float32(pi) * Float32(uy * Float32(2.0)))) * 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(Float32(1.0) + Float32(ux * maxCos)) - ux)))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.00031999999191612005)) tmp = cos((single(pi) * (uy * single(2.0)))) * sqrt((single(2.0) * ux)); else tmp = sqrt((single(1.0) - ((single(1.0) + (ux * (maxCos + single(-1.0)))) * ((single(1.0) + (ux * maxCos)) - ux)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00031999999191612005:\\
\;\;\;\;\cos \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 + ux \cdot \left(maxCos + -1\right)\right) \cdot \left(\left(1 + ux \cdot maxCos\right) - ux\right)}\\
\end{array}
\end{array}
if ux < 3.19999992e-4Initial program 37.7%
Taylor expanded in ux around 0 92.1%
Taylor expanded in maxCos around 0 86.0%
*-commutative71.3%
Simplified86.0%
if 3.19999992e-4 < ux Initial program 89.7%
associate-*l*89.7%
sub-neg89.7%
+-commutative89.7%
distribute-rgt-neg-in89.7%
fma-define90.4%
Simplified90.7%
Taylor expanded in uy around inf 90.0%
Simplified90.0%
Taylor expanded in uy around 0 76.5%
Final simplification83.0%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.00017499999376013875)
(sqrt (+ (* 2.0 ux) (* -2.0 (* ux maxCos))))
(sqrt
(- 1.0 (* (+ 1.0 (* ux (+ maxCos -1.0))) (- (+ 1.0 (* ux maxCos)) ux))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00017499999376013875f) {
tmp = sqrtf(((2.0f * ux) + (-2.0f * (ux * maxCos))));
} else {
tmp = sqrtf((1.0f - ((1.0f + (ux * (maxCos + -1.0f))) * ((1.0f + (ux * maxCos)) - ux))));
}
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.00017499999376013875e0) then
tmp = sqrt(((2.0e0 * ux) + ((-2.0e0) * (ux * maxcos))))
else
tmp = sqrt((1.0e0 - ((1.0e0 + (ux * (maxcos + (-1.0e0)))) * ((1.0e0 + (ux * maxcos)) - ux))))
end if
code = tmp
end function
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.00017499999376013875)) tmp = sqrt(Float32(Float32(Float32(2.0) * ux) + Float32(Float32(-2.0) * Float32(ux * maxCos)))); else tmp = sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(1.0) + Float32(ux * Float32(maxCos + Float32(-1.0)))) * Float32(Float32(Float32(1.0) + Float32(ux * maxCos)) - ux)))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.00017499999376013875)) tmp = sqrt(((single(2.0) * ux) + (single(-2.0) * (ux * maxCos)))); else tmp = sqrt((single(1.0) - ((single(1.0) + (ux * (maxCos + single(-1.0)))) * ((single(1.0) + (ux * maxCos)) - ux)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00017499999376013875:\\
\;\;\;\;\sqrt{2 \cdot ux + -2 \cdot \left(ux \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 + ux \cdot \left(maxCos + -1\right)\right) \cdot \left(\left(1 + ux \cdot maxCos\right) - ux\right)}\\
\end{array}
\end{array}
if ux < 1.74999994e-4Initial program 35.9%
associate-*l*35.9%
sub-neg35.9%
+-commutative35.9%
distribute-rgt-neg-in35.9%
fma-define36.0%
Simplified36.1%
Taylor expanded in uy around 0 32.7%
Simplified32.7%
Taylor expanded in ux around 0 76.9%
Taylor expanded in maxCos around 0 76.9%
if 1.74999994e-4 < ux Initial program 88.5%
associate-*l*88.5%
sub-neg88.5%
+-commutative88.5%
distribute-rgt-neg-in88.5%
fma-define89.2%
Simplified89.5%
Taylor expanded in uy around inf 88.8%
Simplified88.8%
Taylor expanded in uy around 0 74.9%
Final simplification76.2%
(FPCore (ux uy maxCos) :precision binary32 (if (<= ux 0.0001900000061141327) (sqrt (+ (* 2.0 ux) (* -2.0 (* ux maxCos)))) (sqrt (- 1.0 (* (+ 1.0 (* ux (+ maxCos -1.0))) (- 1.0 ux))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.0001900000061141327f) {
tmp = sqrtf(((2.0f * ux) + (-2.0f * (ux * maxCos))));
} else {
tmp = sqrtf((1.0f - ((1.0f + (ux * (maxCos + -1.0f))) * (1.0f - ux))));
}
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.0001900000061141327e0) then
tmp = sqrt(((2.0e0 * ux) + ((-2.0e0) * (ux * maxcos))))
else
tmp = sqrt((1.0e0 - ((1.0e0 + (ux * (maxcos + (-1.0e0)))) * (1.0e0 - ux))))
end if
code = tmp
end function
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.0001900000061141327)) tmp = sqrt(Float32(Float32(Float32(2.0) * ux) + Float32(Float32(-2.0) * Float32(ux * maxCos)))); else tmp = sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(1.0) + Float32(ux * Float32(maxCos + Float32(-1.0)))) * Float32(Float32(1.0) - ux)))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.0001900000061141327)) tmp = sqrt(((single(2.0) * ux) + (single(-2.0) * (ux * maxCos)))); else tmp = sqrt((single(1.0) - ((single(1.0) + (ux * (maxCos + single(-1.0)))) * (single(1.0) - ux)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.0001900000061141327:\\
\;\;\;\;\sqrt{2 \cdot ux + -2 \cdot \left(ux \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 + ux \cdot \left(maxCos + -1\right)\right) \cdot \left(1 - ux\right)}\\
\end{array}
\end{array}
if ux < 1.90000006e-4Initial program 36.3%
associate-*l*36.3%
sub-neg36.3%
+-commutative36.3%
distribute-rgt-neg-in36.3%
fma-define36.4%
Simplified36.5%
Taylor expanded in uy around 0 33.2%
Simplified33.2%
Taylor expanded in ux around 0 76.8%
Taylor expanded in maxCos around 0 76.8%
if 1.90000006e-4 < ux Initial program 88.8%
associate-*l*88.8%
sub-neg88.8%
+-commutative88.8%
distribute-rgt-neg-in88.8%
fma-define89.6%
Simplified89.8%
Taylor expanded in uy around inf 89.1%
Simplified89.1%
Taylor expanded in maxCos around 0 85.3%
Taylor expanded in uy around 0 72.1%
Final simplification75.2%
(FPCore (ux uy maxCos) :precision binary32 (if (<= ux 0.0001900000061141327) (sqrt (+ (* 2.0 ux) (* -2.0 (* ux maxCos)))) (sqrt (- 1.0 (* (- 1.0 ux) (- 1.0 ux))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.0001900000061141327f) {
tmp = sqrtf(((2.0f * ux) + (-2.0f * (ux * maxCos))));
} else {
tmp = sqrtf((1.0f - ((1.0f - ux) * (1.0f - ux))));
}
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.0001900000061141327e0) then
tmp = sqrt(((2.0e0 * ux) + ((-2.0e0) * (ux * maxcos))))
else
tmp = sqrt((1.0e0 - ((1.0e0 - ux) * (1.0e0 - ux))))
end if
code = tmp
end function
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.0001900000061141327)) tmp = sqrt(Float32(Float32(Float32(2.0) * ux) + Float32(Float32(-2.0) * Float32(ux * maxCos)))); else tmp = sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(1.0) - ux) * Float32(Float32(1.0) - ux)))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.0001900000061141327)) tmp = sqrt(((single(2.0) * ux) + (single(-2.0) * (ux * maxCos)))); else tmp = sqrt((single(1.0) - ((single(1.0) - ux) * (single(1.0) - ux)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.0001900000061141327:\\
\;\;\;\;\sqrt{2 \cdot ux + -2 \cdot \left(ux \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(1 - ux\right)}\\
\end{array}
\end{array}
if ux < 1.90000006e-4Initial program 36.3%
associate-*l*36.3%
sub-neg36.3%
+-commutative36.3%
distribute-rgt-neg-in36.3%
fma-define36.4%
Simplified36.5%
Taylor expanded in uy around 0 33.2%
Simplified33.2%
Taylor expanded in ux around 0 76.8%
Taylor expanded in maxCos around 0 76.8%
if 1.90000006e-4 < ux Initial program 88.8%
associate-*l*88.8%
sub-neg88.8%
+-commutative88.8%
distribute-rgt-neg-in88.8%
fma-define89.6%
Simplified89.8%
Taylor expanded in uy around 0 74.8%
Simplified74.8%
Taylor expanded in maxCos around 0 71.8%
Final simplification75.1%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (+ (* 2.0 ux) (* -2.0 (* ux maxCos)))))
float code(float ux, float uy, float maxCos) {
return sqrtf(((2.0f * ux) + (-2.0f * (ux * 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(((2.0e0 * ux) + ((-2.0e0) * (ux * maxcos))))
end function
function code(ux, uy, maxCos) return sqrt(Float32(Float32(Float32(2.0) * ux) + Float32(Float32(-2.0) * Float32(ux * maxCos)))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt(((single(2.0) * ux) + (single(-2.0) * (ux * maxCos)))); end
\begin{array}{l}
\\
\sqrt{2 \cdot ux + -2 \cdot \left(ux \cdot maxCos\right)}
\end{array}
Initial program 54.6%
associate-*l*54.6%
sub-neg54.6%
+-commutative54.6%
distribute-rgt-neg-in54.6%
fma-define54.9%
Simplified55.0%
Taylor expanded in uy around 0 47.7%
Simplified47.7%
Taylor expanded in ux around 0 66.7%
Taylor expanded in maxCos around 0 66.7%
Final simplification66.7%
(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.6%
associate-*l*54.6%
sub-neg54.6%
+-commutative54.6%
distribute-rgt-neg-in54.6%
fma-define54.9%
Simplified55.0%
Taylor expanded in uy around 0 47.7%
Simplified47.7%
Taylor expanded in ux around 0 66.7%
Final simplification66.7%
(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.6%
associate-*l*54.6%
sub-neg54.6%
+-commutative54.6%
distribute-rgt-neg-in54.6%
fma-define54.9%
Simplified55.0%
Taylor expanded in uy around 0 47.7%
Simplified47.7%
Taylor expanded in ux around 0 66.7%
Taylor expanded in maxCos around 0 63.3%
*-commutative63.3%
Simplified63.3%
Final simplification63.3%
herbie shell --seed 2024043
(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)))))))