
(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))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 13 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))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}
\end{array}
\end{array}
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (* ux ux) (- (/ (+ (* -2.0 maxCos) 2.0) ux) (pow (- maxCos 1.0) 2.0)))) (cos (* (PI) (* 2.0 uy)))))
\begin{array}{l}
\\
\sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 57.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
associate--r+N/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-subN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f32N/A
lower-/.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3270.5
Applied rewrites70.5%
Applied rewrites99.0%
Final simplification99.0%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (- 2.0 (- (* (pow (- maxCos 1.0) 2.0) ux) (* -2.0 maxCos))) ux)) (cos (* (PI) (* 2.0 uy)))))
\begin{array}{l}
\\
\sqrt{\left(2 - \left({\left(maxCos - 1\right)}^{2} \cdot ux - -2 \cdot maxCos\right)\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 57.0%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lower-+.f32N/A
lower-neg.f32N/A
lower-+.f3257.0
lift-*.f32N/A
*-commutativeN/A
lower-*.f3257.0
Applied rewrites57.0%
lift-+.f32N/A
lift-+.f32N/A
associate-+r+N/A
+-commutativeN/A
lift-neg.f32N/A
sub-negN/A
associate-+l-N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f3257.1
Applied rewrites57.1%
Taylor expanded in ux around 0
*-commutativeN/A
cancel-sign-sub-invN/A
metadata-evalN/A
associate-+r+N/A
+-commutativeN/A
lower-*.f32N/A
Applied rewrites2.1%
Applied rewrites99.0%
Final simplification99.0%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (cos (* (PI) (* 2.0 uy)))) (t_1 (- (/ 2.0 ux) 1.0)))
(if (<= maxCos 1.999999987845058e-8)
(* (sqrt (* t_1 (* ux ux))) t_0)
(*
(sqrt
(*
(* maxCos maxCos)
(*
(+ (+ -1.0 (/ (- 2.0 (/ 2.0 ux)) maxCos)) (/ (/ t_1 maxCos) maxCos))
(* ux ux))))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
t_1 := \frac{2}{ux} - 1\\
\mathbf{if}\;maxCos \leq 1.999999987845058 \cdot 10^{-8}:\\
\;\;\;\;\sqrt{t\_1 \cdot \left(ux \cdot ux\right)} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\left(\left(-1 + \frac{2 - \frac{2}{ux}}{maxCos}\right) + \frac{\frac{t\_1}{maxCos}}{maxCos}\right) \cdot \left(ux \cdot ux\right)\right)} \cdot t\_0\\
\end{array}
\end{array}
if maxCos < 1.99999999e-8Initial program 57.2%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
associate--r+N/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-subN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f32N/A
lower-/.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3273.9
Applied rewrites73.9%
Applied rewrites99.1%
Applied rewrites99.1%
Taylor expanded in maxCos around 0
Applied rewrites99.1%
if 1.99999999e-8 < maxCos Initial program 55.6%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
associate--r+N/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-subN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f32N/A
lower-/.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3255.0
Applied rewrites53.2%
Taylor expanded in maxCos around inf
Applied rewrites98.5%
Final simplification99.0%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (cos (* (PI) (* 2.0 uy)))))
(if (<= maxCos 8.99999985648492e-9)
(* (sqrt (* (- (/ 2.0 ux) 1.0) (* ux ux))) t_0)
(*
(sqrt
(*
(*
(- (/ (- (* ux 2.0) (- 2.0 (/ (- 2.0 ux) maxCos))) maxCos) ux)
(* maxCos maxCos))
ux))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\mathbf{if}\;maxCos \leq 8.99999985648492 \cdot 10^{-9}:\\
\;\;\;\;\sqrt{\left(\frac{2}{ux} - 1\right) \cdot \left(ux \cdot ux\right)} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(\frac{ux \cdot 2 - \left(2 - \frac{2 - ux}{maxCos}\right)}{maxCos} - ux\right) \cdot \left(maxCos \cdot maxCos\right)\right) \cdot ux} \cdot t\_0\\
\end{array}
\end{array}
if maxCos < 8.99999986e-9Initial program 57.5%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
associate--r+N/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-subN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f32N/A
lower-/.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3274.3
Applied rewrites74.3%
Applied rewrites99.1%
Applied rewrites99.1%
Taylor expanded in maxCos around 0
Applied rewrites99.1%
if 8.99999986e-9 < maxCos Initial program 54.5%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lower-+.f32N/A
lower-neg.f32N/A
lower-+.f3254.7
lift-*.f32N/A
*-commutativeN/A
lower-*.f3254.7
Applied rewrites54.7%
lift-+.f32N/A
lift-+.f32N/A
associate-+r+N/A
+-commutativeN/A
lift-neg.f32N/A
sub-negN/A
associate-+l-N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f3255.1
Applied rewrites55.1%
Taylor expanded in ux around 0
*-commutativeN/A
cancel-sign-sub-invN/A
metadata-evalN/A
associate-+r+N/A
+-commutativeN/A
lower-*.f32N/A
Applied rewrites6.7%
Taylor expanded in maxCos around -inf
Applied rewrites98.6%
Final simplification99.0%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (- (/ 2.0 ux) 1.0) (* ux ux))) (cos (* (PI) (* 2.0 uy)))))
\begin{array}{l}
\\
\sqrt{\left(\frac{2}{ux} - 1\right) \cdot \left(ux \cdot ux\right)} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 57.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
associate--r+N/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-subN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f32N/A
lower-/.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3270.5
Applied rewrites70.5%
Applied rewrites99.0%
Applied rewrites99.0%
Taylor expanded in maxCos around 0
Applied rewrites94.2%
Final simplification94.2%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (* (- (/ 2.0 ux) 1.0) ux) ux)) (cos (* (PI) (* 2.0 uy)))))
\begin{array}{l}
\\
\sqrt{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 57.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
associate--r+N/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-subN/A
cancel-sign-sub-invN/A
metadata-evalN/A
lower--.f32N/A
lower-/.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3270.5
Applied rewrites70.5%
Taylor expanded in maxCos around 0
Applied rewrites94.1%
Final simplification94.1%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (- 2.0 ux) ux)) (cos (* (PI) (* 2.0 uy)))))
\begin{array}{l}
\\
\sqrt{\left(2 - ux\right) \cdot ux} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 57.0%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lower-+.f32N/A
lower-neg.f32N/A
lower-+.f3257.0
lift-*.f32N/A
*-commutativeN/A
lower-*.f3257.0
Applied rewrites57.0%
lift-+.f32N/A
lift-+.f32N/A
associate-+r+N/A
+-commutativeN/A
lift-neg.f32N/A
sub-negN/A
associate-+l-N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f3257.1
Applied rewrites57.1%
Taylor expanded in ux around 0
*-commutativeN/A
cancel-sign-sub-invN/A
metadata-evalN/A
associate-+r+N/A
+-commutativeN/A
lower-*.f32N/A
Applied rewrites2.5%
Taylor expanded in maxCos around 0
Applied rewrites94.1%
Final simplification94.1%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* maxCos ux) (- 1.0 ux))))
(if (<= (- 1.0 (* t_0 t_0)) 0.00039999998989515007)
(* (sqrt (* (fma maxCos -2.0 2.0) ux)) 1.0)
(*
(sqrt
(-
1.0
(*
(+ (* (- maxCos 1.0) ux) 1.0)
(* (- (+ (/ 1.0 ux) maxCos) 1.0) ux))))
1.0))))
float code(float ux, float uy, float maxCos) {
float t_0 = (maxCos * ux) + (1.0f - ux);
float tmp;
if ((1.0f - (t_0 * t_0)) <= 0.00039999998989515007f) {
tmp = sqrtf((fmaf(maxCos, -2.0f, 2.0f) * ux)) * 1.0f;
} else {
tmp = sqrtf((1.0f - ((((maxCos - 1.0f) * ux) + 1.0f) * ((((1.0f / ux) + maxCos) - 1.0f) * ux)))) * 1.0f;
}
return tmp;
}
function code(ux, uy, maxCos) t_0 = Float32(Float32(maxCos * ux) + Float32(Float32(1.0) - ux)) tmp = Float32(0.0) if (Float32(Float32(1.0) - Float32(t_0 * t_0)) <= Float32(0.00039999998989515007)) tmp = Float32(sqrt(Float32(fma(maxCos, Float32(-2.0), Float32(2.0)) * ux)) * Float32(1.0)); else tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(Float32(maxCos - Float32(1.0)) * ux) + Float32(1.0)) * Float32(Float32(Float32(Float32(Float32(1.0) / ux) + maxCos) - Float32(1.0)) * ux)))) * Float32(1.0)); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := maxCos \cdot ux + \left(1 - ux\right)\\
\mathbf{if}\;1 - t\_0 \cdot t\_0 \leq 0.00039999998989515007:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\left(maxCos - 1\right) \cdot ux + 1\right) \cdot \left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right)} \cdot 1\\
\end{array}
\end{array}
if (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))) < 3.9999999e-4Initial program 34.2%
Taylor expanded in uy around 0
Applied rewrites29.8%
Taylor expanded in ux around 0
Applied rewrites6.7%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f3272.0
Applied rewrites73.9%
if 3.9999999e-4 < (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))) Initial program 89.1%
Taylor expanded in uy around 0
Applied rewrites72.8%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
lift-neg.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-+r+N/A
+-commutativeN/A
associate-+r+N/A
lower-+.f32N/A
lift-neg.f32N/A
neg-mul-1N/A
lower-fma.f3231.5
Applied rewrites31.5%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3273.0
Applied rewrites73.0%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
mul-1-negN/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-+r+N/A
lift-*.f32N/A
+-commutativeN/A
lower-+.f32N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lift--.f32N/A
*-commutativeN/A
lower-*.f3273.1
Applied rewrites73.1%
Final simplification73.9%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* maxCos ux) (- 1.0 ux))))
(if (<= (- 1.0 (* t_0 t_0)) 0.00039999998989515007)
(* (sqrt (* (fma maxCos -2.0 2.0) ux)) 1.0)
(* (sqrt (- 1.0 (* (+ (* (- maxCos 1.0) ux) 1.0) t_0))) 1.0))))
float code(float ux, float uy, float maxCos) {
float t_0 = (maxCos * ux) + (1.0f - ux);
float tmp;
if ((1.0f - (t_0 * t_0)) <= 0.00039999998989515007f) {
tmp = sqrtf((fmaf(maxCos, -2.0f, 2.0f) * ux)) * 1.0f;
} else {
tmp = sqrtf((1.0f - ((((maxCos - 1.0f) * ux) + 1.0f) * t_0))) * 1.0f;
}
return tmp;
}
function code(ux, uy, maxCos) t_0 = Float32(Float32(maxCos * ux) + Float32(Float32(1.0) - ux)) tmp = Float32(0.0) if (Float32(Float32(1.0) - Float32(t_0 * t_0)) <= Float32(0.00039999998989515007)) tmp = Float32(sqrt(Float32(fma(maxCos, Float32(-2.0), Float32(2.0)) * ux)) * Float32(1.0)); else tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(Float32(maxCos - Float32(1.0)) * ux) + Float32(1.0)) * t_0))) * Float32(1.0)); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := maxCos \cdot ux + \left(1 - ux\right)\\
\mathbf{if}\;1 - t\_0 \cdot t\_0 \leq 0.00039999998989515007:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\left(maxCos - 1\right) \cdot ux + 1\right) \cdot t\_0} \cdot 1\\
\end{array}
\end{array}
if (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))) < 3.9999999e-4Initial program 34.2%
Taylor expanded in uy around 0
Applied rewrites29.8%
Taylor expanded in ux around 0
Applied rewrites6.7%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f3270.1
Applied rewrites73.9%
if 3.9999999e-4 < (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))) Initial program 89.1%
Taylor expanded in uy around 0
Applied rewrites72.8%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
lift-neg.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-+r+N/A
+-commutativeN/A
associate-+r+N/A
lower-+.f32N/A
lift-neg.f32N/A
neg-mul-1N/A
lower-fma.f3231.5
Applied rewrites31.5%
lift-fma.f32N/A
lift-*.f32N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-negN/A
lift--.f32N/A
*-commutativeN/A
lower-*.f3273.0
Applied rewrites73.0%
Final simplification73.9%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* maxCos ux) (- 1.0 ux))))
(if (<= (- 1.0 (* t_0 t_0)) 0.00039999998989515007)
(* (sqrt (* (fma maxCos -2.0 2.0) ux)) 1.0)
(* (sqrt (- 1.0 (* (- 1.0 (- ux (* maxCos ux))) (- 1.0 ux)))) 1.0))))
float code(float ux, float uy, float maxCos) {
float t_0 = (maxCos * ux) + (1.0f - ux);
float tmp;
if ((1.0f - (t_0 * t_0)) <= 0.00039999998989515007f) {
tmp = sqrtf((fmaf(maxCos, -2.0f, 2.0f) * ux)) * 1.0f;
} else {
tmp = sqrtf((1.0f - ((1.0f - (ux - (maxCos * ux))) * (1.0f - ux)))) * 1.0f;
}
return tmp;
}
function code(ux, uy, maxCos) t_0 = Float32(Float32(maxCos * ux) + Float32(Float32(1.0) - ux)) tmp = Float32(0.0) if (Float32(Float32(1.0) - Float32(t_0 * t_0)) <= Float32(0.00039999998989515007)) tmp = Float32(sqrt(Float32(fma(maxCos, Float32(-2.0), Float32(2.0)) * ux)) * Float32(1.0)); else tmp = Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(1.0) - Float32(ux - Float32(maxCos * ux))) * Float32(Float32(1.0) - ux)))) * Float32(1.0)); end return tmp end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := maxCos \cdot ux + \left(1 - ux\right)\\
\mathbf{if}\;1 - t\_0 \cdot t\_0 \leq 0.00039999998989515007:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot 1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot \left(1 - ux\right)} \cdot 1\\
\end{array}
\end{array}
if (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))) < 3.9999999e-4Initial program 34.2%
Taylor expanded in uy around 0
Applied rewrites29.8%
Taylor expanded in ux around 0
Applied rewrites6.7%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f3274.6
Applied rewrites73.9%
if 3.9999999e-4 < (-.f32 #s(literal 1 binary32) (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)))) Initial program 89.1%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lower-+.f32N/A
lower-neg.f32N/A
lower-+.f3289.2
lift-*.f32N/A
*-commutativeN/A
lower-*.f3289.2
Applied rewrites89.2%
lift-+.f32N/A
lift-+.f32N/A
associate-+r+N/A
+-commutativeN/A
lift-neg.f32N/A
sub-negN/A
associate-+l-N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lower--.f3289.3
Applied rewrites89.3%
Taylor expanded in maxCos around 0
lower--.f3286.1
Applied rewrites86.1%
Taylor expanded in uy around 0
Applied rewrites70.9%
Final simplification73.0%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (fma maxCos -2.0 2.0) ux)) 1.0))
float code(float ux, float uy, float maxCos) {
return sqrtf((fmaf(maxCos, -2.0f, 2.0f) * ux)) * 1.0f;
}
function code(ux, uy, maxCos) return Float32(sqrt(Float32(fma(maxCos, Float32(-2.0), Float32(2.0)) * ux)) * Float32(1.0)) end
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot 1
\end{array}
Initial program 57.0%
Taylor expanded in uy around 0
Applied rewrites47.6%
Taylor expanded in ux around 0
Applied rewrites6.6%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f3263.7
Applied rewrites63.3%
Final simplification62.9%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (fma -1.0 1.0 1.0)) 1.0))
float code(float ux, float uy, float maxCos) {
return sqrtf(fmaf(-1.0f, 1.0f, 1.0f)) * 1.0f;
}
function code(ux, uy, maxCos) return Float32(sqrt(fma(Float32(-1.0), Float32(1.0), Float32(1.0))) * Float32(1.0)) end
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(-1, 1, 1\right)} \cdot 1
\end{array}
Initial program 57.0%
Taylor expanded in uy around 0
Applied rewrites47.6%
Taylor expanded in ux around 0
Applied rewrites6.6%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
neg-mul-1N/A
lower-fma.f3220.0
Applied rewrites20.0%
Final simplification20.0%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- 1.0 1.0)) 1.0))
float code(float ux, float uy, float maxCos) {
return sqrtf((1.0f - 1.0f)) * 1.0f;
}
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 - 1.0e0)) * 1.0e0
end function
function code(ux, uy, maxCos) return Float32(sqrt(Float32(Float32(1.0) - Float32(1.0))) * Float32(1.0)) end
function tmp = code(ux, uy, maxCos) tmp = sqrt((single(1.0) - single(1.0))) * single(1.0); end
\begin{array}{l}
\\
\sqrt{1 - 1} \cdot 1
\end{array}
Initial program 57.0%
Taylor expanded in uy around 0
Applied rewrites47.6%
Taylor expanded in ux around 0
Applied rewrites6.6%
Final simplification6.6%
herbie shell --seed 2024264
(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)))))))