
(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))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\sin \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 19 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))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\sin \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 (* (- (- 2.0 (* (pow (- maxCos 1.0) 2.0) ux)) (* maxCos 2.0)) ux)) (sin (* 2.0 (* uy (PI))))))
\begin{array}{l}
\\
\sqrt{\left(\left(2 - {\left(maxCos - 1\right)}^{2} \cdot ux\right) - maxCos \cdot 2\right) \cdot ux} \cdot \sin \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right)
\end{array}
Initial program 57.9%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3258.8
Applied rewrites58.8%
lift-*.f32N/A
rem-square-sqrtN/A
lift-sqrt.f32N/A
lift-sqrt.f32N/A
associate-*r*N/A
lift-*.f32N/A
associate-*r*N/A
lift-*.f32N/A
lift-*.f32N/A
lift-*.f3258.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3258.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3258.8
Applied rewrites58.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f3297.5
Applied rewrites97.5%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
*-commutativeN/A
associate-*r*N/A
lift-sqrt.f32N/A
lift-sqrt.f32N/A
rem-square-sqrtN/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3298.2
Applied rewrites98.2%
Final simplification98.2%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (* 2.0 uy) (PI)))) (t_1 (+ (- 1.0 ux) (* maxCos ux))))
(if (<= (- 1.0 (* t_1 t_1)) 0.00015999999595806003)
(* (sqrt (* (* (- maxCos 1.0) ux) -2.0)) t_0)
(* (sqrt (- 1.0 (* (- (+ (* maxCos ux) 1.0) ux) (- 1.0 ux)))) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
t_1 := \left(1 - ux\right) + maxCos \cdot ux\\
\mathbf{if}\;1 - t\_1 \cdot t\_1 \leq 0.00015999999595806003:\\
\;\;\;\;\sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot -2} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\left(maxCos \cdot ux + 1\right) - ux\right) \cdot \left(1 - ux\right)} \cdot t\_0\\
\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)))) < 1.59999996e-4Initial program 34.2%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
lower--.f32N/A
lift-*.f32N/A
pow2N/A
pow-to-expN/A
rem-log-expN/A
pow-to-expN/A
pow2N/A
lift-*.f32N/A
lower-expm1.f32N/A
Applied rewrites48.7%
lift-log1p.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-*.f32N/A
associate-+r+N/A
*-commutativeN/A
neg-mul-1N/A
sub-negN/A
associate-+l-N/A
flip3--N/A
log-divN/A
lower--.f32N/A
Applied rewrites91.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3293.4
Applied rewrites93.4%
if 1.59999996e-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.4%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lower-+.f32N/A
lower-neg.f32N/A
lower-+.f3289.3
lift-*.f32N/A
*-commutativeN/A
lower-*.f3289.3
Applied rewrites89.3%
Taylor expanded in maxCos around 0
lower--.f3287.1
Applied rewrites87.1%
Final simplification90.7%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (* 2.0 uy) (PI)))) (t_1 (+ (- 1.0 ux) (* maxCos ux))))
(if (<= (- 1.0 (* t_1 t_1)) 0.00015999999595806003)
(* (sqrt (* (* (- maxCos 1.0) ux) -2.0)) t_0)
(* (sqrt (- 1.0 (* (- 1.0 ux) t_1))) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
t_1 := \left(1 - ux\right) + maxCos \cdot ux\\
\mathbf{if}\;1 - t\_1 \cdot t\_1 \leq 0.00015999999595806003:\\
\;\;\;\;\sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot -2} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot t\_1} \cdot t\_0\\
\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)))) < 1.59999996e-4Initial program 34.2%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
lower--.f32N/A
lift-*.f32N/A
pow2N/A
pow-to-expN/A
rem-log-expN/A
pow-to-expN/A
pow2N/A
lift-*.f32N/A
lower-expm1.f32N/A
Applied rewrites48.7%
lift-log1p.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-*.f32N/A
associate-+r+N/A
*-commutativeN/A
neg-mul-1N/A
sub-negN/A
associate-+l-N/A
flip3--N/A
log-divN/A
lower--.f32N/A
Applied rewrites91.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3293.4
Applied rewrites93.4%
if 1.59999996e-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.4%
Taylor expanded in maxCos around 0
lower--.f3287.0
Applied rewrites87.0%
Final simplification90.6%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (* 2.0 uy) (PI)))) (t_1 (+ (- 1.0 ux) (* maxCos ux))))
(if (<= t_1 0.9999200105667114)
(* (sqrt (- 1.0 (* t_1 t_1))) t_0)
(* (sqrt (* (* (- maxCos 1.0) ux) -2.0)) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
t_1 := \left(1 - ux\right) + maxCos \cdot ux\\
\mathbf{if}\;t\_1 \leq 0.9999200105667114:\\
\;\;\;\;\sqrt{1 - t\_1 \cdot t\_1} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot -2} \cdot t\_0\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999920011Initial program 89.4%
if 0.999920011 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 34.2%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
lower--.f32N/A
lift-*.f32N/A
pow2N/A
pow-to-expN/A
rem-log-expN/A
pow-to-expN/A
pow2N/A
lift-*.f32N/A
lower-expm1.f32N/A
Applied rewrites48.7%
lift-log1p.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-*.f32N/A
associate-+r+N/A
*-commutativeN/A
neg-mul-1N/A
sub-negN/A
associate-+l-N/A
flip3--N/A
log-divN/A
lower--.f32N/A
Applied rewrites91.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3293.4
Applied rewrites93.4%
Final simplification91.7%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sqrt (PI))))
(*
(sqrt (* (- (- 2.0 (* (fma -2.0 ux 2.0) maxCos)) ux) ux))
(sin (* (* (* t_0 2.0) uy) t_0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\sqrt{\left(\left(2 - \mathsf{fma}\left(-2, ux, 2\right) \cdot maxCos\right) - ux\right) \cdot ux} \cdot \sin \left(\left(\left(t\_0 \cdot 2\right) \cdot uy\right) \cdot t\_0\right)
\end{array}
\end{array}
Initial program 57.9%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3258.8
Applied rewrites58.8%
lift-*.f32N/A
rem-square-sqrtN/A
lift-sqrt.f32N/A
lift-sqrt.f32N/A
associate-*r*N/A
lift-*.f32N/A
associate-*r*N/A
lift-*.f32N/A
lift-*.f32N/A
lift-*.f3258.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3258.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3258.8
Applied rewrites58.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f3297.5
Applied rewrites97.5%
Taylor expanded in maxCos around 0
Applied rewrites84.5%
Final simplification82.6%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (* 2.0 uy) (PI)))))
(if (<= ux 7.999999797903001e-5)
(* (sqrt (* (* (- maxCos 1.0) ux) -2.0)) t_0)
(*
(sqrt
(- 1.0 (* (+ (- 1.0 ux) (* maxCos ux)) (- 1.0 (- ux (* maxCos ux))))))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
\mathbf{if}\;ux \leq 7.999999797903001 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{\left(\left(maxCos - 1\right) \cdot ux\right) \cdot -2} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\left(1 - ux\right) + maxCos \cdot ux\right) \cdot \left(1 - \left(ux - maxCos \cdot ux\right)\right)} \cdot t\_0\\
\end{array}
\end{array}
if ux < 7.9999998e-5Initial program 34.2%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
lower--.f32N/A
lift-*.f32N/A
pow2N/A
pow-to-expN/A
rem-log-expN/A
pow-to-expN/A
pow2N/A
lift-*.f32N/A
lower-expm1.f32N/A
Applied rewrites48.7%
lift-log1p.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-*.f32N/A
associate-+r+N/A
*-commutativeN/A
neg-mul-1N/A
sub-negN/A
associate-+l-N/A
flip3--N/A
log-divN/A
lower--.f32N/A
Applied rewrites91.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3293.4
Applied rewrites93.4%
if 7.9999998e-5 < ux Initial program 89.4%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
lower--.f3289.5
lift-*.f32N/A
*-commutativeN/A
lower-*.f3289.5
Applied rewrites89.5%
Final simplification91.7%
(FPCore (ux uy maxCos) :precision binary32 (let* ((t_0 (sqrt (PI)))) (* (sqrt (* (- 2.0 ux) ux)) (sin (* (* (* t_0 2.0) uy) t_0)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{\mathsf{PI}\left(\right)}\\
\sqrt{\left(2 - ux\right) \cdot ux} \cdot \sin \left(\left(\left(t\_0 \cdot 2\right) \cdot uy\right) \cdot t\_0\right)
\end{array}
\end{array}
Initial program 57.9%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3258.8
Applied rewrites58.8%
lift-*.f32N/A
rem-square-sqrtN/A
lift-sqrt.f32N/A
lift-sqrt.f32N/A
associate-*r*N/A
lift-*.f32N/A
associate-*r*N/A
lift-*.f32N/A
lift-*.f32N/A
lift-*.f3258.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3258.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3258.8
Applied rewrites58.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f3297.5
Applied rewrites97.5%
Taylor expanded in maxCos around 0
Applied rewrites92.6%
Final simplification92.6%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (- maxCos 1.0) ux)))
(if (<= (+ (- 1.0 ux) (* maxCos ux)) 0.9998499751091003)
(*
(sqrt (- 1.0 (* (+ t_0 1.0) (- 1.0 (- ux (* maxCos ux))))))
(* (* 2.0 (PI)) uy))
(* (sqrt (* t_0 -2.0)) (sin (* (* 2.0 uy) (PI)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos - 1\right) \cdot ux\\
\mathbf{if}\;\left(1 - ux\right) + maxCos \cdot ux \leq 0.9998499751091003:\\
\;\;\;\;\sqrt{1 - \left(t\_0 + 1\right) \cdot \left(1 - \left(ux - maxCos \cdot ux\right)\right)} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{t\_0 \cdot -2} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999849975Initial program 90.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3290.0
Applied rewrites90.0%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3277.2
Applied rewrites77.2%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift--.f32N/A
lower--.f3277.1
Applied rewrites77.1%
Applied rewrites77.2%
if 0.999849975 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 35.6%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
neg-sub0N/A
associate-+l-N/A
lower--.f32N/A
lift-*.f32N/A
pow2N/A
pow-to-expN/A
rem-log-expN/A
pow-to-expN/A
pow2N/A
lift-*.f32N/A
lower-expm1.f32N/A
Applied rewrites49.4%
lift-log1p.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-*.f32N/A
associate-+r+N/A
*-commutativeN/A
neg-mul-1N/A
sub-negN/A
associate-+l-N/A
flip3--N/A
log-divN/A
lower--.f32N/A
Applied rewrites90.5%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3292.7
Applied rewrites92.7%
Final simplification86.4%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 6.799999852091787e-8)
(* (sqrt (* (fma maxCos -2.0 2.0) ux)) (sin (* (* 2.0 uy) (PI))))
(*
(sqrt
(-
1.0
(* (* (- (+ (/ 1.0 ux) maxCos) 1.0) ux) (+ (- 1.0 ux) (* maxCos ux)))))
(* (* 2.0 (PI)) uy))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 6.799999852091787 \cdot 10^{-8}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(maxCos, -2, 2\right) \cdot ux} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right) \cdot \left(\left(1 - ux\right) + maxCos \cdot ux\right)} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)\\
\end{array}
\end{array}
if ux < 6.79999985e-8Initial program 12.0%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f3239.4
Applied rewrites39.4%
if 6.79999985e-8 < ux Initial program 74.9%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3275.2
Applied rewrites75.2%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3265.8
Applied rewrites65.8%
Final simplification73.3%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sqrt
(-
1.0
(* (* (- (+ (/ 1.0 ux) maxCos) 1.0) ux) (+ (- 1.0 ux) (* maxCos ux)))))
(* (* 2.0 (PI)) uy)))\begin{array}{l}
\\
\sqrt{1 - \left(\left(\left(\frac{1}{ux} + maxCos\right) - 1\right) \cdot ux\right) \cdot \left(\left(1 - ux\right) + maxCos \cdot ux\right)} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)
\end{array}
Initial program 57.9%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3258.8
Applied rewrites58.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3252.0
Applied rewrites52.0%
Final simplification52.0%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* 2.0 (PI)) uy)) (t_1 (+ (* (- maxCos 1.0) ux) 1.0)))
(if (<= ux 3.999999975690116e-8)
(* (sqrt (fma (- ux (fma maxCos ux 1.0)) t_1 1.0)) t_0)
(* (sqrt (- 1.0 (* t_1 (- 1.0 (- ux (* maxCos ux)))))) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
t_1 := \left(maxCos - 1\right) \cdot ux + 1\\
\mathbf{if}\;ux \leq 3.999999975690116 \cdot 10^{-8}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(ux - \mathsf{fma}\left(maxCos, ux, 1\right), t\_1, 1\right)} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - t\_1 \cdot \left(1 - \left(ux - maxCos \cdot ux\right)\right)} \cdot t\_0\\
\end{array}
\end{array}
if ux < 3.99999998e-8Initial program 7.8%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3211.5
Applied rewrites11.5%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3211.5
Applied rewrites11.5%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
lift--.f32N/A
lift-*.f32N/A
distribute-lft-neg-inN/A
lower-fma.f32N/A
Applied rewrites16.1%
if 3.99999998e-8 < ux Initial program 73.3%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3273.3
Applied rewrites73.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3264.4
Applied rewrites64.4%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift--.f32N/A
lower--.f3264.4
Applied rewrites64.4%
Applied rewrites64.4%
Final simplification53.1%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* 2.0 (PI)) uy)) (t_1 (+ (- 1.0 ux) (* maxCos ux))))
(if (<= ux 3.999999975690116e-8)
(*
(sqrt (fma (- ux (fma maxCos ux 1.0)) (+ (* (- maxCos 1.0) ux) 1.0) 1.0))
t_0)
(* t_0 (sqrt (- 1.0 (* t_1 t_1)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
t_1 := \left(1 - ux\right) + maxCos \cdot ux\\
\mathbf{if}\;ux \leq 3.999999975690116 \cdot 10^{-8}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(ux - \mathsf{fma}\left(maxCos, ux, 1\right), \left(maxCos - 1\right) \cdot ux + 1, 1\right)} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{1 - t\_1 \cdot t\_1}\\
\end{array}
\end{array}
if ux < 3.99999998e-8Initial program 7.8%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3211.5
Applied rewrites11.5%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3211.5
Applied rewrites11.5%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
lift--.f32N/A
lift-*.f32N/A
distribute-lft-neg-inN/A
lower-fma.f32N/A
Applied rewrites16.1%
if 3.99999998e-8 < ux Initial program 73.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3264.3
Applied rewrites64.3%
Final simplification53.0%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* 2.0 (PI)) uy)))
(if (<= ux 3.999999975690116e-8)
(*
(sqrt (fma (- ux (fma maxCos ux 1.0)) (+ (* (- maxCos 1.0) ux) 1.0) 1.0))
t_0)
(* (sqrt (- 1.0 (* (- 1.0 ux) (- 1.0 (- ux (* maxCos ux)))))) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
\mathbf{if}\;ux \leq 3.999999975690116 \cdot 10^{-8}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(ux - \mathsf{fma}\left(maxCos, ux, 1\right), \left(maxCos - 1\right) \cdot ux + 1, 1\right)} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(1 - ux\right) \cdot \left(1 - \left(ux - maxCos \cdot ux\right)\right)} \cdot t\_0\\
\end{array}
\end{array}
if ux < 3.99999998e-8Initial program 7.8%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3211.5
Applied rewrites11.5%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3211.5
Applied rewrites11.5%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lift-*.f32N/A
lift-+.f32N/A
lift--.f32N/A
lift-*.f32N/A
distribute-lft-neg-inN/A
lower-fma.f32N/A
Applied rewrites16.1%
if 3.99999998e-8 < ux Initial program 73.3%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3273.3
Applied rewrites73.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3264.4
Applied rewrites64.4%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift--.f32N/A
lower--.f3264.4
Applied rewrites64.4%
Taylor expanded in maxCos around 0
Applied rewrites63.3%
Final simplification52.3%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- 1.0 (* (- 1.0 ux) (- 1.0 (- ux (* maxCos ux)))))) (* (* 2.0 (PI)) uy)))
\begin{array}{l}
\\
\sqrt{1 - \left(1 - ux\right) \cdot \left(1 - \left(ux - maxCos \cdot ux\right)\right)} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)
\end{array}
Initial program 57.9%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3258.8
Applied rewrites58.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3252.0
Applied rewrites52.0%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift--.f32N/A
lower--.f3252.0
Applied rewrites52.0%
Taylor expanded in maxCos around 0
Applied rewrites50.3%
Final simplification50.3%
(FPCore (ux uy maxCos) :precision binary32 (* (* (* 2.0 (PI)) uy) (sqrt (- 1.0 (* (- 1.0 ux) (+ (- 1.0 ux) (* maxCos ux)))))))
\begin{array}{l}
\\
\left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot \sqrt{1 - \left(1 - ux\right) \cdot \left(\left(1 - ux\right) + maxCos \cdot ux\right)}
\end{array}
Initial program 57.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.1
Applied rewrites51.1%
Taylor expanded in maxCos around 0
lower--.f3250.3
Applied rewrites50.3%
Final simplification50.3%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- 1.0 (* 1.0 (+ (- 1.0 ux) (* maxCos ux))))) (* (* 2.0 (PI)) uy)))
\begin{array}{l}
\\
\sqrt{1 - 1 \cdot \left(\left(1 - ux\right) + maxCos \cdot ux\right)} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)
\end{array}
Initial program 57.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.1
Applied rewrites51.1%
Taylor expanded in ux around 0
Applied rewrites25.7%
Final simplification25.7%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- 1.0 (* (* (* ux ux) maxCos) maxCos))) (* (* 2.0 (PI)) uy)))
\begin{array}{l}
\\
\sqrt{1 - \left(\left(ux \cdot ux\right) \cdot maxCos\right) \cdot maxCos} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)
\end{array}
Initial program 57.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.1
Applied rewrites51.1%
Taylor expanded in maxCos around inf
unpow2N/A
associate-*r*N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f3220.6
Applied rewrites20.6%
Final simplification20.6%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (fma -2.0 maxCos 2.0) ux)) (* (* 2.0 (PI)) uy)))
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)
\end{array}
Initial program 57.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.1
Applied rewrites51.1%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3263.6
Applied rewrites63.6%
Final simplification63.6%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- 1.0 1.0)) (* (* 2.0 (PI)) uy)))
\begin{array}{l}
\\
\sqrt{1 - 1} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)
\end{array}
Initial program 57.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.1
Applied rewrites51.1%
Taylor expanded in ux around 0
Applied rewrites7.1%
Final simplification7.1%
herbie shell --seed 2024243
(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)))))))