
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux))
(t_1 (sqrt (- 1.0 (* t_0 t_0))))
(t_2 (* (* uy 2.0) (PI))))
(+ (+ (* (* (cos t_2) t_1) xi) (* (* (sin t_2) t_1) yi)) (* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\\
\left(\left(\cos t\_2 \cdot t\_1\right) \cdot xi + \left(\sin t\_2 \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
\end{array}
Sampling outcomes in binary32 precision:
Herbie found 18 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux))
(t_1 (sqrt (- 1.0 (* t_0 t_0))))
(t_2 (* (* uy 2.0) (PI))))
(+ (+ (* (* (cos t_2) t_1) xi) (* (* (sin t_2) t_1) yi)) (* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\\
\left(\left(\cos t\_2 \cdot t\_1\right) \cdot xi + \left(\sin t\_2 \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
\end{array}
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux))
(t_1 (sqrt (- 1.0 (* t_0 t_0))))
(t_2 (* (* uy 2.0) (PI))))
(+
(+ (* (* (cos t_2) t_1) xi) (* (* (sin t_2) t_1) yi))
(* (- (* maxCos ux) (* ux (* ux maxCos))) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\\
\left(\left(\cos t\_2 \cdot t\_1\right) \cdot xi + \left(\sin t\_2 \cdot t\_1\right) \cdot yi\right) + \left(maxCos \cdot ux - ux \cdot \left(ux \cdot maxCos\right)\right) \cdot zi
\end{array}
\end{array}
Initial program 99.1%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-rgt-inN/A
*-lft-identityN/A
distribute-lft-inN/A
*-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-neg.f3299.2
Applied rewrites99.2%
Final simplification99.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux))
(t_1 (sqrt (- 1.0 (* t_0 t_0))))
(t_2 (* (* uy 2.0) (PI))))
(+
(+ (* (* (cos t_2) t_1) xi) (* (* (sin t_2) t_1) yi))
(* (* (- 1.0 ux) (* maxCos ux)) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\\
\left(\left(\cos t\_2 \cdot t\_1\right) \cdot xi + \left(\sin t\_2 \cdot t\_1\right) \cdot yi\right) + \left(\left(1 - ux\right) \cdot \left(maxCos \cdot ux\right)\right) \cdot zi
\end{array}
\end{array}
Initial program 99.1%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.2
Applied rewrites99.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux))
(t_1 (sqrt (- 1.0 (* t_0 t_0))))
(t_2 (* (* uy 2.0) (PI))))
(+
(+ (* (* (cos t_2) t_1) xi) (* (* (sin t_2) t_1) yi))
(* (* (- maxCos (* maxCos ux)) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\\
\left(\left(\cos t\_2 \cdot t\_1\right) \cdot xi + \left(\sin t\_2 \cdot t\_1\right) \cdot yi\right) + \left(\left(maxCos - maxCos \cdot ux\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 99.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3299.2
Applied rewrites99.2%
Final simplification99.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux)))
(+
(+
(* (cos (* (* (PI) uy) 2.0)) xi)
(* (* (sin (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* t_0 t_0)))) yi))
(* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
\left(\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
\end{array}
Initial program 99.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3299.1
Applied rewrites99.1%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux)))
(+
(+
(* (cos (* (* (PI) uy) 2.0)) xi)
(* (* (sin (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* t_0 t_0)))) yi))
(* (* maxCos (fma (- ux) ux ux)) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
\left(\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot yi\right) + \left(maxCos \cdot \mathsf{fma}\left(-ux, ux, ux\right)\right) \cdot zi
\end{array}
\end{array}
Initial program 99.1%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-rgt-inN/A
*-lft-identityN/A
distribute-lft-inN/A
*-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-neg.f3299.2
Applied rewrites99.2%
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*r*N/A
lift-*.f32N/A
*-commutativeN/A
distribute-rgt-outN/A
lower-*.f32N/A
*-commutativeN/A
lower-fma.f3294.3
Applied rewrites93.9%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3297.2
Applied rewrites97.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux)) (t_1 (sqrt (- 1.0 (* t_0 t_0)))))
(if (or (<= yi -4.99999991225835e-14) (not (<= yi 9.99999983775159e-18)))
(+
(+
(* (* (fma (* -2.0 (* uy uy)) (* (PI) (PI)) 1.0) t_1) xi)
(* (* (sin (* (* uy 2.0) (PI))) t_1) yi))
(* (* maxCos (fma (- ux) ux ux)) zi))
(+
(*
(* (cos (* (* (PI) uy) 2.0)) xi)
(sqrt (- 1.0 (* (* (pow (- 1.0 ux) 2.0) (* ux ux)) (* maxCos maxCos)))))
(* (- (* maxCos ux) (* ux (* ux maxCos))) zi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
\mathbf{if}\;yi \leq -4.99999991225835 \cdot 10^{-14} \lor \neg \left(yi \leq 9.99999983775159 \cdot 10^{-18}\right):\\
\;\;\;\;\left(\left(\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot t\_1\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot t\_1\right) \cdot yi\right) + \left(maxCos \cdot \mathsf{fma}\left(-ux, ux, ux\right)\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;\left(\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot xi\right) \cdot \sqrt{1 - \left({\left(1 - ux\right)}^{2} \cdot \left(ux \cdot ux\right)\right) \cdot \left(maxCos \cdot maxCos\right)} + \left(maxCos \cdot ux - ux \cdot \left(ux \cdot maxCos\right)\right) \cdot zi\\
\end{array}
\end{array}
if yi < -4.99999991e-14 or 9.99999984e-18 < yi Initial program 98.9%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-rgt-inN/A
*-lft-identityN/A
distribute-lft-inN/A
*-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-neg.f3299.0
Applied rewrites99.0%
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*r*N/A
lift-*.f32N/A
*-commutativeN/A
distribute-rgt-outN/A
lower-*.f32N/A
*-commutativeN/A
lower-fma.f3296.8
Applied rewrites96.8%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3269.6
Applied rewrites72.5%
if -4.99999991e-14 < yi < 9.99999984e-18Initial program 99.3%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-rgt-inN/A
*-lft-identityN/A
distribute-lft-inN/A
*-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-neg.f3299.4
Applied rewrites99.4%
Taylor expanded in xi around inf
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
sub-negN/A
mul-1-negN/A
lower-sqrt.f32N/A
mul-1-negN/A
Applied rewrites85.5%
Final simplification81.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux)) (t_1 (sqrt (- 1.0 (* t_0 t_0)))))
(if (or (<= yi -4.99999991225835e-14) (not (<= yi 9.99999983775159e-18)))
(+
(+
(* (* (fma (* -2.0 (* uy uy)) (* (PI) (PI)) 1.0) t_1) xi)
(* (* (sin (* (* uy 2.0) (PI))) t_1) yi))
(* (* maxCos (fma (- ux) ux ux)) zi))
(+
(* (* (- ux (* ux ux)) zi) maxCos)
(*
(* xi (sqrt (- 1.0 (pow (* (* maxCos (- 1.0 ux)) ux) 2.0))))
(cos (* (* (PI) 2.0) uy)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
\mathbf{if}\;yi \leq -4.99999991225835 \cdot 10^{-14} \lor \neg \left(yi \leq 9.99999983775159 \cdot 10^{-18}\right):\\
\;\;\;\;\left(\left(\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot t\_1\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot t\_1\right) \cdot yi\right) + \left(maxCos \cdot \mathsf{fma}\left(-ux, ux, ux\right)\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;\left(\left(ux - ux \cdot ux\right) \cdot zi\right) \cdot maxCos + \left(xi \cdot \sqrt{1 - {\left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right)}^{2}}\right) \cdot \cos \left(\left(\mathsf{PI}\left(\right) \cdot 2\right) \cdot uy\right)\\
\end{array}
\end{array}
if yi < -4.99999991e-14 or 9.99999984e-18 < yi Initial program 98.9%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-rgt-inN/A
*-lft-identityN/A
distribute-lft-inN/A
*-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-neg.f3299.0
Applied rewrites99.0%
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*r*N/A
lift-*.f32N/A
*-commutativeN/A
distribute-rgt-outN/A
lower-*.f32N/A
*-commutativeN/A
lower-fma.f3296.8
Applied rewrites96.8%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3271.6
Applied rewrites71.4%
if -4.99999991e-14 < yi < 9.99999984e-18Initial program 99.3%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-rgt-inN/A
*-lft-identityN/A
distribute-lft-inN/A
*-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-neg.f3299.4
Applied rewrites99.4%
Applied rewrites83.0%
Taylor expanded in yi around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
sub-negN/A
lower--.f32N/A
unpow2N/A
lower-*.f3285.5
Applied rewrites85.5%
Final simplification80.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux)) (t_1 (sqrt (- 1.0 (* t_0 t_0)))))
(if (or (<= yi -4.99999991225835e-14) (not (<= yi 4.999999841327613e-21)))
(+
(+
(* (* (fma (* -2.0 (* uy uy)) (* (PI) (PI)) 1.0) t_1) xi)
(* (* (sin (* (* uy 2.0) (PI))) t_1) yi))
(* (* maxCos (fma (- ux) ux ux)) zi))
(+
(*
(sqrt (- 1.0 (* (* (* ux ux) (pow (- 1.0 ux) 2.0)) (* maxCos maxCos))))
xi)
(* (* (- ux (* ux ux)) maxCos) zi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
\mathbf{if}\;yi \leq -4.99999991225835 \cdot 10^{-14} \lor \neg \left(yi \leq 4.999999841327613 \cdot 10^{-21}\right):\\
\;\;\;\;\left(\left(\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot t\_1\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot t\_1\right) \cdot yi\right) + \left(maxCos \cdot \mathsf{fma}\left(-ux, ux, ux\right)\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot xi + \left(\left(ux - ux \cdot ux\right) \cdot maxCos\right) \cdot zi\\
\end{array}
\end{array}
if yi < -4.99999991e-14 or 4.99999984e-21 < yi Initial program 98.9%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-rgt-inN/A
*-lft-identityN/A
distribute-lft-inN/A
*-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-neg.f3299.0
Applied rewrites99.0%
lift-+.f32N/A
+-commutativeN/A
lift-*.f32N/A
lift-*.f32N/A
associate-*r*N/A
lift-*.f32N/A
*-commutativeN/A
distribute-rgt-outN/A
lower-*.f32N/A
*-commutativeN/A
lower-fma.f3296.1
Applied rewrites96.1%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3270.2
Applied rewrites70.2%
if -4.99999991e-14 < yi < 4.99999984e-21Initial program 99.4%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-rgt-inN/A
*-lft-identityN/A
distribute-lft-inN/A
*-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-neg.f3299.4
Applied rewrites99.4%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3299.4
Applied rewrites99.4%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites77.7%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
unpow2N/A
lower-*.f3277.8
Applied rewrites77.8%
Final simplification76.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0
(sqrt
(- 1.0 (* (* (pow (- 1.0 ux) 2.0) (* ux ux)) (* maxCos maxCos)))))
(t_1 (* (sin (* (* (PI) uy) 2.0)) yi)))
(if (<= yi -5.999999759184749e-13)
t_1
(if (<= yi 4.99999991225835e-14)
(+ (* t_0 xi) (* (- (* maxCos ux) (* ux (* ux maxCos))) zi))
(* t_0 t_1)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 - \left({\left(1 - ux\right)}^{2} \cdot \left(ux \cdot ux\right)\right) \cdot \left(maxCos \cdot maxCos\right)}\\
t_1 := \sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\\
\mathbf{if}\;yi \leq -5.999999759184749 \cdot 10^{-13}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;yi \leq 4.99999991225835 \cdot 10^{-14}:\\
\;\;\;\;t\_0 \cdot xi + \left(maxCos \cdot ux - ux \cdot \left(ux \cdot maxCos\right)\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot t\_1\\
\end{array}
\end{array}
if yi < -5.99999976e-13Initial program 98.8%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites4.9%
Taylor expanded in ux around 0
Applied rewrites62.9%
if -5.99999976e-13 < yi < 4.99999991e-14Initial program 99.3%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-rgt-inN/A
*-lft-identityN/A
distribute-lft-inN/A
*-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-neg.f3299.4
Applied rewrites99.4%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites73.2%
if 4.99999991e-14 < yi Initial program 99.0%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites6.7%
Taylor expanded in yi around inf
Applied rewrites54.4%
Final simplification66.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(if (or (<= yi -5.999999759184749e-13) (not (<= yi 4.99999991225835e-14)))
(* (sin (* (* (PI) uy) 2.0)) yi)
(+
(*
(sqrt (- 1.0 (* (* (pow (- 1.0 ux) 2.0) (* ux ux)) (* maxCos maxCos))))
xi)
(* (- (* maxCos ux) (* ux (* ux maxCos))) zi))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;yi \leq -5.999999759184749 \cdot 10^{-13} \lor \neg \left(yi \leq 4.99999991225835 \cdot 10^{-14}\right):\\
\;\;\;\;\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left({\left(1 - ux\right)}^{2} \cdot \left(ux \cdot ux\right)\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot xi + \left(maxCos \cdot ux - ux \cdot \left(ux \cdot maxCos\right)\right) \cdot zi\\
\end{array}
\end{array}
if yi < -5.99999976e-13 or 4.99999991e-14 < yi Initial program 98.9%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites5.6%
Taylor expanded in ux around 0
Applied rewrites57.2%
if -5.99999976e-13 < yi < 4.99999991e-14Initial program 99.3%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-rgt-inN/A
*-lft-identityN/A
distribute-lft-inN/A
*-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-neg.f3299.4
Applied rewrites99.4%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites73.2%
Final simplification66.6%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(if (or (<= yi -5.999999759184749e-13) (not (<= yi 4.99999991225835e-14)))
(* (sin (* (* (PI) uy) 2.0)) yi)
(+
(*
(sqrt (- 1.0 (* (* (* ux ux) (pow (- 1.0 ux) 2.0)) (* maxCos maxCos))))
xi)
(* (* (- ux (* ux ux)) maxCos) zi))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;yi \leq -5.999999759184749 \cdot 10^{-13} \lor \neg \left(yi \leq 4.99999991225835 \cdot 10^{-14}\right):\\
\;\;\;\;\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot xi + \left(\left(ux - ux \cdot ux\right) \cdot maxCos\right) \cdot zi\\
\end{array}
\end{array}
if yi < -5.99999976e-13 or 4.99999991e-14 < yi Initial program 98.9%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites5.9%
Taylor expanded in ux around 0
Applied rewrites57.2%
if -5.99999976e-13 < yi < 4.99999991e-14Initial program 99.3%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-rgt-inN/A
*-lft-identityN/A
distribute-lft-inN/A
*-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-neg.f3299.4
Applied rewrites99.4%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3299.3
Applied rewrites99.3%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites73.2%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
unpow2N/A
lower-*.f3273.2
Applied rewrites73.2%
Final simplification66.6%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(if (or (<= yi -5.999999759184749e-13) (not (<= yi 4.99999991225835e-14)))
(* (sin (* (* (PI) uy) 2.0)) yi)
(+
(*
(sqrt (- 1.0 (* (* (* ux ux) (pow (- 1.0 ux) 2.0)) (* maxCos maxCos))))
xi)
(* (* (- maxCos (* maxCos ux)) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;yi \leq -5.999999759184749 \cdot 10^{-13} \lor \neg \left(yi \leq 4.99999991225835 \cdot 10^{-14}\right):\\
\;\;\;\;\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot xi + \left(\left(maxCos - maxCos \cdot ux\right) \cdot ux\right) \cdot zi\\
\end{array}
\end{array}
if yi < -5.99999976e-13 or 4.99999991e-14 < yi Initial program 98.9%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites5.8%
Taylor expanded in ux around 0
Applied rewrites57.2%
if -5.99999976e-13 < yi < 4.99999991e-14Initial program 99.3%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-rgt-inN/A
*-lft-identityN/A
distribute-lft-inN/A
*-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-neg.f3299.4
Applied rewrites99.4%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3299.3
Applied rewrites99.3%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites73.2%
Final simplification66.5%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (if (or (<= yi -5.999999759184749e-13) (not (<= yi 4.99999991225835e-14))) (* (sin (* (* (PI) uy) 2.0)) yi) (+ (* 1.0 xi) (* (* (- maxCos (* maxCos ux)) ux) zi))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;yi \leq -5.999999759184749 \cdot 10^{-13} \lor \neg \left(yi \leq 4.99999991225835 \cdot 10^{-14}\right):\\
\;\;\;\;\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\\
\mathbf{else}:\\
\;\;\;\;1 \cdot xi + \left(\left(maxCos - maxCos \cdot ux\right) \cdot ux\right) \cdot zi\\
\end{array}
\end{array}
if yi < -5.99999976e-13 or 4.99999991e-14 < yi Initial program 98.9%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites6.8%
Taylor expanded in ux around 0
Applied rewrites57.2%
if -5.99999976e-13 < yi < 4.99999991e-14Initial program 99.3%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-rgt-inN/A
*-lft-identityN/A
distribute-lft-inN/A
*-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-neg.f3299.4
Applied rewrites99.4%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3299.3
Applied rewrites99.3%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites73.2%
Taylor expanded in ux around 0
Applied rewrites73.2%
Final simplification66.5%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (* 1.0 xi) (* (* (- maxCos (* maxCos ux)) ux) zi)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (1.0f * xi) + (((maxCos - (maxCos * ux)) * ux) * zi);
}
real(4) function code(xi, yi, zi, ux, uy, maxcos)
real(4), intent (in) :: xi
real(4), intent (in) :: yi
real(4), intent (in) :: zi
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = (1.0e0 * xi) + (((maxcos - (maxcos * ux)) * ux) * zi)
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(1.0) * xi) + Float32(Float32(Float32(maxCos - Float32(maxCos * ux)) * ux) * zi)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (single(1.0) * xi) + (((maxCos - (maxCos * ux)) * ux) * zi); end
\begin{array}{l}
\\
1 \cdot xi + \left(\left(maxCos - maxCos \cdot ux\right) \cdot ux\right) \cdot zi
\end{array}
Initial program 99.1%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-rgt-inN/A
*-lft-identityN/A
distribute-lft-inN/A
*-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-neg.f3299.2
Applied rewrites99.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3299.2
Applied rewrites99.2%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites56.6%
Taylor expanded in ux around 0
Applied rewrites56.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* (- ux (* ux ux)) maxCos) zi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return ((ux - (ux * ux)) * maxCos) * zi;
}
real(4) function code(xi, yi, zi, ux, uy, maxcos)
real(4), intent (in) :: xi
real(4), intent (in) :: yi
real(4), intent (in) :: zi
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = ((ux - (ux * ux)) * maxcos) * zi
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(ux - Float32(ux * ux)) * maxCos) * zi) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = ((ux - (ux * ux)) * maxCos) * zi; end
\begin{array}{l}
\\
\left(\left(ux - ux \cdot ux\right) \cdot maxCos\right) \cdot zi
\end{array}
Initial program 99.1%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
*-commutativeN/A
lift--.f32N/A
sub-negN/A
distribute-rgt-inN/A
*-lft-identityN/A
distribute-lft-inN/A
*-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-neg.f3299.2
Applied rewrites99.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3299.2
Applied rewrites99.2%
Taylor expanded in zi around inf
*-commutativeN/A
+-commutativeN/A
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
distribute-lft-inN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
sub-negN/A
lower--.f32N/A
unpow2N/A
lower-*.f3213.6
Applied rewrites13.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (- 1.0 ux) (* (* maxCos ux) zi)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (1.0f - ux) * ((maxCos * ux) * zi);
}
real(4) function code(xi, yi, zi, ux, uy, maxcos)
real(4), intent (in) :: xi
real(4), intent (in) :: yi
real(4), intent (in) :: zi
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = (1.0e0 - ux) * ((maxcos * ux) * zi)
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(1.0) - ux) * Float32(Float32(maxCos * ux) * zi)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (single(1.0) - ux) * ((maxCos * ux) * zi); end
\begin{array}{l}
\\
\left(1 - ux\right) \cdot \left(\left(maxCos \cdot ux\right) \cdot zi\right)
\end{array}
Initial program 99.1%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3213.5
Applied rewrites13.5%
Applied rewrites13.6%
Final simplification13.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* (* maxCos (- 1.0 ux)) ux) zi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return ((maxCos * (1.0f - ux)) * ux) * zi;
}
real(4) function code(xi, yi, zi, ux, uy, maxcos)
real(4), intent (in) :: xi
real(4), intent (in) :: yi
real(4), intent (in) :: zi
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = ((maxcos * (1.0e0 - ux)) * ux) * zi
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(maxCos * Float32(Float32(1.0) - ux)) * ux) * zi) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = ((maxCos * (single(1.0) - ux)) * ux) * zi; end
\begin{array}{l}
\\
\left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot zi
\end{array}
Initial program 99.1%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3213.5
Applied rewrites13.5%
Applied rewrites13.6%
Final simplification13.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* zi ux) maxCos))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (zi * ux) * maxCos;
}
real(4) function code(xi, yi, zi, ux, uy, maxcos)
real(4), intent (in) :: xi
real(4), intent (in) :: yi
real(4), intent (in) :: zi
real(4), intent (in) :: ux
real(4), intent (in) :: uy
real(4), intent (in) :: maxcos
code = (zi * ux) * maxcos
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(zi * ux) * maxCos) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (zi * ux) * maxCos; end
\begin{array}{l}
\\
\left(zi \cdot ux\right) \cdot maxCos
\end{array}
Initial program 99.1%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3213.5
Applied rewrites13.5%
Taylor expanded in ux around 0
Applied rewrites12.3%
Final simplification12.3%
herbie shell --seed 2024325
(FPCore (xi yi zi ux uy maxCos)
:name "UniformSampleCone 2"
:precision binary32
:pre (and (and (and (and (and (and (<= -10000.0 xi) (<= xi 10000.0)) (and (<= -10000.0 yi) (<= yi 10000.0))) (and (<= -10000.0 zi) (<= zi 10000.0))) (and (<= 2.328306437e-10 ux) (<= ux 1.0))) (and (<= 2.328306437e-10 uy) (<= uy 1.0))) (and (<= 0.0 maxCos) (<= maxCos 1.0)))
(+ (+ (* (* (cos (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* (* (* (- 1.0 ux) maxCos) ux) (* (* (- 1.0 ux) maxCos) ux))))) xi) (* (* (sin (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* (* (* (- 1.0 ux) maxCos) ux) (* (* (- 1.0 ux) maxCos) ux))))) yi)) (* (* (* (- 1.0 ux) maxCos) ux) zi)))