
(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 12 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) (* -2.0 maxCos))) ux)) (sin (* (+ uy uy) (PI)))))
\begin{array}{l}
\\
\sqrt{\left(2 - \left({\left(maxCos - 1\right)}^{2} \cdot ux - -2 \cdot maxCos\right)\right) \cdot ux} \cdot \sin \left(\left(uy + uy\right) \cdot \mathsf{PI}\left(\right)\right)
\end{array}
Initial program 57.0%
lift-*.f32N/A
lift-PI.f32N/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-PI.f32N/A
lower-sqrt.f32N/A
lift-PI.f32N/A
lower-sqrt.f3256.9
Applied rewrites56.9%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f320.8
Applied rewrites0.8%
Applied rewrites97.6%
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*r*N/A
associate-*r*N/A
lift-sqrt.f32N/A
lift-sqrt.f32N/A
rem-square-sqrtN/A
lift-PI.f32N/A
*-commutativeN/A
lift-PI.f32N/A
associate-*r*N/A
*-commutativeN/A
lift-*.f32N/A
count-2N/A
lift-*.f32N/A
lift-*.f32N/A
distribute-lft-outN/A
lower-*.f32N/A
lower-+.f3298.5
Applied rewrites98.5%
Final simplification98.5%
(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.0%
lift-*.f32N/A
lift-PI.f32N/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-PI.f32N/A
lower-sqrt.f32N/A
lift-PI.f32N/A
lower-sqrt.f3256.9
Applied rewrites56.9%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f320.8
Applied rewrites0.8%
Taylor expanded in maxCos around 0
Applied rewrites84.5%
Final simplification83.3%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* uy (PI)) 2.0)))
(if (<= (* 2.0 uy) 0.0003600000054575503)
(*
t_0
(sqrt
(* (- 2.0 (- (* (pow (- maxCos 1.0) 2.0) ux) (* -2.0 maxCos))) ux)))
(* (sin t_0) (sqrt (+ (* (- 1.0 ux) ux) ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot 2\\
\mathbf{if}\;2 \cdot uy \leq 0.0003600000054575503:\\
\;\;\;\;t\_0 \cdot \sqrt{\left(2 - \left({\left(maxCos - 1\right)}^{2} \cdot ux - -2 \cdot maxCos\right)\right) \cdot ux}\\
\mathbf{else}:\\
\;\;\;\;\sin t\_0 \cdot \sqrt{\left(1 - ux\right) \cdot ux + ux}\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 3.60000005e-4Initial program 58.1%
lift-*.f32N/A
lift-PI.f32N/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-PI.f32N/A
lower-sqrt.f32N/A
lift-PI.f32N/A
lower-sqrt.f3258.0
Applied rewrites58.0%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cancel-sign-sub-invN/A
metadata-evalN/A
+-commutativeN/A
lower-fma.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f321.0
Applied rewrites1.0%
Applied rewrites97.6%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.6
Applied rewrites98.6%
if 3.60000005e-4 < (*.f32 uy #s(literal 2 binary32)) Initial program 55.2%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3237.0
Applied rewrites37.0%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift--.f32N/A
sub-negN/A
lift-neg.f32N/A
associate-+r+N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift-+.f32N/A
distribute-lft-inN/A
lower-+.f32N/A
Applied rewrites36.1%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3292.8
Applied rewrites92.8%
Final simplification96.5%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (+ (/ (- 1.0 ux) maxCos) ux) ux)))
(if (<= maxCos 4.999999873689376e-6)
(* (sin (* (* uy (PI)) 2.0)) (sqrt (+ (* (- 1.0 ux) ux) ux)))
(*
(sqrt
(*
(* maxCos maxCos)
(-
(/ (/ ux maxCos) maxCos)
(+ (- t_0 (* (/ 1.0 maxCos) t_0)) (/ ux maxCos)))))
(* (* 2.0 (PI)) uy)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\frac{1 - ux}{maxCos} + ux\right) \cdot ux\\
\mathbf{if}\;maxCos \leq 4.999999873689376 \cdot 10^{-6}:\\
\;\;\;\;\sin \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right) \cdot \sqrt{\left(1 - ux\right) \cdot ux + ux}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(maxCos \cdot maxCos\right) \cdot \left(\frac{\frac{ux}{maxCos}}{maxCos} - \left(\left(t\_0 - \frac{1}{maxCos} \cdot t\_0\right) + \frac{ux}{maxCos}\right)\right)} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)\\
\end{array}
\end{array}
if maxCos < 4.99999987e-6Initial program 56.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3249.5
Applied rewrites49.5%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift--.f32N/A
sub-negN/A
lift-neg.f32N/A
associate-+r+N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift-+.f32N/A
distribute-lft-inN/A
lower-+.f32N/A
Applied rewrites49.8%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.0
Applied rewrites98.0%
if 4.99999987e-6 < maxCos Initial 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.f3254.2
Applied rewrites54.2%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift--.f32N/A
sub-negN/A
lift-neg.f32N/A
associate-+r+N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift-+.f32N/A
distribute-lft-inN/A
lower-+.f32N/A
Applied rewrites37.0%
Taylor expanded in maxCos around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites54.9%
Applied rewrites88.8%
Final simplification96.4%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (- 1.0 ux) ux)))
(if (<= maxCos 4.999999873689376e-6)
(* (sin (* (* uy (PI)) 2.0)) (sqrt (+ t_0 ux)))
(*
(sqrt
(*
(-
(/ (/ ux maxCos) maxCos)
(-
(- (* (/ ux maxCos) 2.0) (/ (* ux ux) maxCos))
(/ (/ t_0 maxCos) maxCos)))
(* maxCos maxCos)))
(* (* 2.0 (PI)) uy)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) \cdot ux\\
\mathbf{if}\;maxCos \leq 4.999999873689376 \cdot 10^{-6}:\\
\;\;\;\;\sin \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right) \cdot \sqrt{t\_0 + ux}\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\frac{\frac{ux}{maxCos}}{maxCos} - \left(\left(\frac{ux}{maxCos} \cdot 2 - \frac{ux \cdot ux}{maxCos}\right) - \frac{\frac{t\_0}{maxCos}}{maxCos}\right)\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)\\
\end{array}
\end{array}
if maxCos < 4.99999987e-6Initial program 56.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3249.5
Applied rewrites49.5%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift--.f32N/A
sub-negN/A
lift-neg.f32N/A
associate-+r+N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift-+.f32N/A
distribute-lft-inN/A
lower-+.f32N/A
Applied rewrites49.8%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
associate-*r*N/A
mul-1-negN/A
cancel-sign-subN/A
lower-+.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.0
Applied rewrites98.0%
if 4.99999987e-6 < maxCos Initial 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.f3254.2
Applied rewrites54.2%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift--.f32N/A
sub-negN/A
lift-neg.f32N/A
associate-+r+N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift-+.f32N/A
distribute-lft-inN/A
lower-+.f32N/A
Applied rewrites37.0%
Taylor expanded in maxCos around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites54.9%
Taylor expanded in ux around 0
Applied rewrites77.7%
Final simplification94.5%
(FPCore (ux uy maxCos) :precision binary32 (if (<= (* 2.0 uy) 0.0010400000028312206) (* (sqrt (+ (* (- 1.0 ux) ux) ux)) (* (* 2.0 (PI)) uy)) (* (sqrt (* 2.0 ux)) (sin (* (* uy (PI)) 2.0)))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;2 \cdot uy \leq 0.0010400000028312206:\\
\;\;\;\;\sqrt{\left(1 - ux\right) \cdot ux + ux} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)\\
\mathbf{else}:\\
\;\;\;\;\sqrt{2 \cdot ux} \cdot \sin \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00104Initial program 58.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3258.4
Applied rewrites58.4%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift--.f32N/A
sub-negN/A
lift-neg.f32N/A
associate-+r+N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift-+.f32N/A
distribute-lft-inN/A
lower-+.f32N/A
Applied rewrites54.8%
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--.f3289.0
Applied rewrites89.0%
if 0.00104 < (*.f32 uy #s(literal 2 binary32)) Initial program 54.2%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3233.9
Applied rewrites33.9%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3246.8
Applied rewrites46.8%
Taylor expanded in maxCos around 0
Applied rewrites46.8%
Taylor expanded in uy around inf
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3275.9
Applied rewrites75.9%
Final simplification84.7%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (- 1.0 ux) ux)) (t_1 (* (* 2.0 (PI)) uy)))
(if (<= maxCos 1.4999999853326784e-10)
(* (sqrt (+ t_0 ux)) t_1)
(*
(sqrt
(*
(-
(/ (/ ux maxCos) maxCos)
(-
(- (* (/ ux maxCos) 2.0) (/ (* ux ux) maxCos))
(/ (/ t_0 maxCos) maxCos)))
(* maxCos maxCos)))
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) \cdot ux\\
t_1 := \left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
\mathbf{if}\;maxCos \leq 1.4999999853326784 \cdot 10^{-10}:\\
\;\;\;\;\sqrt{t\_0 + ux} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\frac{\frac{ux}{maxCos}}{maxCos} - \left(\left(\frac{ux}{maxCos} \cdot 2 - \frac{ux \cdot ux}{maxCos}\right) - \frac{\frac{t\_0}{maxCos}}{maxCos}\right)\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot t\_1\\
\end{array}
\end{array}
if maxCos < 1.49999999e-10Initial program 57.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3249.4
Applied rewrites49.4%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift--.f32N/A
sub-negN/A
lift-neg.f32N/A
associate-+r+N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift-+.f32N/A
distribute-lft-inN/A
lower-+.f32N/A
Applied rewrites49.7%
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--.f3280.4
Applied rewrites80.4%
if 1.49999999e-10 < maxCos Initial program 56.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3252.8
Applied rewrites52.8%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift--.f32N/A
sub-negN/A
lift-neg.f32N/A
associate-+r+N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift-+.f32N/A
distribute-lft-inN/A
lower-+.f32N/A
Applied rewrites42.1%
Taylor expanded in maxCos around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites65.6%
Taylor expanded in ux around 0
Applied rewrites80.1%
Final simplification80.4%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (- 1.0 ux) ux)) (t_1 (* (* 2.0 (PI)) uy)))
(if (<= maxCos 1.4999999853326784e-10)
(* (sqrt (+ t_0 ux)) t_1)
(*
(sqrt
(*
(-
(/ (/ ux maxCos) maxCos)
(- (* (/ ux maxCos) 2.0) (/ (/ t_0 maxCos) maxCos)))
(* maxCos maxCos)))
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(1 - ux\right) \cdot ux\\
t_1 := \left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
\mathbf{if}\;maxCos \leq 1.4999999853326784 \cdot 10^{-10}:\\
\;\;\;\;\sqrt{t\_0 + ux} \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(\frac{\frac{ux}{maxCos}}{maxCos} - \left(\frac{ux}{maxCos} \cdot 2 - \frac{\frac{t\_0}{maxCos}}{maxCos}\right)\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot t\_1\\
\end{array}
\end{array}
if maxCos < 1.49999999e-10Initial program 57.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3249.4
Applied rewrites49.4%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift--.f32N/A
sub-negN/A
lift-neg.f32N/A
associate-+r+N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift-+.f32N/A
distribute-lft-inN/A
lower-+.f32N/A
Applied rewrites49.7%
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--.f3280.4
Applied rewrites80.4%
if 1.49999999e-10 < maxCos Initial program 56.3%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3252.8
Applied rewrites52.8%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift--.f32N/A
sub-negN/A
lift-neg.f32N/A
associate-+r+N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift-+.f32N/A
distribute-lft-inN/A
lower-+.f32N/A
Applied rewrites42.1%
Taylor expanded in maxCos around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites65.6%
Taylor expanded in ux around 0
Applied rewrites78.9%
Final simplification80.0%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* 2.0 (PI)) uy)))
(if (<= maxCos 1.1000000085914508e-5)
(* (sqrt (+ (* (- 1.0 ux) ux) ux)) t_0)
(*
(sqrt
(* (/ (- (* 4.0 (* maxCos maxCos)) 4.0) (- (* -2.0 maxCos) 2.0)) ux))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
\mathbf{if}\;maxCos \leq 1.1000000085914508 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{\left(1 - ux\right) \cdot ux + ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{4 \cdot \left(maxCos \cdot maxCos\right) - 4}{-2 \cdot maxCos - 2} \cdot ux} \cdot t\_0\\
\end{array}
\end{array}
if maxCos < 1.10000001e-5Initial program 57.2%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3249.9
Applied rewrites49.9%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift--.f32N/A
sub-negN/A
lift-neg.f32N/A
associate-+r+N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift-+.f32N/A
distribute-lft-inN/A
lower-+.f32N/A
Applied rewrites50.0%
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--.f3280.8
Applied rewrites80.8%
if 1.10000001e-5 < maxCos Initial program 56.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3252.8
Applied rewrites52.8%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3248.6
Applied rewrites48.6%
Applied rewrites48.6%
Applied rewrites70.0%
Final simplification79.0%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* 2.0 (PI)) uy)))
(if (<= maxCos 1.1000000085914508e-5)
(* (sqrt (+ (* (- 1.0 ux) ux) ux)) t_0)
(* (sqrt (* (+ (* -2.0 maxCos) 2.0) ux)) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
\mathbf{if}\;maxCos \leq 1.1000000085914508 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{\left(1 - ux\right) \cdot ux + ux} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{\left(-2 \cdot maxCos + 2\right) \cdot ux} \cdot t\_0\\
\end{array}
\end{array}
if maxCos < 1.10000001e-5Initial program 57.2%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3249.9
Applied rewrites49.9%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift--.f32N/A
sub-negN/A
lift-neg.f32N/A
associate-+r+N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift-+.f32N/A
distribute-lft-inN/A
lower-+.f32N/A
Applied rewrites50.0%
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--.f3280.8
Applied rewrites80.8%
if 1.10000001e-5 < maxCos Initial program 56.4%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3252.8
Applied rewrites52.8%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3248.6
Applied rewrites48.6%
Applied rewrites70.0%
Final simplification79.0%
(FPCore (ux uy maxCos) :precision binary32 (* (sqrt (+ (* (- 1.0 ux) ux) ux)) (* (* 2.0 (PI)) uy)))
\begin{array}{l}
\\
\sqrt{\left(1 - ux\right) \cdot ux + ux} \cdot \left(\left(2 \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right)
\end{array}
Initial program 57.0%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3250.3
Applied rewrites50.3%
lift-*.f32N/A
lift-+.f32N/A
+-commutativeN/A
lift--.f32N/A
sub-negN/A
lift-neg.f32N/A
associate-+r+N/A
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
+-commutativeN/A
lift-+.f32N/A
distribute-lft-inN/A
lower-+.f32N/A
Applied rewrites47.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--.f3275.8
Applied rewrites75.8%
Final simplification75.8%
(FPCore (ux uy maxCos) :precision binary32 (* (* (+ uy uy) (PI)) (sqrt (* 2.0 ux))))
\begin{array}{l}
\\
\left(\left(uy + uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{2 \cdot ux}
\end{array}
Initial program 57.0%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3250.3
Applied rewrites50.3%
Taylor expanded in ux around 0
cancel-sign-sub-invN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3263.4
Applied rewrites63.4%
Taylor expanded in maxCos around 0
Applied rewrites63.4%
Applied rewrites63.4%
Final simplification63.4%
herbie shell --seed 2024251
(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)))))))