
(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 17 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
(-
(* (- (fma (- maxCos 1.0) ux 2.0) maxCos) ux)
(* (* (fma maxCos ux (- 1.0 ux)) maxCos) ux)))))\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{fma}\left(maxCos - 1, ux, 2\right) - maxCos\right) \cdot ux - \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot maxCos\right) \cdot ux}
\end{array}
Initial program 54.8%
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 rewrites53.0%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower--.f3298.5
Applied rewrites98.5%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* (* uy 2.0) (PI))) (sqrt (fma (- (* (fma (- maxCos 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(maxCos - 2, ux, 2\right) \cdot ux, maxCos, \left(2 - ux\right) \cdot ux\right)}
\end{array}
Initial program 54.8%
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 rewrites98.5%
Taylor expanded in ux around 0
Applied rewrites98.5%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* (* uy 2.0) (PI))) (sqrt (* (- (fma (- maxCos 1.0) (fma (- 1.0 maxCos) ux -1.0) 1.0) maxCos) ux))))
\begin{array}{l}
\\
\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(\mathsf{fma}\left(maxCos - 1, \mathsf{fma}\left(1 - maxCos, ux, -1\right), 1\right) - maxCos\right) \cdot ux}
\end{array}
Initial program 54.8%
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.f3254.8
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f3254.8
Applied rewrites54.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites98.4%
Final simplification98.4%
(FPCore (ux uy maxCos) :precision binary32 (* (sin (* (+ uy uy) (PI))) (sqrt (* (fma -2.0 maxCos (- 2.0 (* (fma -2.0 maxCos 1.0) ux))) ux))))
\begin{array}{l}
\\
\sin \left(\left(uy + uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\mathsf{fma}\left(-2, maxCos, 2 - \mathsf{fma}\left(-2, maxCos, 1\right) \cdot ux\right) \cdot ux}
\end{array}
Initial program 54.8%
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.8%
lift-*.f32N/A
*-commutativeN/A
count-2-revN/A
lower-+.f3297.8
Applied rewrites97.8%
(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 54.8%
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 rewrites98.5%
Taylor expanded in ux around 0
Applied rewrites97.3%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= uy 0.0002500000118743628)
(*
(* (* (PI) 2.0) uy)
(sqrt
(fma
(* (- maxCos) (fma maxCos ux (- 1.0 ux)))
ux
(*
(fma (fma -1.0 maxCos 1.0) -1.0 (/ (fma -1.0 maxCos 2.0) ux))
(* ux ux)))))
(* (sin (* (* uy 2.0) (PI))) (sqrt (* (- 2.0 ux) ux)))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \leq 0.0002500000118743628:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(\left(-maxCos\right) \cdot \mathsf{fma}\left(maxCos, ux, 1 - ux\right), ux, \mathsf{fma}\left(\mathsf{fma}\left(-1, maxCos, 1\right), -1, \frac{\mathsf{fma}\left(-1, maxCos, 2\right)}{ux}\right) \cdot \left(ux \cdot ux\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{\left(2 - ux\right) \cdot ux}\\
\end{array}
\end{array}
if uy < 2.50000012e-4Initial program 53.6%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3253.5
Applied rewrites53.5%
lift--.f32N/A
lift-*.f32N/A
pow2N/A
metadata-evalN/A
pow-prod-upN/A
unpow1N/A
unpow1N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
*-commutativeN/A
Applied rewrites51.6%
Taylor expanded in ux around -inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-add-revN/A
lower-/.f32N/A
+-commutativeN/A
lower-fma.f32N/A
unpow2N/A
lower-*.f3298.5
Applied rewrites98.5%
if 2.50000012e-4 < uy Initial program 57.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.2
Applied rewrites98.2%
Taylor expanded in maxCos around 0
Applied rewrites91.9%
Final simplification96.2%
(FPCore (ux uy maxCos)
:precision binary32
(*
(* (* (PI) 2.0) uy)
(sqrt
(fma
(* (- maxCos) (fma maxCos ux (- 1.0 ux)))
ux
(*
(fma (fma -1.0 maxCos 1.0) -1.0 (/ (fma -1.0 maxCos 2.0) ux))
(* ux ux))))))\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(\left(-maxCos\right) \cdot \mathsf{fma}\left(maxCos, ux, 1 - ux\right), ux, \mathsf{fma}\left(\mathsf{fma}\left(-1, maxCos, 1\right), -1, \frac{\mathsf{fma}\left(-1, maxCos, 2\right)}{ux}\right) \cdot \left(ux \cdot ux\right)\right)}
\end{array}
Initial program 54.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3247.3
Applied rewrites47.3%
lift--.f32N/A
lift-*.f32N/A
pow2N/A
metadata-evalN/A
pow-prod-upN/A
unpow1N/A
unpow1N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
*-commutativeN/A
Applied rewrites45.5%
Taylor expanded in ux around -inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
lower-fma.f32N/A
+-commutativeN/A
associate-*r/N/A
metadata-evalN/A
associate-*r/N/A
div-add-revN/A
lower-/.f32N/A
+-commutativeN/A
lower-fma.f32N/A
unpow2N/A
lower-*.f3280.9
Applied rewrites80.9%
Final simplification80.9%
(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.9997000098228455)
(* (* (* (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.9997000098228455:\\
\;\;\;\;\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.99970001Initial program 89.0%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3273.6
Applied rewrites73.6%
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f3273.6
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f3273.6
Applied rewrites73.6%
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 34.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3232.0
Applied rewrites32.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.f3278.5
Applied rewrites78.5%
Applied rewrites78.5%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
(if (<= (* t_0 t_0) 0.9997000098228455)
(*
(sqrt (- 1.0 (* (- (fma maxCos ux 1.0) ux) (fma maxCos ux (- 1.0 ux)))))
(* (* (PI) uy) 2.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.9997000098228455:\\
\;\;\;\;\sqrt{1 - \left(\mathsf{fma}\left(maxCos, ux, 1\right) - ux\right) \cdot \mathsf{fma}\left(maxCos, ux, 1 - ux\right)} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\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.99970001Initial program 89.0%
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 rewrites89.2%
Taylor expanded in uy around 0
count-2-revN/A
distribute-rgt-outN/A
count-2-revN/A
lower-*.f32N/A
Applied rewrites73.5%
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 34.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3232.0
Applied rewrites32.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.f3278.5
Applied rewrites78.5%
Applied rewrites78.5%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
(if (<= (* t_0 t_0) 0.9977999925613403)
(* (* (* (PI) 2.0) uy) (sqrt (- 1.0 (* t_0 (- 1.0 ux)))))
(* (* (+ (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.9977999925613403:\\
\;\;\;\;\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(\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.997799993Initial program 93.0%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3277.3
Applied rewrites77.3%
Taylor expanded in maxCos around 0
lower--.f3275.5
Applied rewrites75.5%
if 0.997799993 < (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))) Initial program 39.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3235.5
Applied rewrites35.5%
Taylor expanded in ux around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3276.0
Applied rewrites76.0%
Applied rewrites76.0%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (- 1.0 ux) (* ux maxCos))))
(if (<= (* t_0 t_0) 0.9977999925613403)
(* (* (* (PI) 2.0) uy) (sqrt (fma (- ux 1.0) (- 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.9977999925613403:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\mathsf{fma}\left(ux - 1, 1 - 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.997799993Initial program 93.0%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3277.3
Applied rewrites77.3%
lift--.f32N/A
lift-*.f32N/A
pow2N/A
metadata-evalN/A
pow-prod-upN/A
unpow1N/A
unpow1N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
*-commutativeN/A
Applied rewrites77.1%
Taylor expanded in maxCos around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower--.f32N/A
lower--.f3275.2
Applied rewrites75.2%
if 0.997799993 < (*.f32 (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos)) (+.f32 (-.f32 #s(literal 1 binary32) ux) (*.f32 ux maxCos))) Initial program 39.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3235.5
Applied rewrites35.5%
Taylor expanded in ux around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3276.0
Applied rewrites76.0%
Applied rewrites76.0%
Final simplification75.8%
(FPCore (ux uy maxCos)
:precision binary32
(*
(* (* (PI) uy) 2.0)
(sqrt
(-
(* (- (fma (- maxCos 1.0) ux 2.0) maxCos) ux)
(* (* (fma maxCos ux (- 1.0 ux)) maxCos) ux)))))\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot \sqrt{\left(\mathsf{fma}\left(maxCos - 1, ux, 2\right) - maxCos\right) \cdot ux - \left(\mathsf{fma}\left(maxCos, ux, 1 - ux\right) \cdot maxCos\right) \cdot ux}
\end{array}
Initial program 54.8%
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 rewrites53.0%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
lower--.f3298.5
Applied rewrites98.5%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3280.9
Applied rewrites80.9%
(FPCore (ux uy maxCos)
:precision binary32
(*
(* (* (PI) 2.0) uy)
(sqrt
(*
(-
(+ (fma (- (fma (- maxCos 1.0) maxCos (- 1.0 maxCos))) ux (- maxCos)) 2.0)
maxCos)
ux))))\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right) \cdot \sqrt{\left(\left(\mathsf{fma}\left(-\mathsf{fma}\left(maxCos - 1, maxCos, 1 - maxCos\right), ux, -maxCos\right) + 2\right) - maxCos\right) \cdot ux}
\end{array}
Initial program 54.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3247.3
Applied rewrites47.3%
lift--.f32N/A
lift-*.f32N/A
pow2N/A
metadata-evalN/A
pow-prod-upN/A
unpow1N/A
unpow1N/A
lift-+.f32N/A
distribute-lft-inN/A
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
lift-+.f32N/A
lift-*.f32N/A
*-commutativeN/A
+-commutativeN/A
lift-fma.f32N/A
lift-*.f32N/A
*-commutativeN/A
Applied rewrites45.5%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites80.9%
Final simplification80.9%
(FPCore (ux uy maxCos)
:precision binary32
(let* ((t_0 (fma maxCos ux (- 1.0 ux))))
(if (<= ux 0.0001500000071246177)
(* (* (+ (PI) (PI)) uy) (sqrt (* (fma -2.0 maxCos 2.0) ux)))
(* (* (* (PI) uy) 2.0) (sqrt (fma t_0 (- t_0) 1.0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(maxCos, ux, 1 - ux\right)\\
\mathbf{if}\;ux \leq 0.0001500000071246177:\\
\;\;\;\;\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 uy\right) \cdot 2\right) \cdot \sqrt{\mathsf{fma}\left(t\_0, -t\_0, 1\right)}\\
\end{array}
\end{array}
if ux < 1.50000007e-4Initial program 34.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3232.0
Applied rewrites32.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.f3278.5
Applied rewrites78.5%
Applied rewrites78.5%
if 1.50000007e-4 < ux Initial program 89.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.f3289.1
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f3289.1
Applied rewrites89.1%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3273.7
Applied rewrites73.7%
(FPCore (ux uy maxCos)
:precision binary32
(if (<= ux 0.0001500000071246177)
(* (* (+ (PI) (PI)) uy) (sqrt (* (fma -2.0 maxCos 2.0) ux)))
(*
(sqrt (fma (- ux (fma maxCos ux 1.0)) (- (fma maxCos ux 1.0) ux) 1.0))
(* (* (PI) uy) 2.0))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;ux \leq 0.0001500000071246177:\\
\;\;\;\;\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}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(ux - \mathsf{fma}\left(maxCos, ux, 1\right), \mathsf{fma}\left(maxCos, ux, 1\right) - ux, 1\right)} \cdot \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right)\\
\end{array}
\end{array}
if ux < 1.50000007e-4Initial program 34.9%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3232.0
Applied rewrites32.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.f3278.5
Applied rewrites78.5%
Applied rewrites78.5%
if 1.50000007e-4 < ux Initial program 89.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.f3289.1
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lower-fma.f3289.1
Applied rewrites89.1%
Taylor expanded in uy around 0
count-2-revN/A
distribute-rgt-outN/A
count-2-revN/A
lower-*.f32N/A
Applied rewrites73.4%
Final simplification76.6%
(FPCore (ux uy maxCos) :precision binary32 (* (* (* (PI) uy) 2.0) (sqrt (- (* (- 2.0 ux) ux) (* (* maxCos ux) (fma -2.0 ux 2.0))))))
\begin{array}{l}
\\
\left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\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 54.8%
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.8%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3280.5
Applied rewrites80.5%
(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 54.8%
Taylor expanded in uy around 0
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3247.3
Applied rewrites47.3%
Taylor expanded in ux around 0
metadata-evalN/A
fp-cancel-sign-sub-invN/A
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
lower-fma.f3267.1
Applied rewrites67.1%
Applied rewrites67.1%
herbie shell --seed 2024350
(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)))))))