
(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 11 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 (* (sin (cbrt (* (pow (* uy 2.0) 3.0) (pow PI 3.0)))) (sqrt (- (* (fma maxCos -2.0 2.0) ux) (* (pow (+ maxCos -1.0) 2.0) (* ux ux))))))
float code(float ux, float uy, float maxCos) {
return sinf(cbrtf((powf((uy * 2.0f), 3.0f) * powf(((float) M_PI), 3.0f)))) * sqrtf(((fmaf(maxCos, -2.0f, 2.0f) * ux) - (powf((maxCos + -1.0f), 2.0f) * (ux * ux))));
}
function code(ux, uy, maxCos) return Float32(sin(cbrt(Float32((Float32(uy * Float32(2.0)) ^ Float32(3.0)) * (Float32(pi) ^ Float32(3.0))))) * sqrt(Float32(Float32(fma(maxCos, Float32(-2.0), Float32(2.0)) * ux) - Float32((Float32(maxCos + Float32(-1.0)) ^ Float32(2.0)) * Float32(ux * ux))))) end
\begin{array}{l}
\\
\sin \left(\sqrt[3]{{\left(uy \cdot 2\right)}^{3} \cdot {\pi}^{3}}\right) \cdot \sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux - {\left(maxCos + -1\right)}^{2} \cdot \left(ux \cdot ux\right)}
\end{array}
Initial program 59.5%
associate-*l*59.5%
+-commutative59.5%
associate-+r-59.5%
fma-def59.5%
+-commutative59.5%
associate-+r-59.3%
fma-def59.3%
Simplified59.3%
Taylor expanded in ux around 0 98.4%
cancel-sign-sub-inv98.4%
metadata-eval98.4%
+-commutative98.4%
mul-1-neg98.4%
unsub-neg98.4%
*-commutative98.4%
fma-def98.4%
sub-neg98.4%
metadata-eval98.4%
unpow298.4%
Simplified98.4%
associate-*r*98.4%
add-cbrt-cube98.4%
add-cbrt-cube98.4%
cbrt-unprod98.4%
pow398.5%
pow398.5%
Applied egg-rr98.5%
Final simplification98.5%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sin (cbrt (* (pow (* uy 2.0) 3.0) (pow PI 3.0))))
(sqrt
(+
(* (+ maxCos -1.0) (* (- 1.0 maxCos) (pow ux 2.0)))
(* ux (- (- 1.0 (+ maxCos -1.0)) maxCos))))))
float code(float ux, float uy, float maxCos) {
return sinf(cbrtf((powf((uy * 2.0f), 3.0f) * powf(((float) M_PI), 3.0f)))) * sqrtf((((maxCos + -1.0f) * ((1.0f - maxCos) * powf(ux, 2.0f))) + (ux * ((1.0f - (maxCos + -1.0f)) - maxCos))));
}
function code(ux, uy, maxCos) return Float32(sin(cbrt(Float32((Float32(uy * Float32(2.0)) ^ Float32(3.0)) * (Float32(pi) ^ Float32(3.0))))) * sqrt(Float32(Float32(Float32(maxCos + Float32(-1.0)) * Float32(Float32(Float32(1.0) - maxCos) * (ux ^ Float32(2.0)))) + Float32(ux * Float32(Float32(Float32(1.0) - Float32(maxCos + Float32(-1.0))) - maxCos))))) end
\begin{array}{l}
\\
\sin \left(\sqrt[3]{{\left(uy \cdot 2\right)}^{3} \cdot {\pi}^{3}}\right) \cdot \sqrt{\left(maxCos + -1\right) \cdot \left(\left(1 - maxCos\right) \cdot {ux}^{2}\right) + ux \cdot \left(\left(1 - \left(maxCos + -1\right)\right) - maxCos\right)}
\end{array}
Initial program 59.5%
associate-*l*59.5%
sub-neg59.5%
+-commutative59.5%
distribute-rgt-neg-in59.5%
fma-def59.6%
+-commutative59.6%
associate-+r-59.7%
fma-def59.7%
neg-sub059.7%
+-commutative59.7%
associate-+r-59.4%
associate--r-59.4%
neg-sub059.4%
+-commutative59.4%
sub-neg59.4%
fma-def59.4%
Simplified59.4%
Taylor expanded in ux around 0 98.4%
associate-*r*98.4%
add-cbrt-cube98.4%
add-cbrt-cube98.4%
cbrt-unprod98.4%
pow398.5%
pow398.5%
Applied egg-rr98.5%
Final simplification98.5%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sin (* uy (* 2.0 PI)))
(sqrt
(fma
ux
(- 1.0 (+ maxCos (+ maxCos -1.0)))
(* (+ maxCos -1.0) (* (* ux ux) (- 1.0 maxCos)))))))
float code(float ux, float uy, float maxCos) {
return sinf((uy * (2.0f * ((float) M_PI)))) * sqrtf(fmaf(ux, (1.0f - (maxCos + (maxCos + -1.0f))), ((maxCos + -1.0f) * ((ux * ux) * (1.0f - maxCos)))));
}
function code(ux, uy, maxCos) return Float32(sin(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(fma(ux, Float32(Float32(1.0) - Float32(maxCos + Float32(maxCos + Float32(-1.0)))), Float32(Float32(maxCos + Float32(-1.0)) * Float32(Float32(ux * ux) * Float32(Float32(1.0) - maxCos)))))) end
\begin{array}{l}
\\
\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux, 1 - \left(maxCos + \left(maxCos + -1\right)\right), \left(maxCos + -1\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(1 - maxCos\right)\right)\right)}
\end{array}
Initial program 59.5%
associate-*l*59.5%
sub-neg59.5%
+-commutative59.5%
distribute-rgt-neg-in59.5%
fma-def59.6%
+-commutative59.6%
associate-+r-59.7%
fma-def59.7%
neg-sub059.7%
+-commutative59.7%
associate-+r-59.4%
associate--r-59.4%
neg-sub059.4%
+-commutative59.4%
sub-neg59.4%
fma-def59.4%
Simplified59.4%
Taylor expanded in ux around 0 98.4%
+-commutative98.4%
fma-def98.4%
associate--l+98.4%
mul-1-neg98.4%
sub-neg98.4%
metadata-eval98.4%
distribute-neg-in98.4%
metadata-eval98.4%
+-commutative98.4%
sub-neg98.4%
sub-neg98.4%
metadata-eval98.4%
*-commutative98.4%
unpow298.4%
Simplified98.4%
Final simplification98.4%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* ux (- 1.0 ux))))
(*
(sin (* uy (* 2.0 PI)))
(sqrt (- (* ux (- 2.0 ux)) (* maxCos (+ t_0 t_0)))))))
float code(float ux, float uy, float maxCos) {
float t_0 = ux * (1.0f - ux);
return sinf((uy * (2.0f * ((float) M_PI)))) * sqrtf(((ux * (2.0f - ux)) - (maxCos * (t_0 + t_0))));
}
function code(ux, uy, maxCos) t_0 = Float32(ux * Float32(Float32(1.0) - ux)) return Float32(sin(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(Float32(Float32(ux * Float32(Float32(2.0) - ux)) - Float32(maxCos * Float32(t_0 + t_0))))) end
function tmp = code(ux, uy, maxCos) t_0 = ux * (single(1.0) - ux); tmp = sin((uy * (single(2.0) * single(pi)))) * sqrt(((ux * (single(2.0) - ux)) - (maxCos * (t_0 + t_0)))); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := ux \cdot \left(1 - ux\right)\\
\sin \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 - ux\right) - maxCos \cdot \left(t_0 + t_0\right)}
\end{array}
\end{array}
Initial program 59.5%
associate-*l*59.5%
sub-neg59.5%
+-commutative59.5%
distribute-rgt-neg-in59.5%
fma-def59.6%
+-commutative59.6%
associate-+r-59.7%
fma-def59.7%
neg-sub059.7%
+-commutative59.7%
associate-+r-59.4%
associate--r-59.4%
neg-sub059.4%
+-commutative59.4%
sub-neg59.4%
fma-def59.4%
Simplified59.4%
Taylor expanded in maxCos around 0 57.7%
Taylor expanded in ux around 0 97.8%
neg-mul-197.8%
+-commutative97.8%
sub-neg97.8%
unpow297.8%
distribute-rgt-out--97.8%
Simplified97.8%
Final simplification97.8%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* 2.0 (* uy PI))) (sqrt (* ux (- 2.0 ux)))))
float code(float ux, float uy, float maxCos) {
return sinf((2.0f * (uy * ((float) M_PI)))) * sqrtf((ux * (2.0f - ux)));
}
function code(ux, uy, maxCos) return Float32(sin(Float32(Float32(2.0) * Float32(uy * Float32(pi)))) * sqrt(Float32(ux * Float32(Float32(2.0) - ux)))) end
function tmp = code(ux, uy, maxCos) tmp = sin((single(2.0) * (uy * single(pi)))) * sqrt((ux * (single(2.0) - ux))); end
\begin{array}{l}
\\
\sin \left(2 \cdot \left(uy \cdot \pi\right)\right) \cdot \sqrt{ux \cdot \left(2 - ux\right)}
\end{array}
Initial program 59.5%
associate-*l*59.5%
+-commutative59.5%
associate-+r-59.5%
fma-def59.5%
+-commutative59.5%
associate-+r-59.3%
fma-def59.3%
Simplified59.3%
Taylor expanded in ux around 0 98.4%
cancel-sign-sub-inv98.4%
metadata-eval98.4%
+-commutative98.4%
mul-1-neg98.4%
unsub-neg98.4%
*-commutative98.4%
fma-def98.4%
sub-neg98.4%
metadata-eval98.4%
unpow298.4%
Simplified98.4%
Taylor expanded in maxCos around 0 93.5%
*-commutative93.5%
unpow293.5%
distribute-rgt-out--93.5%
Simplified93.5%
Final simplification93.5%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.00019999999494757503)
(* 2.0 (* (* uy PI) (sqrt (+ (* -2.0 (* maxCos ux)) (* 2.0 ux)))))
(*
2.0
(*
(* uy PI)
(sqrt
(+
1.0
(* (+ ux (- -1.0 (* maxCos ux))) (+ 1.0 (- (* maxCos ux) ux)))))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00019999999494757503f) {
tmp = 2.0f * ((uy * ((float) M_PI)) * sqrtf(((-2.0f * (maxCos * ux)) + (2.0f * ux))));
} else {
tmp = 2.0f * ((uy * ((float) M_PI)) * sqrtf((1.0f + ((ux + (-1.0f - (maxCos * ux))) * (1.0f + ((maxCos * ux) - ux))))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.00019999999494757503)) tmp = Float32(Float32(2.0) * Float32(Float32(uy * Float32(pi)) * sqrt(Float32(Float32(Float32(-2.0) * Float32(maxCos * ux)) + Float32(Float32(2.0) * ux))))); else tmp = Float32(Float32(2.0) * Float32(Float32(uy * Float32(pi)) * sqrt(Float32(Float32(1.0) + Float32(Float32(ux + Float32(Float32(-1.0) - Float32(maxCos * ux))) * Float32(Float32(1.0) + Float32(Float32(maxCos * ux) - ux))))))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (ux <= single(0.00019999999494757503)) tmp = single(2.0) * ((uy * single(pi)) * sqrt(((single(-2.0) * (maxCos * ux)) + (single(2.0) * ux)))); else tmp = single(2.0) * ((uy * single(pi)) * sqrt((single(1.0) + ((ux + (single(-1.0) - (maxCos * ux))) * (single(1.0) + ((maxCos * ux) - ux)))))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00019999999494757503:\\
\;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{-2 \cdot \left(maxCos \cdot ux\right) + 2 \cdot ux}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 + \left(ux + \left(-1 - maxCos \cdot ux\right)\right) \cdot \left(1 + \left(maxCos \cdot ux - ux\right)\right)}\right)\\
\end{array}
\end{array}
if ux < 1.99999995e-4Initial program 38.8%
associate-*l*38.8%
+-commutative38.8%
associate-+r-38.8%
fma-def38.8%
+-commutative38.8%
associate-+r-38.7%
fma-def38.7%
Simplified38.7%
Taylor expanded in ux around 0 92.0%
Taylor expanded in uy around 0 82.7%
Taylor expanded in maxCos around 0 82.7%
if 1.99999995e-4 < ux Initial program 90.3%
associate-*l*90.3%
sub-neg90.3%
+-commutative90.3%
distribute-rgt-neg-in90.3%
fma-def90.4%
+-commutative90.4%
associate-+r-90.5%
fma-def90.5%
neg-sub090.5%
+-commutative90.5%
associate-+r-90.1%
associate--r-90.1%
neg-sub090.1%
+-commutative90.1%
sub-neg90.1%
fma-def90.1%
Simplified90.1%
Taylor expanded in uy around 0 74.1%
*-un-lft-identity74.1%
associate--l+74.2%
Applied egg-rr74.2%
*-lft-identity74.2%
Simplified74.2%
Final simplification79.3%
(FPCore (ux uy maxCos) :precision binary32 (if (<= ux 0.00019999999494757503) (* 2.0 (* (* uy PI) (sqrt (* ux (- 2.0 (* 2.0 maxCos)))))) (* 2.0 (* (* uy PI) (sqrt (- 1.0 (* (- 1.0 ux) (- 1.0 ux))))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00019999999494757503f) {
tmp = 2.0f * ((uy * ((float) M_PI)) * sqrtf((ux * (2.0f - (2.0f * maxCos)))));
} else {
tmp = 2.0f * ((uy * ((float) M_PI)) * sqrtf((1.0f - ((1.0f - ux) * (1.0f - ux)))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.00019999999494757503)) tmp = Float32(Float32(2.0) * Float32(Float32(uy * Float32(pi)) * sqrt(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos)))))); else tmp = Float32(Float32(2.0) * Float32(Float32(uy * Float32(pi)) * 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.00019999999494757503)) tmp = single(2.0) * ((uy * single(pi)) * sqrt((ux * (single(2.0) - (single(2.0) * maxCos))))); else tmp = single(2.0) * ((uy * single(pi)) * 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.00019999999494757503:\\
\;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 - \left(1 - ux\right) \cdot \left(1 - ux\right)}\right)\\
\end{array}
\end{array}
if ux < 1.99999995e-4Initial program 38.8%
associate-*l*38.8%
+-commutative38.8%
associate-+r-38.8%
fma-def38.8%
+-commutative38.8%
associate-+r-38.7%
fma-def38.7%
Simplified38.7%
Taylor expanded in ux around 0 92.0%
Taylor expanded in uy around 0 82.7%
if 1.99999995e-4 < ux Initial program 90.3%
associate-*l*90.3%
sub-neg90.3%
+-commutative90.3%
distribute-rgt-neg-in90.3%
fma-def90.4%
+-commutative90.4%
associate-+r-90.5%
fma-def90.5%
neg-sub090.5%
+-commutative90.5%
associate-+r-90.1%
associate--r-90.1%
neg-sub090.1%
+-commutative90.1%
sub-neg90.1%
fma-def90.1%
Simplified90.1%
Taylor expanded in uy around 0 74.1%
Taylor expanded in maxCos around 0 71.1%
Final simplification78.0%
(FPCore (ux uy maxCos) :precision binary32 (if (<= ux 0.00019999999494757503) (* 2.0 (* (* uy PI) (sqrt (+ (* -2.0 (* maxCos ux)) (* 2.0 ux))))) (* 2.0 (* (* uy PI) (sqrt (- 1.0 (* (- 1.0 ux) (- 1.0 ux))))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (ux <= 0.00019999999494757503f) {
tmp = 2.0f * ((uy * ((float) M_PI)) * sqrtf(((-2.0f * (maxCos * ux)) + (2.0f * ux))));
} else {
tmp = 2.0f * ((uy * ((float) M_PI)) * sqrtf((1.0f - ((1.0f - ux) * (1.0f - ux)))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (ux <= Float32(0.00019999999494757503)) tmp = Float32(Float32(2.0) * Float32(Float32(uy * Float32(pi)) * sqrt(Float32(Float32(Float32(-2.0) * Float32(maxCos * ux)) + Float32(Float32(2.0) * ux))))); else tmp = Float32(Float32(2.0) * Float32(Float32(uy * Float32(pi)) * 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.00019999999494757503)) tmp = single(2.0) * ((uy * single(pi)) * sqrt(((single(-2.0) * (maxCos * ux)) + (single(2.0) * ux)))); else tmp = single(2.0) * ((uy * single(pi)) * 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.00019999999494757503:\\
\;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{-2 \cdot \left(maxCos \cdot ux\right) + 2 \cdot ux}\right)\\
\mathbf{else}:\\
\;\;\;\;2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{1 - \left(1 - ux\right) \cdot \left(1 - ux\right)}\right)\\
\end{array}
\end{array}
if ux < 1.99999995e-4Initial program 38.8%
associate-*l*38.8%
+-commutative38.8%
associate-+r-38.8%
fma-def38.8%
+-commutative38.8%
associate-+r-38.7%
fma-def38.7%
Simplified38.7%
Taylor expanded in ux around 0 92.0%
Taylor expanded in uy around 0 82.7%
Taylor expanded in maxCos around 0 82.7%
if 1.99999995e-4 < ux Initial program 90.3%
associate-*l*90.3%
sub-neg90.3%
+-commutative90.3%
distribute-rgt-neg-in90.3%
fma-def90.4%
+-commutative90.4%
associate-+r-90.5%
fma-def90.5%
neg-sub090.5%
+-commutative90.5%
associate-+r-90.1%
associate--r-90.1%
neg-sub090.1%
+-commutative90.1%
sub-neg90.1%
fma-def90.1%
Simplified90.1%
Taylor expanded in uy around 0 74.1%
Taylor expanded in maxCos around 0 71.1%
Final simplification78.0%
(FPCore (ux uy maxCos) :precision binary32 (* 2.0 (* (* uy PI) (sqrt (* ux (- 2.0 (* 2.0 maxCos)))))))
float code(float ux, float uy, float maxCos) {
return 2.0f * ((uy * ((float) M_PI)) * sqrtf((ux * (2.0f - (2.0f * maxCos)))));
}
function code(ux, uy, maxCos) return Float32(Float32(2.0) * Float32(Float32(uy * Float32(pi)) * sqrt(Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos)))))) end
function tmp = code(ux, uy, maxCos) tmp = single(2.0) * ((uy * single(pi)) * sqrt((ux * (single(2.0) - (single(2.0) * maxCos))))); end
\begin{array}{l}
\\
2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\right)
\end{array}
Initial program 59.5%
associate-*l*59.5%
+-commutative59.5%
associate-+r-59.5%
fma-def59.5%
+-commutative59.5%
associate-+r-59.3%
fma-def59.3%
Simplified59.3%
Taylor expanded in ux around 0 75.3%
Taylor expanded in uy around 0 68.0%
Final simplification68.0%
(FPCore (ux uy maxCos) :precision binary32 (* 2.0 (* (* uy PI) (sqrt (* 2.0 ux)))))
float code(float ux, float uy, float maxCos) {
return 2.0f * ((uy * ((float) M_PI)) * sqrtf((2.0f * ux)));
}
function code(ux, uy, maxCos) return Float32(Float32(2.0) * Float32(Float32(uy * Float32(pi)) * sqrt(Float32(Float32(2.0) * ux)))) end
function tmp = code(ux, uy, maxCos) tmp = single(2.0) * ((uy * single(pi)) * sqrt((single(2.0) * ux))); end
\begin{array}{l}
\\
2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{2 \cdot ux}\right)
\end{array}
Initial program 59.5%
associate-*l*59.5%
+-commutative59.5%
associate-+r-59.5%
fma-def59.5%
+-commutative59.5%
associate-+r-59.3%
fma-def59.3%
Simplified59.3%
Taylor expanded in ux around 0 75.3%
Taylor expanded in uy around 0 68.0%
Taylor expanded in maxCos around 0 66.1%
Final simplification66.1%
(FPCore (ux uy maxCos) :precision binary32 (* 2.0 (* (* uy PI) (sqrt 0.0))))
float code(float ux, float uy, float maxCos) {
return 2.0f * ((uy * ((float) M_PI)) * sqrtf(0.0f));
}
function code(ux, uy, maxCos) return Float32(Float32(2.0) * Float32(Float32(uy * Float32(pi)) * sqrt(Float32(0.0)))) end
function tmp = code(ux, uy, maxCos) tmp = single(2.0) * ((uy * single(pi)) * sqrt(single(0.0))); end
\begin{array}{l}
\\
2 \cdot \left(\left(uy \cdot \pi\right) \cdot \sqrt{0}\right)
\end{array}
Initial program 59.5%
associate-*l*59.5%
sub-neg59.5%
+-commutative59.5%
distribute-rgt-neg-in59.5%
fma-def59.6%
+-commutative59.6%
associate-+r-59.7%
fma-def59.7%
neg-sub059.7%
+-commutative59.7%
associate-+r-59.4%
associate--r-59.4%
neg-sub059.4%
+-commutative59.4%
sub-neg59.4%
fma-def59.4%
Simplified59.4%
Taylor expanded in uy around 0 52.3%
Taylor expanded in ux around 0 7.2%
Final simplification7.2%
herbie shell --seed 2023224
(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)))))))