
(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 14 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 2.0)) ux) (pow (- maxCos 1.0) 2.0)) ux) ux))))
\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(\frac{2 - maxCos \cdot 2}{ux} - {\left(maxCos - 1\right)}^{2}\right) \cdot ux\right) \cdot ux}
\end{array}
Initial program 59.4%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3260.4
Applied rewrites60.4%
Taylor expanded in ux around inf
Applied rewrites18.0%
Applied rewrites98.1%
Final simplification98.1%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= maxCos 1.9999999494757503e-5)
(*
(sin (* (* uy 2.0) (PI)))
(sqrt (* (- (fma -2.0 maxCos 2.0) (* (pow (- maxCos 1.0) 2.0) ux)) ux)))
(*
(* (* (PI) 2.0) uy)
(sqrt
(*
(*
(-
(+ (/ 2.0 (* (* maxCos maxCos) ux)) (/ 2.0 maxCos))
(+ (+ (/ 1.0 (* maxCos maxCos)) 1.0) (/ (/ 2.0 maxCos) ux)))
(* maxCos maxCos))
(* ux ux))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;maxCos \leq 1.9999999494757503 \cdot 10^{-5}:\\
\;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{fma}\left(-2, maxCos, 2\right) - {\left(maxCos - 1\right)}^{2} \cdot ux\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(\left(\left(\frac{2}{\left(maxCos \cdot maxCos\right) \cdot ux} + \frac{2}{maxCos}\right) - \left(\left(\frac{1}{maxCos \cdot maxCos} + 1\right) + \frac{\frac{2}{maxCos}}{ux}\right)\right) \cdot \left(maxCos \cdot maxCos\right)\right) \cdot \left(ux \cdot ux\right)}\\
\end{array}
\end{array}
if maxCos < 1.99999995e-5Initial program 58.3%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3259.2
Applied rewrites59.2%
Taylor expanded in ux around inf
Applied rewrites21.0%
Taylor expanded in ux around 0
Applied rewrites19.7%
if 1.99999995e-5 < maxCos Initial program 68.0%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3262.6
Applied rewrites62.6%
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
*-commutativeN/A
lower-*.f3245.9
Applied rewrites38.1%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites49.9%
Taylor expanded in maxCos around inf
Applied rewrites84.3%
Final simplification31.0%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* uy 2.0) 0.0004199999966658652)
(*
(* (* (PI) 2.0) uy)
(sqrt
(*
(-
(/ 2.0 ux)
(- (* (+ -1.0 maxCos) (- maxCos 1.0)) (* -2.0 (/ maxCos ux))))
(* ux ux))))
(* (sin (* (* uy 2.0) (PI))) (sqrt (* (* (- (/ 2.0 ux) 1.0) ux) ux)))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \cdot 2 \leq 0.0004199999966658652:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(\frac{2}{ux} - \left(\left(-1 + maxCos\right) \cdot \left(maxCos - 1\right) - -2 \cdot \frac{maxCos}{ux}\right)\right) \cdot \left(ux \cdot ux\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\left(\frac{2}{ux} - 1\right) \cdot ux\right) \cdot ux}\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 4.19999997e-4Initial program 58.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3258.7
Applied rewrites58.7%
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
*-commutativeN/A
lower-*.f3255.9
Applied rewrites54.5%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites92.5%
Applied rewrites98.2%
if 4.19999997e-4 < (*.f32 uy #s(literal 2 binary32)) Initial program 60.4%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3260.9
Applied rewrites60.9%
Taylor expanded in ux around inf
Applied rewrites21.6%
Taylor expanded in maxCos around 0
Applied rewrites92.6%
Final simplification96.0%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* uy 2.0) 0.0013599999947473407)
(*
(* (* (PI) 2.0) uy)
(sqrt
(*
(-
(/ 2.0 ux)
(- (* (+ -1.0 maxCos) (- maxCos 1.0)) (* -2.0 (/ maxCos ux))))
(* ux ux))))
(* (* (sqrt 2.0) (sin (* (* (PI) uy) 2.0))) (sqrt (* (- 1.0 maxCos) ux)))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \cdot 2 \leq 0.0013599999947473407:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(\frac{2}{ux} - \left(\left(-1 + maxCos\right) \cdot \left(maxCos - 1\right) - -2 \cdot \frac{maxCos}{ux}\right)\right) \cdot \left(ux \cdot ux\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\sqrt{2} \cdot \sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot ux}\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00135999999Initial program 59.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3259.5
Applied rewrites59.5%
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
*-commutativeN/A
lower-*.f3256.9
Applied rewrites56.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites91.9%
Applied rewrites97.5%
if 0.00135999999 < (*.f32 uy #s(literal 2 binary32)) Initial program 58.7%
lift-*.f32N/A
sqr-abs-revN/A
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
fabs-subN/A
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
fabs-subN/A
sqr-absN/A
lower-*.f32N/A
lower--.f32N/A
lower--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/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
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-*.f32N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f3276.8
Applied rewrites76.8%
Final simplification90.4%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= (* uy 2.0) 0.0013599999947473407)
(*
(* (* (PI) 2.0) uy)
(sqrt
(*
(-
(/ 2.0 ux)
(- (* (+ -1.0 maxCos) (- maxCos 1.0)) (* -2.0 (/ maxCos ux))))
(* ux ux))))
(* (sin (* (* uy 2.0) (PI))) (sqrt (* ux (* 2.0 (- 1.0 maxCos)))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \cdot 2 \leq 0.0013599999947473407:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(\frac{2}{ux} - \left(\left(-1 + maxCos\right) \cdot \left(maxCos - 1\right) - -2 \cdot \frac{maxCos}{ux}\right)\right) \cdot \left(ux \cdot ux\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{ux \cdot \left(2 \cdot \left(1 - maxCos\right)\right)}\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00135999999Initial program 59.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3259.5
Applied rewrites59.5%
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
*-commutativeN/A
lower-*.f3256.9
Applied rewrites56.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites91.9%
Applied rewrites97.5%
if 0.00135999999 < (*.f32 uy #s(literal 2 binary32)) Initial program 58.7%
lift-*.f32N/A
sqr-abs-revN/A
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
fabs-subN/A
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
fabs-subN/A
sqr-absN/A
lower-*.f32N/A
lower--.f32N/A
lower--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower--.f3258.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3258.8
Applied rewrites58.8%
Taylor expanded in ux around 0
count-2-revN/A
distribute-lft-outN/A
count-2-revN/A
metadata-evalN/A
lower-*.f32N/A
metadata-evalN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-*.f32N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f3276.7
Applied rewrites76.7%
Final simplification90.3%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)))
(if (<= (* uy 2.0) 0.0013599999947473407)
(*
t_0
(sqrt
(*
(-
(/ 2.0 ux)
(- (* (+ -1.0 maxCos) (- maxCos 1.0)) (* -2.0 (/ maxCos ux))))
(* ux ux))))
(* (sin t_0) (sqrt (* (fma -2.0 maxCos 2.0) ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
\mathbf{if}\;uy \cdot 2 \leq 0.0013599999947473407:\\
\;\;\;\;t\_0 \cdot \sqrt{\left(\frac{2}{ux} - \left(\left(-1 + maxCos\right) \cdot \left(maxCos - 1\right) - -2 \cdot \frac{maxCos}{ux}\right)\right) \cdot \left(ux \cdot ux\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin t\_0 \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00135999999Initial program 59.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3259.5
Applied rewrites59.5%
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
*-commutativeN/A
lower-*.f3256.9
Applied rewrites55.2%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites91.9%
Applied rewrites97.5%
if 0.00135999999 < (*.f32 uy #s(literal 2 binary32)) Initial program 58.7%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-/.f3259.1
Applied rewrites59.1%
Taylor expanded in ux around 0
*-commutativeN/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
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites15.9%
Final simplification69.4%
(FPCore (ux uy maxCos)
:precision binary32
(*
(* (* (PI) 2.0) uy)
(sqrt
(*
(-
(/ 2.0 ux)
(- (* (+ -1.0 maxCos) (- maxCos 1.0)) (* -2.0 (/ maxCos ux))))
(* ux ux)))))\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(\frac{2}{ux} - \left(\left(-1 + maxCos\right) \cdot \left(maxCos - 1\right) - -2 \cdot \frac{maxCos}{ux}\right)\right) \cdot \left(ux \cdot ux\right)}
\end{array}
Initial program 59.4%
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
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
*-commutativeN/A
lower-*.f3249.5
Applied rewrites49.3%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites76.2%
Applied rewrites80.1%
Final simplification80.1%
(FPCore (ux uy maxCos)
:precision binary32
(*
(* (* (PI) 2.0) uy)
(sqrt
(*
(- (- (/ 2.0 ux) (* (+ -1.0 maxCos) (- maxCos 1.0))) (* (/ maxCos ux) 2.0))
(* ux ux)))))\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(\left(\frac{2}{ux} - \left(-1 + maxCos\right) \cdot \left(maxCos - 1\right)\right) - \frac{maxCos}{ux} \cdot 2\right) \cdot \left(ux \cdot ux\right)}
\end{array}
Initial program 59.4%
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
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
*-commutativeN/A
lower-*.f3249.5
Applied rewrites47.9%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites76.2%
Applied rewrites80.1%
Final simplification80.1%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
(if (<= t_0 0.9998499751091003)
(* (* (* (PI) 2.0) uy) (sqrt (- 1.0 (* t_0 (- 1.0 ux)))))
(* (* (* (* (sqrt 2.0) (PI)) uy) 2.0) (sqrt (* (- 1.0 maxCos) ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) + ux \cdot maxCos\\
\mathbf{if}\;t\_0 \leq 0.9998499751091003:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{1 - t\_0 \cdot \left(1 - ux\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\sqrt{2} \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2\right) \cdot \sqrt{\left(1 - maxCos\right) \cdot ux}\\
\end{array}
\end{array}
if (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) < 0.999849975Initial program 90.2%
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%
Taylor expanded in maxCos around 0
lower--.f3272.9
Applied rewrites72.9%
if 0.999849975 < (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) Initial program 39.3%
lift-*.f32N/A
sqr-abs-revN/A
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
fabs-subN/A
lift-+.f32N/A
lift--.f32N/A
associate-+l-N/A
fabs-subN/A
sqr-absN/A
lower-*.f32N/A
lower--.f32N/A
lower--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower--.f3239.4
lift-*.f32N/A
*-commutativeN/A
lower-*.f3239.4
Applied rewrites39.4%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
*-commutativeN/A
*-lft-identityN/A
metadata-evalN/A
fp-cancel-sign-sub-invN/A
lower-*.f32N/A
fp-cancel-sign-sub-invN/A
metadata-evalN/A
*-lft-identityN/A
lower--.f3291.3
Applied rewrites91.3%
Taylor expanded in uy around 0
Applied rewrites74.7%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) 2.0) uy)))
(if (<= ux 0.0001500000071246177)
(* t_0 (sqrt (* (fma -2.0 maxCos 2.0) ux)))
(* t_0 (sqrt (- 1.0 (* (+ (- 1.0 ux) (* ux maxCos)) (- 1.0 ux))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\\
\mathbf{if}\;ux \leq 0.0001500000071246177:\\
\;\;\;\;t\_0 \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \sqrt{1 - \left(\left(1 - ux\right) + ux \cdot maxCos\right) \cdot \left(1 - ux\right)}\\
\end{array}
\end{array}
if ux < 1.50000007e-4Initial program 39.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3234.5
Applied rewrites34.5%
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
*-commutativeN/A
lower-*.f3234.3
Applied rewrites33.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites75.8%
Taylor expanded in ux around 0
Applied rewrites72.4%
if 1.50000007e-4 < ux Initial program 90.0%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3277.0
Applied rewrites77.0%
Taylor expanded in maxCos around 0
lower--.f3272.5
Applied rewrites72.5%
Final simplification72.4%
(FPCore (ux uy maxCos) :precision binary32 (* (* (* (PI) 2.0) uy) (sqrt (* (- (/ 2.0 ux) 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} - 1\right) \cdot \left(ux \cdot ux\right)}
\end{array}
Initial program 59.4%
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
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
*-commutativeN/A
lower-*.f3249.5
Applied rewrites48.1%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites76.2%
Taylor expanded in maxCos around 0
Applied rewrites76.2%
Final simplification76.2%
(FPCore (ux uy maxCos) :precision binary32 (if (<= ux 0.0001500000071246177) (* (* (* (PI) 2.0) uy) (sqrt (* (fma -2.0 maxCos 2.0) ux))) (* (* (+ (PI) (PI)) uy) (sqrt (- 1.0 (* (- 1.0 ux) (- 1.0 ux)))))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.0001500000071246177:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) + \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot \sqrt{1 - \left(1 - ux\right) \cdot \left(1 - ux\right)}\\
\end{array}
\end{array}
if ux < 1.50000007e-4Initial program 39.1%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3234.5
Applied rewrites34.5%
lift-*.f32N/A
lift-+.f32N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
*-commutativeN/A
lower-*.f3234.3
Applied rewrites32.6%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites75.8%
Taylor expanded in ux around 0
Applied rewrites72.4%
if 1.50000007e-4 < ux Initial program 90.0%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3277.0
Applied rewrites77.0%
Taylor expanded in maxCos around 0
lower--.f3272.5
Applied rewrites72.5%
Taylor expanded in maxCos around 0
lower--.f3272.1
Applied rewrites72.1%
Applied rewrites72.1%
Final simplification72.3%
(FPCore (ux uy maxCos) :precision binary32 (* (* (* (PI) 2.0) uy) (sqrt (* (fma -2.0 maxCos 2.0) ux))))
\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2\right) \cdot ux}
\end{array}
Initial program 59.4%
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
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift-fma.f32N/A
*-commutativeN/A
lower-*.f3249.5
Applied rewrites46.4%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites76.2%
Taylor expanded in ux around 0
Applied rewrites61.9%
Final simplification62.2%
(FPCore (ux uy maxCos) :precision binary32 (* (* (* (PI) 2.0) uy) (sqrt (- 1.0 (fabs 1.0)))))
\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{1 - \left|1\right|}
\end{array}
Initial program 59.4%
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
sqr-abs-revN/A
lift-+.f32N/A
lift--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate--r-N/A
lift--.f32N/A
fabs-subN/A
lift-+.f32N/A
lift--.f32N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate--r-N/A
lift--.f32N/A
fabs-subN/A
mul-fabsN/A
lower-fabs.f32N/A
Applied rewrites51.5%
Taylor expanded in ux around 0
Applied rewrites7.1%
herbie shell --seed 2024329
(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)))))))