
(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 16 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
(*
(sin (* (* uy 2.0) (PI)))
(sqrt
(*
(- (* (- (/ (- 2.0 maxCos) ux) (pow (- maxCos 1.0) 2.0)) ux) maxCos)
ux))))\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(\frac{2 - maxCos}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot ux - maxCos\right) \cdot ux}
\end{array}
Initial program 59.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3259.6
Applied rewrites59.6%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
lower-*.f3298.1
Applied rewrites98.1%
Applied rewrites98.1%
Taylor expanded in ux around inf
Applied rewrites98.2%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* (* uy 2.0) (PI))) (sqrt (* (- (- (- 2.0 (* ux (pow (- maxCos 1.0) 2.0))) maxCos) maxCos) ux))))
\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(\left(2 - ux \cdot {\left(maxCos - 1\right)}^{2}\right) - maxCos\right) - maxCos\right) \cdot ux}
\end{array}
Initial program 59.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3259.6
Applied rewrites59.6%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
lower-*.f3298.1
Applied rewrites98.1%
Applied rewrites98.1%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))) (t_1 (sqrt (- 1.0 (* t_0 t_0)))))
(if (<= (* (sin (* (* uy 2.0) (PI))) t_1) 9.999999747378752e-5)
(*
(* (* (PI) 2.0) uy)
(sqrt
(*
(-
(/ 2.0 ux)
(fma (/ maxCos ux) 2.0 (* (- maxCos 1.0) (- maxCos 1.0))))
(* ux ux))))
(*
(*
(*
2.0
(+ (PI) (* (* (* (* (PI) (PI)) (PI)) -0.6666666666666666) (* uy uy))))
uy)
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
\mathbf{if}\;\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot t\_1 \leq 9.999999747378752 \cdot 10^{-5}:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(\frac{2}{ux} - \mathsf{fma}\left(\frac{maxCos}{ux}, 2, \left(maxCos - 1\right) \cdot \left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot ux\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(2 \cdot \left(\mathsf{PI}\left(\right) + \left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \mathsf{PI}\left(\right)\right) \cdot -0.6666666666666666\right) \cdot \left(uy \cdot uy\right)\right)\right) \cdot uy\right) \cdot t\_1\\
\end{array}
\end{array}
if (*.f32 (sin.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) (sqrt.f32 (-.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)))))) < 9.99999975e-5Initial program 52.5%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3249.2
Applied rewrites49.2%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
lift-*.f32N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift-*.f32N/A
lift-fma.f32N/A
*-commutativeN/A
lower-*.f3248.9
Applied rewrites47.7%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites84.9%
if 9.99999975e-5 < (*.f32 (sin.f32 (*.f32 (*.f32 uy #s(literal 2 binary32)) (PI.f32))) (sqrt.f32 (-.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 79.9%
lift-sin.f32N/A
lift-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*l*N/A
sin-2N/A
lower-*.f32N/A
lower-*.f32N/A
lower-sin.f32N/A
lower-*.f32N/A
lower-cos.f32N/A
lower-*.f3280.0
Applied rewrites80.0%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites68.5%
Applied rewrites68.5%
Final simplification81.2%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* (* uy 2.0) (PI))) (sqrt (* (- (- (- 2.0 (* (fma -2.0 ux 1.0) maxCos)) ux) maxCos) ux))))
\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(\left(2 - \mathsf{fma}\left(-2, ux, 1\right) \cdot maxCos\right) - ux\right) - maxCos\right) \cdot ux}
\end{array}
Initial program 59.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3259.6
Applied rewrites59.6%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
lower-*.f3298.1
Applied rewrites98.1%
Applied rewrites98.1%
Taylor expanded in maxCos around 0
Applied rewrites85.7%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* (* uy 2.0) (PI))) (sqrt (* (- (- 2.0 (* (fma -2.0 ux 2.0) maxCos)) ux) ux))))
\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(2 - \mathsf{fma}\left(-2, ux, 2\right) \cdot maxCos\right) - ux\right) \cdot ux}
\end{array}
Initial program 59.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3259.6
Applied rewrites59.6%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
lower-*.f3298.1
Applied rewrites98.1%
Taylor expanded in maxCos around 0
Applied rewrites85.4%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* (* uy 2.0) (PI))) (sqrt (* (- (- 2.0 ux) maxCos) ux))))
\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(2 - ux\right) - maxCos\right) \cdot ux}
\end{array}
Initial program 59.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3259.6
Applied rewrites59.6%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
lower-*.f3298.1
Applied rewrites98.1%
Applied rewrites98.1%
Taylor expanded in maxCos around 0
Applied rewrites93.4%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* (* uy 2.0) (PI))) (sqrt (* (- 2.0 ux) ux))))
\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 - ux\right) \cdot ux}
\end{array}
Initial program 59.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3259.6
Applied rewrites59.6%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
associate-*r*N/A
mul-1-negN/A
fp-cancel-sub-signN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
lower-*.f3298.1
Applied rewrites98.1%
Taylor expanded in maxCos around 0
Applied rewrites92.9%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)) (t_1 (+ (- 1.0 ux) (* ux maxCos))))
(if (<= (sqrt (- 1.0 (* t_1 t_1))) 0.04050000011920929)
(* t_0 (sqrt (* (- 2.0 (* 2.0 maxCos)) ux)))
(* t_0 (sqrt (- 1.0 (* t_1 (- 1.0 ux))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
t_1 := \left(1 - ux\right) + ux \cdot maxCos\\
\mathbf{if}\;\sqrt{1 - t\_1 \cdot t\_1} \leq 0.04050000011920929:\\
\;\;\;\;t\_0 \cdot \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{1 - t\_1 \cdot \left(1 - ux\right)}\\
\end{array}
\end{array}
if (sqrt.f32 (-.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))))) < 0.0405000001Initial program 40.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3237.1
Applied rewrites37.1%
Taylor expanded in maxCos around 0
lower--.f3236.1
Applied rewrites36.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f3273.4
Applied rewrites73.1%
Applied rewrites76.8%
if 0.0405000001 < (sqrt.f32 (-.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 92.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3276.0
Applied rewrites76.0%
Taylor expanded in maxCos around 0
lower--.f3275.0
Applied rewrites75.0%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))) (t_1 (* (* (PI) 2.0) uy)))
(if (<= (* t_0 t_0) 0.9997000098228455)
(* t_1 (sqrt (- 1.0 (* (- 1.0 (- ux (* maxCos ux))) t_0))))
(* t_1 (sqrt (* (* (- (/ 2.0 maxCos) 2.0) maxCos) ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
t_1 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
\mathbf{if}\;t\_0 \cdot t\_0 \leq 0.9997000098228455:\\
\;\;\;\;t\_1 \cdot \sqrt{1 - \left(1 - \left(ux - maxCos \cdot ux\right)\right) \cdot t\_0}\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \sqrt{\left(\left(\frac{2}{maxCos} - 2\right) \cdot maxCos\right) \cdot ux}\\
\end{array}
\end{array}
if (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))) < 0.99970001Initial program 89.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3275.0
Applied rewrites75.0%
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
lift--.f32N/A
lower--.f3275.1
Applied rewrites75.1%
if 0.99970001 < (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))) Initial program 36.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3233.3
Applied rewrites33.3%
Taylor expanded in maxCos around 0
lower--.f3233.1
Applied rewrites33.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f3275.1
Applied rewrites56.1%
Taylor expanded in maxCos around inf
Applied rewrites78.3%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)) (t_1 (+ (- 1.0 ux) (* ux maxCos))))
(if (<= (sqrt (- 1.0 (* t_1 t_1))) 0.04050000011920929)
(* t_0 (sqrt (* (- 2.0 (* 2.0 maxCos)) ux)))
(* t_0 (sqrt (- 1.0 (* (- 1.0 ux) (- 1.0 ux))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
t_1 := \left(1 - ux\right) + ux \cdot maxCos\\
\mathbf{if}\;\sqrt{1 - t\_1 \cdot t\_1} \leq 0.04050000011920929:\\
\;\;\;\;t\_0 \cdot \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{1 - \left(1 - ux\right) \cdot \left(1 - ux\right)}\\
\end{array}
\end{array}
if (sqrt.f32 (-.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))))) < 0.0405000001Initial program 40.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3237.1
Applied rewrites37.1%
Taylor expanded in maxCos around 0
lower--.f3236.1
Applied rewrites36.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f3273.4
Applied rewrites73.4%
Applied rewrites76.8%
if 0.0405000001 < (sqrt.f32 (-.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 92.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3276.0
Applied rewrites76.0%
Taylor expanded in maxCos around 0
lower--.f3275.0
Applied rewrites75.0%
Taylor expanded in maxCos around 0
lower--.f3274.7
Applied rewrites74.7%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
(if (<= (* t_0 t_0) 0.9983500242233276)
(*
(* (* (PI) uy) 2.0)
(sqrt (- 1.0 (* (- (- ux (* maxCos ux)) 1.0) (- ux 1.0)))))
(* (* (* (PI) 2.0) uy) (sqrt (* (* (- (/ 2.0 maxCos) 2.0) maxCos) ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\mathbf{if}\;t\_0 \cdot t\_0 \leq 0.9983500242233276:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot \sqrt{1 - \left(\left(ux - maxCos \cdot ux\right) - 1\right) \cdot \left(ux - 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(\left(\frac{2}{maxCos} - 2\right) \cdot maxCos\right) \cdot ux}\\
\end{array}
\end{array}
if (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))) < 0.998350024Initial program 92.7%
lift-*.f32N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
fabs-subN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
fabs-subN/A
Applied rewrites93.0%
Taylor expanded in maxCos around 0
lower--.f3290.4
Applied rewrites90.4%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3275.0
Applied rewrites75.0%
if 0.998350024 < (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))) Initial program 40.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3237.1
Applied rewrites37.1%
Taylor expanded in maxCos around 0
lower--.f3236.1
Applied rewrites36.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f3273.4
Applied rewrites73.4%
Taylor expanded in maxCos around inf
Applied rewrites76.8%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
(if (<= (* t_0 t_0) 0.9983500242233276)
(*
(* (* (PI) uy) 2.0)
(sqrt (- 1.0 (* (- (- ux (* maxCos ux)) 1.0) (- ux 1.0)))))
(* (* (* (PI) 2.0) uy) (sqrt (* (- 2.0 (* 2.0 maxCos)) ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\mathbf{if}\;t\_0 \cdot t\_0 \leq 0.9983500242233276:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot \sqrt{1 - \left(\left(ux - maxCos \cdot ux\right) - 1\right) \cdot \left(ux - 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux}\\
\end{array}
\end{array}
if (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))) < 0.998350024Initial program 92.7%
lift-*.f32N/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
fabs-subN/A
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
rem-sqrt-square-revN/A
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
fabs-subN/A
Applied rewrites93.0%
Taylor expanded in maxCos around 0
lower--.f3290.4
Applied rewrites90.4%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3275.0
Applied rewrites75.0%
if 0.998350024 < (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))) Initial program 40.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3237.1
Applied rewrites37.1%
Taylor expanded in maxCos around 0
lower--.f3236.1
Applied rewrites36.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f3273.4
Applied rewrites73.1%
Applied rewrites76.8%
(FPCore (ux uy maxCos)
:precision binary32
(*
(* (* (PI) 2.0) uy)
(sqrt
(*
(- (/ 2.0 ux) (fma (/ maxCos ux) 2.0 (* (- maxCos 1.0) (- maxCos 1.0))))
(* ux ux)))))\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(\frac{2}{ux} - \mathsf{fma}\left(\frac{maxCos}{ux}, 2, \left(maxCos - 1\right) \cdot \left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot ux\right)}
\end{array}
Initial program 59.0%
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%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
distribute-rgt-inN/A
lift-*.f32N/A
*-commutativeN/A
associate-*l*N/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift-*.f32N/A
lift-fma.f32N/A
*-commutativeN/A
lower-*.f3250.1
Applied rewrites47.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites77.6%
Final simplification77.8%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)) (t_1 (+ (- 1.0 ux) (* ux maxCos))))
(if (<= ux 0.0001500000071246177)
(* t_0 (sqrt (* (* (- (/ 2.0 maxCos) 2.0) maxCos) ux)))
(* t_0 (sqrt (- 1.0 (* t_1 t_1)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
t_1 := \left(1 - ux\right) + ux \cdot maxCos\\
\mathbf{if}\;ux \leq 0.0001500000071246177:\\
\;\;\;\;t\_0 \cdot \sqrt{\left(\left(\frac{2}{maxCos} - 2\right) \cdot maxCos\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{1 - t\_1 \cdot t\_1}\\
\end{array}
\end{array}
if ux < 1.50000007e-4Initial program 36.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3233.3
Applied rewrites33.3%
Taylor expanded in maxCos around 0
lower--.f3233.1
Applied rewrites33.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f3275.1
Applied rewrites66.3%
Taylor expanded in maxCos around inf
Applied rewrites78.3%
if 1.50000007e-4 < ux Initial program 89.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3275.0
Applied rewrites75.0%
(FPCore (ux uy maxCos) :precision binary32 (* (* (* (PI) 2.0) uy) (sqrt (* (- 2.0 (* 2.0 maxCos)) ux))))
\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(2 - 2 \cdot maxCos\right) \cdot ux}
\end{array}
Initial program 59.0%
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.1
Applied rewrites50.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f3262.6
Applied rewrites62.5%
Applied rewrites64.8%
(FPCore (ux uy maxCos) :precision binary32 (* (* (* (PI) 2.0) uy) (sqrt (* 2.0 ux))))
\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{2 \cdot ux}
\end{array}
Initial program 59.0%
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.1
Applied rewrites50.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
+-commutativeN/A
lower-fma.f3262.6
Applied rewrites62.5%
Taylor expanded in maxCos around 0
Applied rewrites62.6%
herbie shell --seed 2024346
(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)))))))