
(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 12 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 (* ux (- 2.0 (+ (* 2.0 maxCos) (* ux (pow (+ -1.0 maxCos) 2.0))))))))
float code(float ux, float uy, float maxCos) {
return cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((ux * (2.0f - ((2.0f * maxCos) + (ux * powf((-1.0f + maxCos), 2.0f))))));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(ux * Float32(Float32(2.0) - Float32(Float32(Float32(2.0) * maxCos) + Float32(ux * (Float32(Float32(-1.0) + maxCos) ^ Float32(2.0)))))))) end
function tmp = code(ux, uy, maxCos) tmp = cos(((uy * single(2.0)) * single(pi))) * sqrt((ux * (single(2.0) - ((single(2.0) * maxCos) + (ux * ((single(-1.0) + maxCos) ^ single(2.0))))))); end
\begin{array}{l}
\\
\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - \left(2 \cdot maxCos + ux \cdot {\left(-1 + maxCos\right)}^{2}\right)\right)}
\end{array}
Initial program 60.7%
Taylor expanded in ux around 0 99.0%
associate--l+99.0%
associate-*r*99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
+-commutative99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (ux uy maxCos) :precision binary32 (* (cos (* (* uy 2.0) PI)) (sqrt (* ux (+ 2.0 (- (* maxCos (- (* ux (- 2.0 maxCos)) 2.0)) ux))))))
float code(float ux, float uy, float maxCos) {
return cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((ux * (2.0f + ((maxCos * ((ux * (2.0f - maxCos)) - 2.0f)) - ux))));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(ux * Float32(Float32(2.0) + Float32(Float32(maxCos * Float32(Float32(ux * Float32(Float32(2.0) - maxCos)) - Float32(2.0))) - ux))))) end
function tmp = code(ux, uy, maxCos) tmp = cos(((uy * single(2.0)) * single(pi))) * sqrt((ux * (single(2.0) + ((maxCos * ((ux * (single(2.0) - maxCos)) - single(2.0))) - ux)))); end
\begin{array}{l}
\\
\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 + \left(maxCos \cdot \left(ux \cdot \left(2 - maxCos\right) - 2\right) - ux\right)\right)}
\end{array}
Initial program 60.7%
Taylor expanded in ux around 0 99.0%
associate--l+99.0%
associate-*r*99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in maxCos around 0 99.0%
Taylor expanded in ux around 0 99.0%
mul-1-neg99.0%
unsub-neg99.0%
Simplified99.0%
pow199.0%
mul-1-neg99.0%
Applied egg-rr99.0%
unpow199.0%
Simplified99.0%
Final simplification99.0%
(FPCore (ux uy maxCos) :precision binary32 (if (<= maxCos 3.3999999686784577e-6) (* (cos (* (* uy 2.0) PI)) (sqrt (* ux (- 2.0 ux)))) (sqrt (* ux (- (- 2.0 (* ux (pow (+ -1.0 maxCos) 2.0))) (* 2.0 maxCos))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (maxCos <= 3.3999999686784577e-6f) {
tmp = cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((ux * (2.0f - ux)));
} else {
tmp = sqrtf((ux * ((2.0f - (ux * powf((-1.0f + maxCos), 2.0f))) - (2.0f * maxCos))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (maxCos <= Float32(3.3999999686784577e-6)) tmp = Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(ux * Float32(Float32(2.0) - ux)))); else tmp = sqrt(Float32(ux * Float32(Float32(Float32(2.0) - Float32(ux * (Float32(Float32(-1.0) + maxCos) ^ Float32(2.0)))) - Float32(Float32(2.0) * maxCos)))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (maxCos <= single(3.3999999686784577e-6)) tmp = cos(((uy * single(2.0)) * single(pi))) * sqrt((ux * (single(2.0) - ux))); else tmp = sqrt((ux * ((single(2.0) - (ux * ((single(-1.0) + maxCos) ^ single(2.0)))) - (single(2.0) * maxCos)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 3.3999999686784577 \cdot 10^{-6}:\\
\;\;\;\;\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - ux\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{ux \cdot \left(\left(2 - ux \cdot {\left(-1 + maxCos\right)}^{2}\right) - 2 \cdot maxCos\right)}\\
\end{array}
\end{array}
if maxCos < 3.39999997e-6Initial program 63.0%
Taylor expanded in ux around 0 99.0%
associate--l+99.0%
associate-*r*99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in maxCos around 0 99.0%
Taylor expanded in maxCos around 0 98.7%
neg-mul-198.7%
unsub-neg98.7%
Simplified98.7%
if 3.39999997e-6 < maxCos Initial program 48.6%
Taylor expanded in ux around 0 99.3%
associate--l+99.2%
associate-*r*99.2%
mul-1-neg99.2%
sub-neg99.2%
metadata-eval99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in uy around 0 85.7%
Final simplification96.7%
(FPCore (ux uy maxCos) :precision binary32 (* (cos (* (* uy 2.0) PI)) (sqrt (* ux (+ 2.0 (- (* maxCos (- (* 2.0 ux) 2.0)) ux))))))
float code(float ux, float uy, float maxCos) {
return cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((ux * (2.0f + ((maxCos * ((2.0f * ux) - 2.0f)) - ux))));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(ux * Float32(Float32(2.0) + Float32(Float32(maxCos * Float32(Float32(Float32(2.0) * ux) - Float32(2.0))) - ux))))) 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))) - ux)))); end
\begin{array}{l}
\\
\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 + \left(maxCos \cdot \left(2 \cdot ux - 2\right) - ux\right)\right)}
\end{array}
Initial program 60.7%
Taylor expanded in ux around 0 99.0%
associate--l+99.0%
associate-*r*99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in maxCos around 0 98.0%
pow199.0%
mul-1-neg99.0%
Applied egg-rr98.0%
unpow199.0%
Simplified98.0%
Final simplification98.0%
(FPCore (ux uy maxCos) :precision binary32 (if (<= maxCos 3.3999999686784577e-6) (* (cos (* (* uy 2.0) PI)) (sqrt (* ux (- 2.0 ux)))) (sqrt (* ux (+ 2.0 (- (* maxCos (- (* ux (- 2.0 maxCos)) 2.0)) ux))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (maxCos <= 3.3999999686784577e-6f) {
tmp = cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((ux * (2.0f - ux)));
} else {
tmp = sqrtf((ux * (2.0f + ((maxCos * ((ux * (2.0f - maxCos)) - 2.0f)) - ux))));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (maxCos <= Float32(3.3999999686784577e-6)) tmp = Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(ux * Float32(Float32(2.0) - ux)))); else tmp = sqrt(Float32(ux * Float32(Float32(2.0) + Float32(Float32(maxCos * Float32(Float32(ux * Float32(Float32(2.0) - maxCos)) - Float32(2.0))) - ux)))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if (maxCos <= single(3.3999999686784577e-6)) tmp = cos(((uy * single(2.0)) * single(pi))) * sqrt((ux * (single(2.0) - ux))); else tmp = sqrt((ux * (single(2.0) + ((maxCos * ((ux * (single(2.0) - maxCos)) - single(2.0))) - ux)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 3.3999999686784577 \cdot 10^{-6}:\\
\;\;\;\;\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 - ux\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{ux \cdot \left(2 + \left(maxCos \cdot \left(ux \cdot \left(2 - maxCos\right) - 2\right) - ux\right)\right)}\\
\end{array}
\end{array}
if maxCos < 3.39999997e-6Initial program 63.0%
Taylor expanded in ux around 0 99.0%
associate--l+99.0%
associate-*r*99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in maxCos around 0 99.0%
Taylor expanded in maxCos around 0 98.7%
neg-mul-198.7%
unsub-neg98.7%
Simplified98.7%
if 3.39999997e-6 < maxCos Initial program 48.6%
Taylor expanded in ux around 0 99.3%
associate--l+99.2%
associate-*r*99.2%
mul-1-neg99.2%
sub-neg99.2%
metadata-eval99.2%
+-commutative99.2%
Simplified99.2%
Taylor expanded in maxCos around 0 99.1%
Taylor expanded in ux around 0 99.1%
mul-1-neg99.1%
unsub-neg99.1%
Simplified99.1%
Taylor expanded in uy around 0 85.6%
Final simplification96.7%
(FPCore (ux uy maxCos) :precision binary32 (if (<= (* uy 2.0) 0.004000000189989805) (sqrt (* ux (+ 2.0 (- (* maxCos (- (* ux (- 2.0 maxCos)) 2.0)) ux)))) (* (cos (* (* uy 2.0) PI)) (sqrt (* 2.0 ux)))))
float code(float ux, float uy, float maxCos) {
float tmp;
if ((uy * 2.0f) <= 0.004000000189989805f) {
tmp = sqrtf((ux * (2.0f + ((maxCos * ((ux * (2.0f - maxCos)) - 2.0f)) - ux))));
} else {
tmp = cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((2.0f * ux));
}
return tmp;
}
function code(ux, uy, maxCos) tmp = Float32(0.0) if (Float32(uy * Float32(2.0)) <= Float32(0.004000000189989805)) tmp = sqrt(Float32(ux * Float32(Float32(2.0) + Float32(Float32(maxCos * Float32(Float32(ux * Float32(Float32(2.0) - maxCos)) - Float32(2.0))) - ux)))); else tmp = Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(Float32(2.0) * ux))); end return tmp end
function tmp_2 = code(ux, uy, maxCos) tmp = single(0.0); if ((uy * single(2.0)) <= single(0.004000000189989805)) tmp = sqrt((ux * (single(2.0) + ((maxCos * ((ux * (single(2.0) - maxCos)) - single(2.0))) - ux)))); else tmp = cos(((uy * single(2.0)) * single(pi))) * sqrt((single(2.0) * ux)); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \cdot 2 \leq 0.004000000189989805:\\
\;\;\;\;\sqrt{ux \cdot \left(2 + \left(maxCos \cdot \left(ux \cdot \left(2 - maxCos\right) - 2\right) - ux\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{2 \cdot ux}\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00400000019Initial program 63.1%
Taylor expanded in ux around 0 99.3%
associate--l+99.3%
associate-*r*99.3%
mul-1-neg99.3%
sub-neg99.3%
metadata-eval99.3%
+-commutative99.3%
Simplified99.3%
Taylor expanded in maxCos around 0 99.3%
Taylor expanded in ux around 0 99.3%
mul-1-neg99.3%
unsub-neg99.3%
Simplified99.3%
Taylor expanded in uy around 0 95.9%
if 0.00400000019 < (*.f32 uy #s(literal 2 binary32)) Initial program 54.2%
Taylor expanded in ux around 0 45.1%
Taylor expanded in maxCos around 0 76.0%
Final simplification90.6%
(FPCore (ux uy maxCos) :precision binary32 (* (cos (* (* uy 2.0) PI)) (sqrt (* ux (+ 2.0 (- (* maxCos -2.0) ux))))))
float code(float ux, float uy, float maxCos) {
return cosf(((uy * 2.0f) * ((float) M_PI))) * sqrtf((ux * (2.0f + ((maxCos * -2.0f) - ux))));
}
function code(ux, uy, maxCos) return Float32(cos(Float32(Float32(uy * Float32(2.0)) * Float32(pi))) * sqrt(Float32(ux * Float32(Float32(2.0) + Float32(Float32(maxCos * Float32(-2.0)) - ux))))) 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)))); end
\begin{array}{l}
\\
\cos \left(\left(uy \cdot 2\right) \cdot \pi\right) \cdot \sqrt{ux \cdot \left(2 + \left(maxCos \cdot -2 - ux\right)\right)}
\end{array}
Initial program 60.7%
Taylor expanded in ux around 0 99.0%
associate--l+99.0%
associate-*r*99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in maxCos around 0 99.0%
Taylor expanded in ux around 0 97.4%
Final simplification97.4%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (* ux (+ 2.0 (- (* maxCos (- (* ux (- 2.0 maxCos)) 2.0)) ux)))))
float code(float ux, float uy, float maxCos) {
return sqrtf((ux * (2.0f + ((maxCos * ((ux * (2.0f - maxCos)) - 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((ux * (2.0e0 + ((maxcos * ((ux * (2.0e0 - maxcos)) - 2.0e0)) - ux))))
end function
function code(ux, uy, maxCos) return sqrt(Float32(ux * Float32(Float32(2.0) + Float32(Float32(maxCos * Float32(Float32(ux * Float32(Float32(2.0) - maxCos)) - Float32(2.0))) - ux)))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt((ux * (single(2.0) + ((maxCos * ((ux * (single(2.0) - maxCos)) - single(2.0))) - ux)))); end
\begin{array}{l}
\\
\sqrt{ux \cdot \left(2 + \left(maxCos \cdot \left(ux \cdot \left(2 - maxCos\right) - 2\right) - ux\right)\right)}
\end{array}
Initial program 60.7%
Taylor expanded in ux around 0 99.0%
associate--l+99.0%
associate-*r*99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in maxCos around 0 99.0%
Taylor expanded in ux around 0 99.0%
mul-1-neg99.0%
unsub-neg99.0%
Simplified99.0%
Taylor expanded in uy around 0 81.5%
Final simplification81.5%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (* ux (+ 2.0 (- (* maxCos (- (* 2.0 ux) 2.0)) ux)))))
float code(float ux, float uy, float maxCos) {
return sqrtf((ux * (2.0f + ((maxCos * ((2.0f * ux) - 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((ux * (2.0e0 + ((maxcos * ((2.0e0 * ux) - 2.0e0)) - ux))))
end function
function code(ux, uy, maxCos) return sqrt(Float32(ux * Float32(Float32(2.0) + Float32(Float32(maxCos * Float32(Float32(Float32(2.0) * ux) - Float32(2.0))) - ux)))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt((ux * (single(2.0) + ((maxCos * ((single(2.0) * ux) - single(2.0))) - ux)))); end
\begin{array}{l}
\\
\sqrt{ux \cdot \left(2 + \left(maxCos \cdot \left(2 \cdot ux - 2\right) - ux\right)\right)}
\end{array}
Initial program 60.7%
Taylor expanded in ux around 0 99.0%
associate--l+99.0%
associate-*r*99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in maxCos around 0 98.0%
Taylor expanded in uy around 0 80.9%
Final simplification80.9%
(FPCore (ux uy maxCos) :precision binary32 (if (<= maxCos 4.999999873689376e-6) (sqrt (* ux (- 2.0 ux))) (sqrt (* ux (- 2.0 (* 2.0 maxCos))))))
float code(float ux, float uy, float maxCos) {
float tmp;
if (maxCos <= 4.999999873689376e-6f) {
tmp = sqrtf((ux * (2.0f - ux)));
} else {
tmp = sqrtf((ux * (2.0f - (2.0f * maxCos))));
}
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 (maxcos <= 4.999999873689376e-6) then
tmp = sqrt((ux * (2.0e0 - ux)))
else
tmp = sqrt((ux * (2.0e0 - (2.0e0 * maxcos))))
end if
code = tmp
end function
function code(ux, uy, maxCos) tmp = Float32(0.0) if (maxCos <= Float32(4.999999873689376e-6)) tmp = sqrt(Float32(ux * Float32(Float32(2.0) - ux))); else tmp = 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 (maxCos <= single(4.999999873689376e-6)) tmp = sqrt((ux * (single(2.0) - ux))); else tmp = sqrt((ux * (single(2.0) - (single(2.0) * maxCos)))); end tmp_2 = tmp; end
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 4.999999873689376 \cdot 10^{-6}:\\
\;\;\;\;\sqrt{ux \cdot \left(2 - ux\right)}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{ux \cdot \left(2 - 2 \cdot maxCos\right)}\\
\end{array}
\end{array}
if maxCos < 4.99999987e-6Initial program 63.0%
Taylor expanded in ux around 0 99.0%
associate--l+99.0%
associate-*r*99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in maxCos around 0 99.0%
Taylor expanded in maxCos around 0 98.6%
neg-mul-198.6%
unsub-neg98.6%
Simplified98.6%
Taylor expanded in uy around 0 80.7%
if 4.99999987e-6 < maxCos Initial program 47.5%
Taylor expanded in ux around 0 83.5%
Taylor expanded in uy around 0 74.1%
(FPCore (ux uy maxCos) :precision binary32 (sqrt (* ux (- 2.0 ux))))
float code(float ux, float uy, float maxCos) {
return sqrtf((ux * (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((ux * (2.0e0 - ux)))
end function
function code(ux, uy, maxCos) return sqrt(Float32(ux * Float32(Float32(2.0) - ux))) end
function tmp = code(ux, uy, maxCos) tmp = sqrt((ux * (single(2.0) - ux))); end
\begin{array}{l}
\\
\sqrt{ux \cdot \left(2 - ux\right)}
\end{array}
Initial program 60.7%
Taylor expanded in ux around 0 99.0%
associate--l+99.0%
associate-*r*99.0%
mul-1-neg99.0%
sub-neg99.0%
metadata-eval99.0%
+-commutative99.0%
Simplified99.0%
Taylor expanded in maxCos around 0 99.0%
Taylor expanded in maxCos around 0 91.6%
neg-mul-191.6%
unsub-neg91.6%
Simplified91.6%
Taylor expanded in uy around 0 76.1%
(FPCore (ux uy maxCos) :precision binary32 0.0)
float code(float ux, float uy, float maxCos) {
return 0.0f;
}
real(4) function code(ux, uy, maxcos)
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = 0.0e0
end function
function code(ux, uy, maxCos) return Float32(0.0) end
function tmp = code(ux, uy, maxCos) tmp = single(0.0); end
\begin{array}{l}
\\
0
\end{array}
Initial program 60.7%
associate-*l*60.7%
sub-neg60.7%
+-commutative60.7%
distribute-rgt-neg-in60.7%
fma-define60.9%
Simplified61.1%
Taylor expanded in uy around 0 53.6%
mul-1-neg53.6%
unsub-neg53.6%
sub-neg53.6%
metadata-eval53.6%
distribute-lft-in53.6%
*-commutative53.6%
mul-1-neg53.6%
sub-neg53.6%
*-commutative53.6%
associate--l+53.4%
unpow253.4%
sub-neg53.4%
Simplified53.8%
Taylor expanded in ux around 0 6.6%
pow1/26.6%
metadata-eval6.6%
metadata-eval6.6%
metadata-eval6.6%
Applied egg-rr6.6%
herbie shell --seed 2024113
(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)))))))