
(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
(let* ((t_0 (sin (* (PI) (* 2.0 uy)))))
(if (<= maxCos 2.0000000233721948e-7)
(* (sqrt (* (* ux ux) (- (/ 2.0 ux) 1.0))) t_0)
(*
(sqrt
(*
(*
(-
(/ (+ (- (* (* (- 2.0 maxCos) ux) maxCos) ux) 2.0) (* maxCos maxCos))
(/ 2.0 maxCos))
(* maxCos maxCos))
ux))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\mathbf{if}\;maxCos \leq 2.0000000233721948 \cdot 10^{-7}:\\
\;\;\;\;\sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{2}{ux} - 1\right)} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(\frac{\left(\left(\left(2 - maxCos\right) \cdot ux\right) \cdot maxCos - ux\right) + 2}{maxCos \cdot maxCos} - \frac{2}{maxCos}\right) \cdot \left(maxCos \cdot maxCos\right)\right) \cdot ux} \cdot t\_0\\
\end{array}
\end{array}
if maxCos < 2.00000002e-7Initial program 59.4%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lower-+.f32N/A
lower-neg.f32N/A
lower-+.f3259.4
lift-*.f32N/A
*-commutativeN/A
lower-*.f3259.4
Applied rewrites59.4%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
associate--r+N/A
*-commutativeN/A
lower--.f32N/A
Applied rewrites19.1%
Taylor expanded in maxCos around 0
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3298.2
Applied rewrites98.2%
Taylor expanded in ux around inf
Applied rewrites98.3%
if 2.00000002e-7 < maxCos Initial program 57.5%
Taylor expanded in maxCos around -inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites56.0%
Taylor expanded in ux around 0
Applied rewrites31.7%
Taylor expanded in maxCos around 0
Applied rewrites98.5%
Final simplification98.4%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (PI) (* 2.0 uy)))))
(if (<= maxCos 2.0000000233721948e-7)
(* (sqrt (* (* ux ux) (- (/ 2.0 ux) 1.0))) t_0)
(*
(sqrt
(*
(*
(-
(/ (+ (- (* (* ux maxCos) 2.0) ux) 2.0) (* maxCos maxCos))
(/ 2.0 maxCos))
(* maxCos maxCos))
ux))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\mathbf{if}\;maxCos \leq 2.0000000233721948 \cdot 10^{-7}:\\
\;\;\;\;\sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{2}{ux} - 1\right)} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(\frac{\left(\left(ux \cdot maxCos\right) \cdot 2 - ux\right) + 2}{maxCos \cdot maxCos} - \frac{2}{maxCos}\right) \cdot \left(maxCos \cdot maxCos\right)\right) \cdot ux} \cdot t\_0\\
\end{array}
\end{array}
if maxCos < 2.00000002e-7Initial program 59.4%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lower-+.f32N/A
lower-neg.f32N/A
lower-+.f3259.4
lift-*.f32N/A
*-commutativeN/A
lower-*.f3259.4
Applied rewrites59.4%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
associate--r+N/A
*-commutativeN/A
lower--.f32N/A
Applied rewrites20.5%
Taylor expanded in maxCos around 0
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3298.2
Applied rewrites98.2%
Taylor expanded in ux around inf
Applied rewrites98.3%
if 2.00000002e-7 < maxCos Initial program 57.5%
Taylor expanded in maxCos around -inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites56.0%
Taylor expanded in ux around 0
Applied rewrites32.4%
Taylor expanded in maxCos around 0
Applied rewrites96.2%
Final simplification97.9%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (* (PI) (* 2.0 uy)))))
(if (<= maxCos 2.0000000233721948e-7)
(* (sqrt (* (* ux ux) (- (/ 2.0 ux) 1.0))) t_0)
(*
(sqrt
(*
(*
(- (/ (- 2.0 ux) (* maxCos maxCos)) (/ 2.0 maxCos))
(* maxCos maxCos))
ux))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\mathbf{if}\;maxCos \leq 2.0000000233721948 \cdot 10^{-7}:\\
\;\;\;\;\sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{2}{ux} - 1\right)} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\left(\frac{2 - ux}{maxCos \cdot maxCos} - \frac{2}{maxCos}\right) \cdot \left(maxCos \cdot maxCos\right)\right) \cdot ux} \cdot t\_0\\
\end{array}
\end{array}
if maxCos < 2.00000002e-7Initial program 59.4%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lower-+.f32N/A
lower-neg.f32N/A
lower-+.f3259.4
lift-*.f32N/A
*-commutativeN/A
lower-*.f3259.4
Applied rewrites59.4%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
associate--r+N/A
*-commutativeN/A
lower--.f32N/A
Applied rewrites19.2%
Taylor expanded in maxCos around 0
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3298.2
Applied rewrites98.2%
Taylor expanded in ux around inf
Applied rewrites98.3%
if 2.00000002e-7 < maxCos Initial program 57.5%
Taylor expanded in maxCos around -inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites56.0%
Taylor expanded in ux around 0
Applied rewrites34.1%
Taylor expanded in maxCos around 0
Applied rewrites91.5%
Final simplification97.0%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (- 1.0 ux) ux)))
(if (<= (* 2.0 uy) 0.00021149999520275742)
(*
(sqrt
(*
(- (/ (+ (* -2.0 maxCos) 2.0) ux) (pow (- maxCos 1.0) 2.0))
(* ux ux)))
(* (* (PI) 2.0) uy))
(*
(sqrt (- t_0 (- (* (fma (- 1.0 ux) ux t_0) maxCos) ux)))
(sin (* (PI) (* 2.0 uy)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) \cdot ux\\
\mathbf{if}\;2 \cdot uy \leq 0.00021149999520275742:\\
\;\;\;\;\sqrt{\left(\frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \left(ux \cdot ux\right)} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{t\_0 - \left(\mathsf{fma}\left(1 - ux, ux, t\_0\right) \cdot maxCos - ux\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 2.11499995e-4Initial program 58.0%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3258.0
Applied rewrites58.0%
Taylor expanded in ux around inf
Applied rewrites90.8%
Applied rewrites98.4%
if 2.11499995e-4 < (*.f32 uy #s(literal 2 binary32)) Initial program 60.4%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lower-+.f32N/A
lower-neg.f32N/A
lower-+.f3260.2
lift-*.f32N/A
*-commutativeN/A
lower-*.f3260.2
Applied rewrites60.2%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
associate--r+N/A
*-commutativeN/A
lower--.f32N/A
Applied rewrites18.6%
Taylor expanded in maxCos around 0
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3292.1
Applied rewrites92.1%
Taylor expanded in maxCos around 0
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
Applied rewrites80.5%
Final simplification95.9%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* 2.0 uy) 0.00021149999520275742)
(*
(sqrt
(* (- (/ (+ (* -2.0 maxCos) 2.0) ux) (pow (- maxCos 1.0) 2.0)) (* ux ux)))
(* (* (PI) 2.0) uy))
(* (sqrt (* (* ux ux) (- (/ 2.0 ux) 1.0))) (sin (* (PI) (* 2.0 uy))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.00021149999520275742:\\
\;\;\;\;\sqrt{\left(\frac{-2 \cdot maxCos + 2}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot \left(ux \cdot ux\right)} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{2}{ux} - 1\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 2.11499995e-4Initial program 58.0%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3258.0
Applied rewrites58.0%
Taylor expanded in ux around inf
Applied rewrites90.8%
Applied rewrites98.4%
if 2.11499995e-4 < (*.f32 uy #s(literal 2 binary32)) Initial program 60.4%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lower-+.f32N/A
lower-neg.f32N/A
lower-+.f3260.2
lift-*.f32N/A
*-commutativeN/A
lower-*.f3260.2
Applied rewrites60.2%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
associate--r+N/A
*-commutativeN/A
lower--.f32N/A
Applied rewrites18.5%
Taylor expanded in maxCos around 0
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3292.1
Applied rewrites92.1%
Taylor expanded in ux around inf
Applied rewrites92.3%
Final simplification95.8%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* 2.0 uy) 0.00019999999494757503)
(*
(sqrt
(-
(* (- (- (/ 2.0 ux) (/ maxCos ux)) (- 1.0 maxCos)) (* ux ux))
(* (* (fma maxCos ux (- 1.0 ux)) maxCos) ux)))
(* (* (PI) 2.0) uy))
(* (sqrt (* (* ux ux) (- (/ 2.0 ux) 1.0))) (sin (* (PI) (* 2.0 uy))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.00019999999494757503:\\
\;\;\;\;\sqrt{\left(\left(\frac{2}{ux} - \frac{maxCos}{ux}\right) - \left(1 - maxCos\right)\right) \cdot \left(ux \cdot ux\right) - \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot maxCos\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{2}{ux} - 1\right)} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 1.99999995e-4Initial program 57.6%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3257.6
Applied rewrites57.6%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
associate--r+N/A
lower--.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
Applied rewrites32.5%
lift-fma.f32N/A
*-commutativeN/A
+-commutativeN/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
*-commutativeN/A
lower--.f32N/A
lower-*.f3255.4
Applied rewrites54.6%
Taylor expanded in ux around -inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
lower-/.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
unpow2N/A
lower-*.f3297.8
Applied rewrites97.1%
if 1.99999995e-4 < (*.f32 uy #s(literal 2 binary32)) Initial program 60.9%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lower-+.f32N/A
lower-neg.f32N/A
lower-+.f3260.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3260.8
Applied rewrites60.8%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
associate--r+N/A
*-commutativeN/A
lower--.f32N/A
Applied rewrites19.9%
Taylor expanded in maxCos around 0
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3292.2
Applied rewrites92.2%
Taylor expanded in ux around inf
Applied rewrites92.4%
Final simplification88.2%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* 2.0 uy) 0.00019999999494757503)
(*
(sqrt
(-
(* (- (- (/ 2.0 ux) (/ maxCos ux)) (- 1.0 maxCos)) (* ux ux))
(* (* (fma maxCos ux (- 1.0 ux)) maxCos) ux)))
(* (* (PI) 2.0) uy))
(* (sqrt (* (- 2.0 ux) ux)) (sin (* (PI) (* 2.0 uy))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.00019999999494757503:\\
\;\;\;\;\sqrt{\left(\left(\frac{2}{ux} - \frac{maxCos}{ux}\right) - \left(1 - maxCos\right)\right) \cdot \left(ux \cdot ux\right) - \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot maxCos\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(2 - ux\right) \cdot ux} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 1.99999995e-4Initial program 57.6%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3257.6
Applied rewrites57.6%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
associate--r+N/A
lower--.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
Applied rewrites34.4%
lift-fma.f32N/A
*-commutativeN/A
+-commutativeN/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
*-commutativeN/A
lower--.f32N/A
lower-*.f3255.3
Applied rewrites54.7%
Taylor expanded in ux around -inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
lower-/.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
unpow2N/A
lower-*.f3297.8
Applied rewrites97.1%
if 1.99999995e-4 < (*.f32 uy #s(literal 2 binary32)) Initial program 60.9%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lower-+.f32N/A
lower-neg.f32N/A
lower-+.f3260.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3260.8
Applied rewrites60.8%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
associate--r+N/A
*-commutativeN/A
lower--.f32N/A
Applied rewrites19.9%
Taylor expanded in maxCos around 0
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3292.2
Applied rewrites92.2%
Taylor expanded in ux around 0
Applied rewrites92.2%
Final simplification89.4%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* 2.0 uy) 0.0024999999441206455)
(*
(sqrt
(-
(* (- (- (/ 2.0 ux) (/ maxCos ux)) (- 1.0 maxCos)) (* ux ux))
(* (* (fma maxCos ux (- 1.0 ux)) maxCos) ux)))
(* (* (PI) 2.0) uy))
(* (sqrt (* ux 2.0)) (sin (* (PI) (* 2.0 uy))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.0024999999441206455:\\
\;\;\;\;\sqrt{\left(\left(\frac{2}{ux} - \frac{maxCos}{ux}\right) - \left(1 - maxCos\right)\right) \cdot \left(ux \cdot ux\right) - \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot maxCos\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{ux \cdot 2} \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00249999994Initial program 59.5%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3259.1
Applied rewrites59.1%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
associate--r+N/A
lower--.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
Applied rewrites33.9%
lift-fma.f32N/A
*-commutativeN/A
+-commutativeN/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
*-commutativeN/A
lower--.f32N/A
lower-*.f3257.0
Applied rewrites56.3%
Taylor expanded in ux around -inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
lower-/.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
unpow2N/A
lower-*.f3295.5
Applied rewrites95.5%
if 0.00249999994 < (*.f32 uy #s(literal 2 binary32)) Initial program 57.8%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lower-+.f32N/A
lower-neg.f32N/A
lower-+.f3257.7
lift-*.f32N/A
*-commutativeN/A
lower-*.f3257.7
Applied rewrites57.7%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
associate--r+N/A
*-commutativeN/A
lower--.f32N/A
Applied rewrites10.4%
Taylor expanded in maxCos around 0
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3290.6
Applied rewrites90.6%
Taylor expanded in ux around 0
Applied rewrites73.3%
Final simplification80.4%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sqrt
(-
(* (- (- (/ 2.0 ux) (/ maxCos ux)) (- 1.0 maxCos)) (* ux ux))
(* (* (fma maxCos ux (- 1.0 ux)) maxCos) ux)))
(* (* (PI) 2.0) uy)))\begin{array}{l}
\\
\sqrt{\left(\left(\frac{2}{ux} - \frac{maxCos}{ux}\right) - \left(1 - maxCos\right)\right) \cdot \left(ux \cdot ux\right) - \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot maxCos\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\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.5
Applied rewrites51.5%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
associate--r+N/A
lower--.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
Applied rewrites35.6%
lift-fma.f32N/A
*-commutativeN/A
+-commutativeN/A
lift--.f32N/A
associate-+l-N/A
lower--.f32N/A
*-commutativeN/A
lower--.f32N/A
lower-*.f3249.5
Applied rewrites49.5%
Taylor expanded in ux around -inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
lower-/.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
unpow2N/A
lower-*.f3280.2
Applied rewrites80.2%
Final simplification80.0%
(FPCore (ux uy maxCos)
:precision binary32
(*
(sqrt
(-
(* (- (/ 2.0 ux) (- (/ maxCos ux) (- maxCos 1.0))) (* ux ux))
(* (* (fma maxCos ux (- 1.0 ux)) maxCos) ux)))
(* (* (PI) 2.0) uy)))\begin{array}{l}
\\
\sqrt{\left(\frac{2}{ux} - \left(\frac{maxCos}{ux} - \left(maxCos - 1\right)\right)\right) \cdot \left(ux \cdot ux\right) - \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot maxCos\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\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.5
Applied rewrites51.5%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
associate--r+N/A
lower--.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
Applied rewrites34.4%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f32N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f3280.2
Applied rewrites79.8%
Final simplification80.2%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (* ux ux) (- (/ 2.0 ux) 1.0))) (* (* (PI) 2.0) uy)))
\begin{array}{l}
\\
\sqrt{\left(ux \cdot ux\right) \cdot \left(\frac{2}{ux} - 1\right)} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\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.5
Applied rewrites51.5%
Taylor expanded in ux around inf
Applied rewrites75.8%
Taylor expanded in maxCos around 0
Applied rewrites76.2%
Final simplification76.2%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (+ (* (- 1.0 ux) ux) ux)) (* (* (PI) uy) 2.0)))
\begin{array}{l}
\\
\sqrt{\left(1 - ux\right) \cdot ux + ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)
\end{array}
Initial program 59.0%
lift-+.f32N/A
lift--.f32N/A
sub-negN/A
+-commutativeN/A
associate-+l+N/A
lower-+.f32N/A
lower-neg.f32N/A
lower-+.f3258.9
lift-*.f32N/A
*-commutativeN/A
lower-*.f3258.9
Applied rewrites58.9%
lift--.f32N/A
lift-*.f32N/A
lift-+.f32N/A
distribute-lft-inN/A
associate--r+N/A
*-commutativeN/A
lower--.f32N/A
Applied rewrites19.3%
Taylor expanded in maxCos around 0
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3291.7
Applied rewrites91.7%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3276.1
Applied rewrites76.1%
Final simplification76.1%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (* (fma -2.0 maxCos 2.0) ux)) (* (* (PI) 2.0) uy)))
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\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.5
Applied rewrites51.5%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3262.2
Applied rewrites62.0%
Final simplification62.2%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (fma -1.0 1.0 1.0)) (* (* (PI) 2.0) uy)))
\begin{array}{l}
\\
\sqrt{\mathsf{fma}\left(-1, 1, 1\right)} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\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.5
Applied rewrites51.5%
Taylor expanded in ux around 0
Applied rewrites7.1%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
neg-mul-1N/A
metadata-evalN/A
lower-fma.f32N/A
metadata-eval18.1
Applied rewrites20.1%
Final simplification19.2%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (- 1.0 1.0)) (* (* (PI) 2.0) uy)))
\begin{array}{l}
\\
\sqrt{1 - 1} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\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.5
Applied rewrites51.5%
Taylor expanded in ux around 0
Applied rewrites7.1%
Final simplification7.1%
herbie shell --seed 2024270
(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)))))))