
(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 15 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 uy) (PI))) (sqrt (fma (- (* (fma (- maxCos 2.0) ux 2.0) ux)) maxCos (* (- 2.0 ux) ux)))))
\begin{array}{l}
\\
\sin \left(\left(uy + uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-\mathsf{fma}\left(maxCos - 2, ux, 2\right) \cdot ux, maxCos, \left(2 - ux\right) \cdot ux\right)}
\end{array}
Initial program 56.7%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.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--.f3298.4
Applied rewrites98.4%
Taylor expanded in maxCos around 0
Applied rewrites98.4%
Taylor expanded in ux around 0
Applied rewrites98.4%
lift-*.f32N/A
*-commutativeN/A
count-2-revN/A
lower-+.f3298.4
Applied rewrites98.4%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* (* uy 2.0) (PI))) (sqrt (fma (- (* (fma -2.0 ux 2.0) ux)) maxCos (* (- 2.0 ux) ux)))))
\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-\mathsf{fma}\left(-2, ux, 2\right) \cdot ux, maxCos, \left(2 - ux\right) \cdot ux\right)}
\end{array}
Initial program 56.7%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.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--.f3298.4
Applied rewrites98.4%
Taylor expanded in maxCos around 0
Applied rewrites98.4%
Taylor expanded in maxCos around 0
Applied rewrites98.1%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* (* uy 2.0) (PI))) (sqrt (- (* (- 2.0 ux) ux) (* (* maxCos ux) (fma -2.0 ux 2.0))))))
\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 - ux\right) \cdot ux - \left(maxCos \cdot ux\right) \cdot \mathsf{fma}\left(-2, ux, 2\right)}
\end{array}
Initial program 56.7%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.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--.f3298.4
Applied rewrites98.4%
Taylor expanded in maxCos around 0
Applied rewrites98.1%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= maxCos 7.999999797903001e-5)
(* (sin (* (* uy 2.0) (PI))) (sqrt (* (- 2.0 ux) ux)))
(*
(sqrt (* (- (- 1.0 (- maxCos 1.0)) maxCos) ux))
(sin (* (* (PI) uy) 2.0)))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 7.999999797903001 \cdot 10^{-5}:\\
\;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 - ux\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(1 - \left(maxCos - 1\right)\right) - maxCos\right) \cdot ux} \cdot \sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\\
\end{array}
\end{array}
if maxCos < 7.9999998e-5Initial program 59.0%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.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--.f3298.5
Applied rewrites98.5%
Taylor expanded in maxCos around 0
Applied rewrites97.7%
if 7.9999998e-5 < maxCos Initial program 40.0%
lift--.f32N/A
lift-*.f32N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-neg.f3240.1
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f3240.1
Applied rewrites40.1%
lift-*.f32N/A
lift-PI.f32N/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f32N/A
lower-sqrt.f32N/A
lift-PI.f32N/A
lower-sqrt.f3240.1
Applied rewrites40.1%
Taylor expanded in ux around 0
lower-*.f32N/A
lower-sqrt.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f32N/A
lower--.f32N/A
count-2-revN/A
distribute-lft-inN/A
count-2-revN/A
lower-sin.f32N/A
count-2-revN/A
distribute-lft-inN/A
count-2-revN/A
Applied rewrites86.7%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* (* uy 2.0) (PI))) (sqrt (fma (* -2.0 ux) maxCos (* (- 2.0 ux) ux)))))
\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2 \cdot ux, maxCos, \left(2 - ux\right) \cdot ux\right)}
\end{array}
Initial program 56.7%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.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--.f3298.4
Applied rewrites98.4%
Taylor expanded in maxCos around 0
Applied rewrites98.4%
Taylor expanded in ux around 0
Applied rewrites97.5%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (* uy 2.0) (PI)))))
(if (<= maxCos 7.999999797903001e-5)
(* t_0 (sqrt (* (- 2.0 ux) ux)))
(* t_0 (sqrt (* (fma -2.0 maxCos 2.0) ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right)\\
\mathbf{if}\;maxCos \leq 7.999999797903001 \cdot 10^{-5}:\\
\;\;\;\;t\_0 \cdot \sqrt{\left(2 - ux\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\\
\end{array}
\end{array}
if maxCos < 7.9999998e-5Initial program 59.0%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.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--.f3298.5
Applied rewrites98.5%
Taylor expanded in maxCos around 0
Applied rewrites97.7%
if 7.9999998e-5 < maxCos Initial program 40.0%
Taylor expanded in ux around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3286.6
Applied rewrites86.6%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (- 2.0 ux) ux)))
(if (<= uy 0.00011000000085914508)
(*
(* (* 2.0 uy) (PI))
(sqrt (fma (- (* (fma (- maxCos 2.0) ux 2.0) ux)) maxCos t_0)))
(* (sin (* (* uy 2.0) (PI))) (sqrt t_0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 - ux\right) \cdot ux\\
\mathbf{if}\;uy \leq 0.00011000000085914508:\\
\;\;\;\;\left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-\mathsf{fma}\left(maxCos - 2, ux, 2\right) \cdot ux, maxCos, t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{t\_0}\\
\end{array}
\end{array}
if uy < 1.10000001e-4Initial program 56.5%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.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--.f3298.7
Applied rewrites98.7%
Taylor expanded in maxCos around 0
Applied rewrites98.7%
Taylor expanded in ux around 0
Applied rewrites98.7%
Taylor expanded in uy around 0
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3298.7
Applied rewrites98.7%
if 1.10000001e-4 < uy Initial program 56.9%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.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--.f3297.9
Applied rewrites97.9%
Taylor expanded in maxCos around 0
Applied rewrites91.5%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (fma maxCos ux (- 1.0 ux))) (t_1 (+ (- 1.0 ux) (* ux maxCos))))
(if (<= (* t_1 t_1) 0.999750018119812)
(* (* (* (PI) 2.0) uy) (sqrt (fma t_0 (- t_0) 1.0)))
(* (* (+ (PI) (PI)) uy) (sqrt (* (fma -2.0 maxCos 2.0) ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(maxCos, ux, 1 - ux\right)\\
t_1 := \left(1 - ux\right) + ux \cdot maxCos\\
\mathbf{if}\;t\_1 \cdot t\_1 \leq 0.999750018119812:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(t\_0, -t\_0, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\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.999750018Initial program 89.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3276.4
Applied rewrites76.4%
lift--.f32N/A
lift-*.f32N/A
fp-cancel-sub-sign-invN/A
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f32N/A
lift-neg.f32N/A
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f3276.4
Applied rewrites76.4%
if 0.999750018 < (*.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.f3235.1
Applied rewrites35.1%
Taylor expanded in ux around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3281.3
Applied rewrites81.3%
Applied rewrites81.3%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))) (t_1 (fma maxCos ux (- 1.0 ux))))
(if (<= (* t_0 t_0) 0.9996200203895569)
(* (* (* (PI) 2.0) uy) (sqrt (- 1.0 (* t_1 t_1))))
(* (* (+ (PI) (PI)) uy) (sqrt (* (fma -2.0 maxCos 2.0) ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
t_1 := \mathsf{fma}\left(maxCos, ux, 1 - ux\right)\\
\mathbf{if}\;t\_0 \cdot t\_0 \leq 0.9996200203895569:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{1 - t\_1 \cdot t\_1}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\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.99962002Initial program 89.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3276.5
Applied rewrites76.5%
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f3276.5
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f3276.5
Applied rewrites76.5%
if 0.99962002 < (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))) Initial program 36.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3235.8
Applied rewrites35.8%
Taylor expanded in ux around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3281.1
Applied rewrites81.1%
Applied rewrites81.1%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
(if (<= (* t_0 t_0) 0.999750018119812)
(*
(* (* 2.0 uy) (PI))
(sqrt (fma (- ux (fma maxCos ux 1.0)) (- (fma maxCos ux 1.0) ux) 1.0)))
(* (* (+ (PI) (PI)) uy) (sqrt (* (fma -2.0 maxCos 2.0) 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.999750018119812:\\
\;\;\;\;\left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(ux - \mathsf{fma}\left(maxCos, ux, 1\right), \mathsf{fma}\left(maxCos, ux, 1\right) - ux, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\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.999750018Initial program 89.3%
lift--.f32N/A
lift-*.f32N/A
fp-cancel-sub-sign-invN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
lower-neg.f3289.3
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f3289.3
Applied rewrites89.3%
Taylor expanded in uy around 0
associate-*r*N/A
count-2-revN/A
distribute-lft-inN/A
count-2-revN/A
lower-*.f32N/A
count-2-revN/A
distribute-lft-inN/A
count-2-revN/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
+-commutativeN/A
lower-fma.f32N/A
Applied rewrites76.3%
if 0.999750018 < (*.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.f3235.1
Applied rewrites35.1%
Taylor expanded in ux around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3281.3
Applied rewrites81.3%
Applied rewrites81.3%
Final simplification79.4%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.00018000000272877514)
(* (* (+ (PI) (PI)) uy) (sqrt (* (fma -2.0 maxCos 2.0) ux)))
(*
(* (* (PI) 2.0) uy)
(sqrt
(- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (fma (- maxCos 1.0) ux 1.0)))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00018000000272877514:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \mathsf{fma}\left(maxCos - 1, ux, 1\right)}\\
\end{array}
\end{array}
if ux < 1.80000003e-4Initial program 36.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3235.8
Applied rewrites35.8%
Taylor expanded in ux around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3281.1
Applied rewrites81.1%
Applied rewrites81.1%
if 1.80000003e-4 < ux Initial program 89.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3276.5
Applied rewrites76.5%
Taylor expanded in ux around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower--.f3276.7
Applied rewrites76.7%
(FPCore (ux uy maxCos) :precision binary32 (* (* (* 2.0 uy) (PI)) (sqrt (fma (- (* (fma (- maxCos 2.0) ux 2.0) ux)) maxCos (* (- 2.0 ux) ux)))))
\begin{array}{l}
\\
\left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-\mathsf{fma}\left(maxCos - 2, ux, 2\right) \cdot ux, maxCos, \left(2 - ux\right) \cdot ux\right)}
\end{array}
Initial program 56.7%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.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--.f3298.4
Applied rewrites98.4%
Taylor expanded in maxCos around 0
Applied rewrites98.4%
Taylor expanded in ux around 0
Applied rewrites98.4%
Taylor expanded in uy around 0
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3284.3
Applied rewrites84.3%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.00018000000272877514)
(* (* (+ (PI) (PI)) uy) (sqrt (* (fma -2.0 maxCos 2.0) ux)))
(*
(* (* (PI) 2.0) uy)
(sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (- 1.0 ux)))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.00018000000272877514:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(1 - ux\right)}\\
\end{array}
\end{array}
if ux < 1.80000003e-4Initial program 36.7%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3235.8
Applied rewrites35.8%
Taylor expanded in ux around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3281.1
Applied rewrites81.1%
Applied rewrites81.1%
if 1.80000003e-4 < ux Initial program 89.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3276.5
Applied rewrites76.5%
Taylor expanded in maxCos around 0
lower--.f3275.3
Applied rewrites75.3%
(FPCore (ux uy maxCos) :precision binary32 (* (* (+ (PI) (PI)) uy) (sqrt (* (fma -2.0 maxCos 2.0) ux))))
\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}
\end{array}
Initial program 56.7%
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
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3268.9
Applied rewrites68.9%
Applied rewrites68.9%
(FPCore (ux uy maxCos) :precision binary32 (* (* (* (PI) 2.0) uy) (sqrt (- 1.0 1.0))))
\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{1 - 1}
\end{array}
Initial program 56.7%
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%
unpow1N/A
metadata-evalN/A
sqrt-pow1N/A
pow2N/A
sqrt-prodN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f32N/A
lower-sqrt.f3250.2
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f3250.2
Applied rewrites50.2%
Applied rewrites50.4%
Taylor expanded in ux around 0
Applied rewrites7.1%
herbie shell --seed 2024364
(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)))))))