
(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 10 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 (+ (+ 1.0 (* uy (* 2.0 PI))) -1.0))
(sqrt
(fma
(+ -1.0 maxCos)
(* (* ux ux) (- 1.0 maxCos))
(+ ux (* ux (- (- 1.0 maxCos) maxCos)))))))
float code(float ux, float uy, float maxCos) {
return cosf(((1.0f + (uy * (2.0f * ((float) M_PI)))) + -1.0f)) * sqrtf(fmaf((-1.0f + maxCos), ((ux * ux) * (1.0f - maxCos)), (ux + (ux * ((1.0f - maxCos) - maxCos)))));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(Float32(Float32(1.0) + Float32(uy * Float32(Float32(2.0) * Float32(pi)))) + Float32(-1.0))) * sqrt(fma(Float32(Float32(-1.0) + maxCos), Float32(Float32(ux * ux) * Float32(Float32(1.0) - maxCos)), Float32(ux + Float32(ux * Float32(Float32(Float32(1.0) - maxCos) - maxCos)))))) end
\begin{array}{l}
\\
\cos \left(\left(1 + uy \cdot \left(2 \cdot \pi\right)\right) + -1\right) \cdot \sqrt{\mathsf{fma}\left(-1 + maxCos, \left(ux \cdot ux\right) \cdot \left(1 - maxCos\right), ux + ux \cdot \left(\left(1 - maxCos\right) - maxCos\right)\right)}
\end{array}
Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.5%
+-commutative54.5%
associate-+r-54.3%
fma-def54.3%
neg-sub054.3%
+-commutative54.3%
associate-+r-54.2%
associate--r-54.2%
neg-sub054.2%
+-commutative54.2%
sub-neg54.2%
fma-def54.2%
Simplified54.2%
Taylor expanded in ux around 0 98.9%
fma-def98.9%
sub-neg98.9%
metadata-eval98.9%
*-commutative98.9%
unpow298.9%
associate--l+98.9%
distribute-rgt-in98.9%
*-lft-identity98.9%
mul-1-neg98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-neg-in98.9%
metadata-eval98.9%
+-commutative98.9%
sub-neg98.9%
Simplified98.9%
expm1-log1p-u98.8%
expm1-udef98.8%
Applied egg-rr98.8%
sub-neg98.8%
log1p-udef98.8%
add-exp-log98.9%
metadata-eval98.9%
Applied egg-rr98.9%
Final simplification98.9%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sqrt
(fma
(+ -1.0 maxCos)
(* (* ux ux) (- 1.0 maxCos))
(+ ux (* ux (- (- 1.0 maxCos) maxCos)))))
(cos (* uy (* 2.0 PI)))))
float code(float ux, float uy, float maxCos) {
return sqrtf(fmaf((-1.0f + maxCos), ((ux * ux) * (1.0f - maxCos)), (ux + (ux * ((1.0f - maxCos) - maxCos))))) * cosf((uy * (2.0f * ((float) M_PI))));
}
function code(ux, uy, maxCos) return Float32(sqrt(fma(Float32(Float32(-1.0) + maxCos), Float32(Float32(ux * ux) * Float32(Float32(1.0) - maxCos)), Float32(ux + Float32(ux * Float32(Float32(Float32(1.0) - maxCos) - maxCos))))) * cos(Float32(uy * Float32(Float32(2.0) * Float32(pi))))) end
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(-1 + maxCos, \left(ux \cdot ux\right) \cdot \left(1 - maxCos\right), ux + ux \cdot \left(\left(1 - maxCos\right) - maxCos\right)\right)} \cdot \cos \left(uy \cdot \left(2 \cdot \pi\right)\right)
\end{array}
Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.5%
+-commutative54.5%
associate-+r-54.3%
fma-def54.3%
neg-sub054.3%
+-commutative54.3%
associate-+r-54.2%
associate--r-54.2%
neg-sub054.2%
+-commutative54.2%
sub-neg54.2%
fma-def54.2%
Simplified54.2%
Taylor expanded in ux around 0 98.9%
fma-def98.9%
sub-neg98.9%
metadata-eval98.9%
*-commutative98.9%
unpow298.9%
associate--l+98.9%
distribute-rgt-in98.9%
*-lft-identity98.9%
mul-1-neg98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-neg-in98.9%
metadata-eval98.9%
+-commutative98.9%
sub-neg98.9%
Simplified98.9%
Final simplification98.9%
(FPCore (ux uy maxCos)
:precision binary32
(*
(cos (* uy (* 2.0 PI)))
(sqrt
(+
(* (+ -1.0 (* 2.0 maxCos)) (pow ux 2.0))
(* ux (+ 2.0 (* maxCos -2.0)))))))
float code(float ux, float uy, float maxCos) {
return cosf((uy * (2.0f * ((float) M_PI)))) * sqrtf((((-1.0f + (2.0f * maxCos)) * powf(ux, 2.0f)) + (ux * (2.0f + (maxCos * -2.0f)))));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * sqrt(Float32(Float32(Float32(Float32(-1.0) + Float32(Float32(2.0) * maxCos)) * (ux ^ Float32(2.0))) + Float32(ux * Float32(Float32(2.0) + Float32(maxCos * Float32(-2.0))))))) end
function tmp = code(ux, uy, maxCos) tmp = cos((uy * (single(2.0) * single(pi)))) * sqrt((((single(-1.0) + (single(2.0) * maxCos)) * (ux ^ single(2.0))) + (ux * (single(2.0) + (maxCos * single(-2.0)))))); end
\begin{array}{l}
\\
\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{\left(-1 + 2 \cdot maxCos\right) \cdot {ux}^{2} + ux \cdot \left(2 + maxCos \cdot -2\right)}
\end{array}
Initial program 54.5%
associate-*l*54.5%
+-commutative54.5%
associate-+r-54.5%
fma-def54.5%
+-commutative54.5%
associate-+r-54.3%
fma-def54.3%
Simplified54.3%
Taylor expanded in maxCos around 0 54.1%
Taylor expanded in ux around 0 98.1%
Final simplification98.1%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* uy 2.0) 0.00019999999494757503)
(sqrt
(+
(* (+ -1.0 maxCos) (* (* ux ux) (- 1.0 maxCos)))
(* ux (- 2.0 (* 2.0 maxCos)))))
(* (cos (* PI (* uy 2.0))) (sqrt (- (* 2.0 ux) (* ux ux))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if ((uy * 2.0f) <= 0.00019999999494757503f) {
tmp = sqrtf((((-1.0f + maxCos) * ((ux * ux) * (1.0f - maxCos))) + (ux * (2.0f - (2.0f * maxCos)))));
} else {
tmp = cosf((((float) M_PI) * (uy * 2.0f))) * sqrtf(((2.0f * ux) - (ux * ux)));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (Float32(uy * Float32(2.0)) <= Float32(0.00019999999494757503)) tmp = sqrt(Float32(Float32(Float32(Float32(-1.0) + maxCos) * Float32(Float32(ux * ux) * Float32(Float32(1.0) - maxCos))) + Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))))); else tmp = Float32(cos(Float32(Float32(pi) * Float32(uy * Float32(2.0)))) * sqrt(Float32(Float32(Float32(2.0) * ux) - Float32(ux * ux)))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if ((uy * single(2.0)) <= single(0.00019999999494757503)) tmp = sqrt((((single(-1.0) + maxCos) * ((ux * ux) * (single(1.0) - maxCos))) + (ux * (single(2.0) - (single(2.0) * maxCos))))); else tmp = cos((single(pi) * (uy * single(2.0)))) * sqrt(((single(2.0) * ux) - (ux * ux))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \cdot 2 \leq 0.00019999999494757503:\\
\;\;\;\;\sqrt{\left(-1 + maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(1 - maxCos\right)\right) + ux \cdot \left(2 - 2 \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\pi \cdot \left(uy \cdot 2\right)\right) \cdot \sqrt{2 \cdot ux - ux \cdot ux}\\
\end{array}
\end{array}
if (*.f32 uy 2) < 1.99999995e-4Initial program 53.4%
associate-*l*53.4%
sub-neg53.4%
+-commutative53.4%
distribute-rgt-neg-in53.4%
fma-def53.2%
+-commutative53.2%
associate-+r-53.2%
fma-def53.2%
neg-sub053.2%
+-commutative53.2%
associate-+r-53.0%
associate--r-53.0%
neg-sub053.0%
+-commutative53.0%
sub-neg53.0%
fma-def53.0%
Simplified53.0%
Taylor expanded in ux around 0 99.5%
fma-def99.5%
sub-neg99.5%
metadata-eval99.5%
*-commutative99.5%
unpow299.5%
associate--l+99.6%
distribute-rgt-in99.6%
*-lft-identity99.6%
mul-1-neg99.6%
sub-neg99.6%
metadata-eval99.6%
distribute-neg-in99.6%
metadata-eval99.6%
+-commutative99.6%
sub-neg99.6%
Simplified99.6%
Taylor expanded in uy around 0 99.4%
Taylor expanded in ux around 0 99.5%
+-commutative99.5%
sub-neg99.5%
metadata-eval99.5%
unpow299.5%
fma-def99.5%
*-commutative99.5%
Simplified99.5%
fma-udef99.5%
*-commutative99.5%
Applied egg-rr99.5%
if 1.99999995e-4 < (*.f32 uy 2) Initial program 56.2%
associate-*l*56.2%
sub-neg56.2%
+-commutative56.2%
distribute-rgt-neg-in56.2%
fma-def56.3%
+-commutative56.3%
associate-+r-56.1%
fma-def56.1%
neg-sub056.1%
+-commutative56.1%
associate-+r-56.0%
associate--r-56.0%
neg-sub056.0%
+-commutative56.0%
sub-neg56.0%
fma-def56.0%
Simplified56.0%
Taylor expanded in ux around 0 98.0%
fma-def98.0%
sub-neg98.0%
metadata-eval98.0%
*-commutative98.0%
unpow298.0%
associate--l+98.0%
distribute-rgt-in97.9%
*-lft-identity97.9%
mul-1-neg97.9%
sub-neg97.9%
metadata-eval97.9%
distribute-neg-in97.9%
metadata-eval97.9%
+-commutative97.9%
sub-neg97.9%
Simplified97.9%
Taylor expanded in maxCos around 0 92.4%
associate-*r*92.4%
+-commutative92.4%
neg-mul-192.4%
unsub-neg92.4%
*-commutative92.4%
unpow292.4%
Simplified92.4%
Final simplification96.6%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* ux (- 2.0 (* 2.0 maxCos)))))
(if (<= uy 0.0006000000284984708)
(sqrt (+ (* (+ -1.0 maxCos) (* (* ux ux) (- 1.0 maxCos))) t_0))
(* (cos (* uy (* 2.0 PI))) (sqrt t_0)))))
float code(float ux, float uy, float maxCos) {
float t_0 = ux * (2.0f - (2.0f * maxCos));
float tmp;
if (uy <= 0.0006000000284984708f) {
tmp = sqrtf((((-1.0f + maxCos) * ((ux * ux) * (1.0f - maxCos))) + t_0));
} else {
tmp = cosf((uy * (2.0f * ((float) M_PI)))) * 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 (uy <= Float32(0.0006000000284984708)) tmp = sqrt(Float32(Float32(Float32(Float32(-1.0) + maxCos) * Float32(Float32(ux * ux) * Float32(Float32(1.0) - maxCos))) + t_0)); else tmp = Float32(cos(Float32(uy * Float32(Float32(2.0) * Float32(pi)))) * 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 (uy <= single(0.0006000000284984708)) tmp = sqrt((((single(-1.0) + maxCos) * ((ux * ux) * (single(1.0) - maxCos))) + t_0)); else tmp = cos((uy * (single(2.0) * single(pi)))) * 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}\;uy \leq 0.0006000000284984708:\\
\;\;\;\;\sqrt{\left(-1 + maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(1 - maxCos\right)\right) + t_0}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(uy \cdot \left(2 \cdot \pi\right)\right) \cdot \sqrt{t_0}\\
\end{array}
\end{array}
if uy < 6.00000028e-4Initial program 54.3%
associate-*l*54.3%
sub-neg54.3%
+-commutative54.3%
distribute-rgt-neg-in54.3%
fma-def54.2%
+-commutative54.2%
associate-+r-54.1%
fma-def54.1%
neg-sub054.1%
+-commutative54.1%
associate-+r-54.0%
associate--r-54.0%
neg-sub054.0%
+-commutative54.0%
sub-neg54.0%
fma-def54.0%
Simplified54.0%
Taylor expanded in ux around 0 99.4%
fma-def99.4%
sub-neg99.4%
metadata-eval99.4%
*-commutative99.4%
unpow299.4%
associate--l+99.5%
distribute-rgt-in99.5%
*-lft-identity99.5%
mul-1-neg99.5%
sub-neg99.5%
metadata-eval99.5%
distribute-neg-in99.5%
metadata-eval99.5%
+-commutative99.5%
sub-neg99.5%
Simplified99.5%
Taylor expanded in uy around 0 98.0%
Taylor expanded in ux around 0 98.1%
+-commutative98.1%
sub-neg98.1%
metadata-eval98.1%
unpow298.1%
fma-def98.1%
*-commutative98.1%
Simplified98.1%
fma-udef98.1%
*-commutative98.1%
Applied egg-rr98.1%
if 6.00000028e-4 < uy Initial program 55.1%
associate-*l*55.1%
+-commutative55.1%
associate-+r-55.0%
fma-def55.0%
+-commutative55.0%
associate-+r-54.8%
fma-def54.8%
Simplified54.8%
Taylor expanded in ux around 0 76.6%
Final simplification91.3%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (+ (* (+ -1.0 maxCos) (* (* ux ux) (- 1.0 maxCos))) (* ux (- 2.0 (* 2.0 maxCos))))))
float code(float ux, float uy, float maxCos) {
return sqrtf((((-1.0f + maxCos) * ((ux * ux) * (1.0f - maxCos))) + (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(((((-1.0e0) + maxcos) * ((ux * ux) * (1.0e0 - maxcos))) + (ux * (2.0e0 - (2.0e0 * maxcos)))))
end function
function code(ux, uy, maxCos) return sqrt(Float32(Float32(Float32(Float32(-1.0) + maxCos) * Float32(Float32(ux * ux) * Float32(Float32(1.0) - maxCos))) + Float32(ux * Float32(Float32(2.0) - Float32(Float32(2.0) * maxCos))))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt((((single(-1.0) + maxCos) * ((ux * ux) * (single(1.0) - maxCos))) + (ux * (single(2.0) - (single(2.0) * maxCos))))); end
\begin{array}{l}
\\
\sqrt{\left(-1 + maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot \left(1 - maxCos\right)\right) + ux \cdot \left(2 - 2 \cdot maxCos\right)}
\end{array}
Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.5%
+-commutative54.5%
associate-+r-54.3%
fma-def54.3%
neg-sub054.3%
+-commutative54.3%
associate-+r-54.2%
associate--r-54.2%
neg-sub054.2%
+-commutative54.2%
sub-neg54.2%
fma-def54.2%
Simplified54.2%
Taylor expanded in ux around 0 98.9%
fma-def98.9%
sub-neg98.9%
metadata-eval98.9%
*-commutative98.9%
unpow298.9%
associate--l+98.9%
distribute-rgt-in98.9%
*-lft-identity98.9%
mul-1-neg98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-neg-in98.9%
metadata-eval98.9%
+-commutative98.9%
sub-neg98.9%
Simplified98.9%
Taylor expanded in uy around 0 80.2%
Taylor expanded in ux around 0 80.2%
+-commutative80.2%
sub-neg80.2%
metadata-eval80.2%
unpow280.2%
fma-def80.2%
*-commutative80.2%
Simplified80.2%
fma-udef80.2%
*-commutative80.2%
Applied egg-rr80.2%
Final simplification80.2%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (+ (* ux (- 1.0 (* 2.0 maxCos))) (- ux (* (* ux ux) (- 1.0 maxCos))))))
float code(float ux, float uy, float maxCos) {
return sqrtf(((ux * (1.0f - (2.0f * maxCos))) + (ux - ((ux * ux) * (1.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 * (1.0e0 - (2.0e0 * maxcos))) + (ux - ((ux * ux) * (1.0e0 - maxcos)))))
end function
function code(ux, uy, maxCos) return sqrt(Float32(Float32(ux * Float32(Float32(1.0) - Float32(Float32(2.0) * maxCos))) + Float32(ux - Float32(Float32(ux * ux) * Float32(Float32(1.0) - maxCos))))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt(((ux * (single(1.0) - (single(2.0) * maxCos))) + (ux - ((ux * ux) * (single(1.0) - maxCos))))); end
\begin{array}{l}
\\
\sqrt{ux \cdot \left(1 - 2 \cdot maxCos\right) + \left(ux - \left(ux \cdot ux\right) \cdot \left(1 - maxCos\right)\right)}
\end{array}
Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.5%
+-commutative54.5%
associate-+r-54.3%
fma-def54.3%
neg-sub054.3%
+-commutative54.3%
associate-+r-54.2%
associate--r-54.2%
neg-sub054.2%
+-commutative54.2%
sub-neg54.2%
fma-def54.2%
Simplified54.2%
Taylor expanded in ux around 0 98.9%
fma-def98.9%
sub-neg98.9%
metadata-eval98.9%
*-commutative98.9%
unpow298.9%
associate--l+98.9%
distribute-rgt-in98.9%
*-lft-identity98.9%
mul-1-neg98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-neg-in98.9%
metadata-eval98.9%
+-commutative98.9%
sub-neg98.9%
Simplified98.9%
Taylor expanded in uy around 0 80.2%
Taylor expanded in maxCos around 0 79.0%
mul-1-neg79.0%
unpow279.0%
distribute-rgt-neg-in79.0%
Simplified79.0%
Final simplification79.0%
(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.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.5%
+-commutative54.5%
associate-+r-54.3%
fma-def54.3%
neg-sub054.3%
+-commutative54.3%
associate-+r-54.2%
associate--r-54.2%
neg-sub054.2%
+-commutative54.2%
sub-neg54.2%
fma-def54.2%
Simplified54.2%
Taylor expanded in ux around 0 98.9%
fma-def98.9%
sub-neg98.9%
metadata-eval98.9%
*-commutative98.9%
unpow298.9%
associate--l+98.9%
distribute-rgt-in98.9%
*-lft-identity98.9%
mul-1-neg98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-neg-in98.9%
metadata-eval98.9%
+-commutative98.9%
sub-neg98.9%
Simplified98.9%
Taylor expanded in uy around 0 80.2%
Taylor expanded in ux around 0 65.7%
Final simplification65.7%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (- (* 2.0 ux) (* ux ux))))
float code(float ux, float uy, float maxCos) {
return sqrtf(((2.0f * ux) - (ux * 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) - (ux * ux)))
end function
function code(ux, uy, maxCos) return sqrt(Float32(Float32(Float32(2.0) * ux) - Float32(ux * ux))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt(((single(2.0) * ux) - (ux * ux))); end
\begin{array}{l}
\\
\sqrt{2 \cdot ux - ux \cdot ux}
\end{array}
Initial program 54.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.5%
+-commutative54.5%
associate-+r-54.3%
fma-def54.3%
neg-sub054.3%
+-commutative54.3%
associate-+r-54.2%
associate--r-54.2%
neg-sub054.2%
+-commutative54.2%
sub-neg54.2%
fma-def54.2%
Simplified54.2%
Taylor expanded in ux around 0 98.9%
fma-def98.9%
sub-neg98.9%
metadata-eval98.9%
*-commutative98.9%
unpow298.9%
associate--l+98.9%
distribute-rgt-in98.9%
*-lft-identity98.9%
mul-1-neg98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-neg-in98.9%
metadata-eval98.9%
+-commutative98.9%
sub-neg98.9%
Simplified98.9%
Taylor expanded in uy around 0 80.2%
Taylor expanded in maxCos around 0 75.1%
+-commutative75.1%
mul-1-neg75.1%
unsub-neg75.1%
unpow275.1%
Simplified75.1%
Final simplification75.1%
(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.5%
associate-*l*54.5%
sub-neg54.5%
+-commutative54.5%
distribute-rgt-neg-in54.5%
fma-def54.5%
+-commutative54.5%
associate-+r-54.3%
fma-def54.3%
neg-sub054.3%
+-commutative54.3%
associate-+r-54.2%
associate--r-54.2%
neg-sub054.2%
+-commutative54.2%
sub-neg54.2%
fma-def54.2%
Simplified54.2%
Taylor expanded in ux around 0 98.9%
fma-def98.9%
sub-neg98.9%
metadata-eval98.9%
*-commutative98.9%
unpow298.9%
associate--l+98.9%
distribute-rgt-in98.9%
*-lft-identity98.9%
mul-1-neg98.9%
sub-neg98.9%
metadata-eval98.9%
distribute-neg-in98.9%
metadata-eval98.9%
+-commutative98.9%
sub-neg98.9%
Simplified98.9%
Taylor expanded in uy around 0 80.2%
Taylor expanded in ux around 0 65.7%
Taylor expanded in maxCos around 0 62.7%
Final simplification62.7%
herbie shell --seed 2023181
(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)))))))