
(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 22 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 (* (* maxCos (- 1.0 ux)) ux))
(t_1 (sqrt (- 1.0 (* t_0 t_0))))
(t_2 (* (PI) (* 2.0 uy))))
(-
(+ (* yi (* (sin t_2) t_1)) (* xi (* t_1 (cos t_2))))
(* (* (* (- ux 1.0) maxCos) zi) ux))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\\
\left(yi \cdot \left(\sin t\_2 \cdot t\_1\right) + xi \cdot \left(t\_1 \cdot \cos t\_2\right)\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot zi\right) \cdot ux
\end{array}
\end{array}
Initial program 99.1%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3299.1
lift-*.f32N/A
*-commutativeN/A
lower-*.f3299.1
Applied rewrites99.1%
Final simplification99.1%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) (* 2.0 uy)))
(t_1 (* (* maxCos (- 1.0 ux)) ux))
(t_2 (sqrt (- 1.0 (* t_1 t_1)))))
(+
(* (* (- 1.0 ux) ux) (* zi maxCos))
(+ (* yi (* (sin t_0) t_2)) (* xi (* t_2 (cos t_0)))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\\
t_1 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
t_2 := \sqrt{1 - t\_1 \cdot t\_1}\\
\left(\left(1 - ux\right) \cdot ux\right) \cdot \left(zi \cdot maxCos\right) + \left(yi \cdot \left(\sin t\_0 \cdot t\_2\right) + xi \cdot \left(t\_2 \cdot \cos t\_0\right)\right)
\end{array}
\end{array}
Initial program 99.1%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f3299.1
Applied rewrites99.1%
Applied rewrites99.1%
Final simplification99.1%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0
(sqrt
(- 1.0 (* (* maxCos maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0))))))
(t_1 (* (* (PI) uy) 2.0))
(t_2
(+
(* (- (/ (* zi maxCos) ux) (* zi maxCos)) (* ux ux))
(* t_0 (* (cos t_1) xi)))))
(if (<= xi -9.999999998199587e-24)
t_2
(if (<= xi 1.0000000168623835e-16)
(- (* t_0 (* (sin t_1) yi)) (* (* (* (- ux 1.0) maxCos) zi) ux))
t_2))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right)}\\
t_1 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
t_2 := \left(\frac{zi \cdot maxCos}{ux} - zi \cdot maxCos\right) \cdot \left(ux \cdot ux\right) + t\_0 \cdot \left(\cos t\_1 \cdot xi\right)\\
\mathbf{if}\;xi \leq -9.999999998199587 \cdot 10^{-24}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;xi \leq 1.0000000168623835 \cdot 10^{-16}:\\
\;\;\;\;t\_0 \cdot \left(\sin t\_1 \cdot yi\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot zi\right) \cdot ux\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if xi < -1e-23 or 1.00000002e-16 < xi Initial program 99.3%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.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
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites76.6%
if -1e-23 < xi < 1.00000002e-16Initial program 98.6%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3298.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in xi around 0
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
Applied rewrites74.0%
Final simplification75.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(-
(+
(* (sin (* (* (PI) uy) 2.0)) yi)
(* xi (* (sqrt (- 1.0 (* t_0 t_0))) (cos (* (PI) (* 2.0 uy))))))
(* (* (* (- ux 1.0) maxCos) zi) ux))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
\left(\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi + xi \cdot \left(\sqrt{1 - t\_0 \cdot t\_0} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\right)\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot zi\right) \cdot ux
\end{array}
\end{array}
Initial program 99.1%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3299.1
lift-*.f32N/A
*-commutativeN/A
lower-*.f3299.1
Applied rewrites99.1%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.9
Applied rewrites98.9%
Final simplification98.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(+
(+
(* (sin (* (* (PI) uy) 2.0)) yi)
(* xi (* (sqrt (- 1.0 (* t_0 t_0))) (cos (* (PI) (* 2.0 uy))))))
(* (* (- 1.0 ux) ux) (* zi maxCos)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
\left(\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi + xi \cdot \left(\sqrt{1 - t\_0 \cdot t\_0} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\right)\right) + \left(\left(1 - ux\right) \cdot ux\right) \cdot \left(zi \cdot maxCos\right)
\end{array}
\end{array}
Initial program 99.1%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f3299.1
Applied rewrites99.1%
Applied rewrites99.1%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.9
Applied rewrites98.9%
Final simplification98.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(-
(+
(* (cos (* (* (PI) uy) 2.0)) xi)
(* yi (* (sin (* (PI) (* 2.0 uy))) (sqrt (- 1.0 (* t_0 t_0))))))
(* (* (* (- ux 1.0) maxCos) zi) ux))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
\left(\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot xi + yi \cdot \left(\sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right)\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot zi\right) \cdot ux
\end{array}
\end{array}
Initial program 99.1%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3299.1
lift-*.f32N/A
*-commutativeN/A
lower-*.f3299.1
Applied rewrites99.1%
Taylor expanded in maxCos around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.8
Applied rewrites98.8%
Final simplification98.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(+
(+
(* (cos (* (* (PI) uy) 2.0)) xi)
(* yi (* (sin (* (PI) (* 2.0 uy))) (sqrt (- 1.0 (* t_0 t_0))))))
(* (* (- 1.0 ux) ux) (* zi maxCos)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
\left(\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot xi + yi \cdot \left(\sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right)\right) + \left(\left(1 - ux\right) \cdot ux\right) \cdot \left(zi \cdot maxCos\right)
\end{array}
\end{array}
Initial program 99.1%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f3299.1
Applied rewrites99.1%
Applied rewrites99.1%
Taylor expanded in maxCos around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.8
Applied rewrites98.8%
Final simplification98.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(-
(+
(* (cos (* (* (PI) uy) 2.0)) xi)
(* yi (* (sin (* (PI) (* 2.0 uy))) (sqrt (- 1.0 (* t_0 t_0))))))
(* (* (* (- ux 1.0) maxCos) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
\left(\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot xi + yi \cdot \left(\sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right)\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 99.1%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.8
Applied rewrites98.8%
Final simplification98.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0
(sqrt
(- 1.0 (* (* maxCos maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0))))))
(t_1 (* (* (* (- ux 1.0) maxCos) zi) ux))
(t_2 (* (* (PI) uy) 2.0))
(t_3 (- (* t_0 (* (cos t_2) xi)) t_1)))
(if (<= xi -9.999999998199587e-24)
t_3
(if (<= xi 1.0000000168623835e-16)
(- (* t_0 (* (sin t_2) yi)) t_1)
t_3))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right)}\\
t_1 := \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot zi\right) \cdot ux\\
t_2 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
t_3 := t\_0 \cdot \left(\cos t\_2 \cdot xi\right) - t\_1\\
\mathbf{if}\;xi \leq -9.999999998199587 \cdot 10^{-24}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;xi \leq 1.0000000168623835 \cdot 10^{-16}:\\
\;\;\;\;t\_0 \cdot \left(\sin t\_2 \cdot yi\right) - t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if xi < -1e-23 or 1.00000002e-16 < xi Initial program 99.3%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3299.4
lift-*.f32N/A
*-commutativeN/A
lower-*.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
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites76.6%
if -1e-23 < xi < 1.00000002e-16Initial program 98.6%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3298.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in xi around 0
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
Applied rewrites74.0%
Final simplification75.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) uy) 2.0))
(t_1
(sqrt
(- 1.0 (* (* maxCos maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0))))))
(t_2 (* t_1 (* (cos t_0) xi))))
(if (<= xi -9.999999960041972e-13)
t_2
(if (<= xi 1.0000000168623835e-16)
(- (* t_1 (* (sin t_0) yi)) (* (* (* (- ux 1.0) maxCos) zi) ux))
t_2))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
t_1 := \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right)}\\
t_2 := t\_1 \cdot \left(\cos t\_0 \cdot xi\right)\\
\mathbf{if}\;xi \leq -9.999999960041972 \cdot 10^{-13}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;xi \leq 1.0000000168623835 \cdot 10^{-16}:\\
\;\;\;\;t\_1 \cdot \left(\sin t\_0 \cdot yi\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot zi\right) \cdot ux\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if xi < -9.99999996e-13 or 1.00000002e-16 < xi Initial program 99.5%
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
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites80.8%
if -9.99999996e-13 < xi < 1.00000002e-16Initial program 98.7%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3298.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in xi around 0
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
Applied rewrites68.2%
Final simplification74.1%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) uy) 2.0))
(t_1
(*
(sqrt
(- 1.0 (* (* maxCos maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0)))))
(* (cos t_0) xi))))
(if (<= xi -9.999999960041972e-13)
t_1
(if (<= xi 1.0000000168623835e-16)
(- (* (sin t_0) yi) (* (* (* (- ux 1.0) maxCos) zi) ux))
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
t_1 := \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right)} \cdot \left(\cos t\_0 \cdot xi\right)\\
\mathbf{if}\;xi \leq -9.999999960041972 \cdot 10^{-13}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;xi \leq 1.0000000168623835 \cdot 10^{-16}:\\
\;\;\;\;\sin t\_0 \cdot yi - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot zi\right) \cdot ux\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if xi < -9.99999996e-13 or 1.00000002e-16 < xi Initial program 99.5%
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
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites80.8%
if -9.99999996e-13 < xi < 1.00000002e-16Initial program 98.7%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3298.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in xi around 0
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
Applied rewrites68.2%
Taylor expanded in maxCos around 0
Applied rewrites67.8%
Final simplification73.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (- ux 1.0) maxCos))
(t_1
(*
(sqrt
(- 1.0 (* (* maxCos maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0)))))
xi)))
(if (<= xi -9.999999960041972e-13)
(+ t_1 (* (- (/ (* zi maxCos) ux) (* zi maxCos)) (* ux ux)))
(if (<= xi 1.60000000580399e-14)
(- (* (sin (* (* (PI) uy) 2.0)) yi) (* (* t_0 zi) ux))
(- t_1 (* (* t_0 ux) zi))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(ux - 1\right) \cdot maxCos\\
t_1 := \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right)} \cdot xi\\
\mathbf{if}\;xi \leq -9.999999960041972 \cdot 10^{-13}:\\
\;\;\;\;t\_1 + \left(\frac{zi \cdot maxCos}{ux} - zi \cdot maxCos\right) \cdot \left(ux \cdot ux\right)\\
\mathbf{elif}\;xi \leq 1.60000000580399 \cdot 10^{-14}:\\
\;\;\;\;\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi - \left(t\_0 \cdot zi\right) \cdot ux\\
\mathbf{else}:\\
\;\;\;\;t\_1 - \left(t\_0 \cdot ux\right) \cdot zi\\
\end{array}
\end{array}
if xi < -9.99999996e-13Initial program 99.3%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f3299.3
Applied rewrites99.3%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3271.8
Applied rewrites71.8%
if -9.99999996e-13 < xi < 1.60000001e-14Initial program 98.7%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3298.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in xi around 0
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
Applied rewrites67.1%
Taylor expanded in maxCos around 0
Applied rewrites66.8%
if 1.60000001e-14 < xi Initial program 99.7%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3266.6
Applied rewrites66.6%
Final simplification67.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0
(*
(sqrt
(- 1.0 (* (* maxCos maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0)))))
xi))
(t_1 (* (- ux 1.0) maxCos)))
(if (<= xi -9.999999960041972e-13)
(+ (* (* (* zi (- 1.0 ux)) ux) maxCos) t_0)
(if (<= xi 1.60000000580399e-14)
(- (* (sin (* (* (PI) uy) 2.0)) yi) (* (* t_1 zi) ux))
(- t_0 (* (* t_1 ux) zi))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right)} \cdot xi\\
t_1 := \left(ux - 1\right) \cdot maxCos\\
\mathbf{if}\;xi \leq -9.999999960041972 \cdot 10^{-13}:\\
\;\;\;\;\left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot maxCos + t\_0\\
\mathbf{elif}\;xi \leq 1.60000000580399 \cdot 10^{-14}:\\
\;\;\;\;\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi - \left(t\_1 \cdot zi\right) \cdot ux\\
\mathbf{else}:\\
\;\;\;\;t\_0 - \left(t\_1 \cdot ux\right) \cdot zi\\
\end{array}
\end{array}
if xi < -9.99999996e-13Initial program 99.3%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f3299.3
Applied rewrites99.3%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3271.8
Applied rewrites71.8%
if -9.99999996e-13 < xi < 1.60000001e-14Initial program 98.7%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3298.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in xi around 0
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
Applied rewrites67.1%
Taylor expanded in maxCos around 0
Applied rewrites66.8%
if 1.60000001e-14 < xi Initial program 99.7%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3266.6
Applied rewrites66.6%
Final simplification67.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0
(+
(* (* (* zi (- 1.0 ux)) ux) maxCos)
(*
(sqrt
(- 1.0 (* (* maxCos maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0)))))
xi))))
(if (<= xi -9.999999960041972e-13)
t_0
(if (<= xi 1.60000000580399e-14)
(- (* (sin (* (* (PI) uy) 2.0)) yi) (* (* (* (- ux 1.0) maxCos) zi) ux))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot maxCos + \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right)} \cdot xi\\
\mathbf{if}\;xi \leq -9.999999960041972 \cdot 10^{-13}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;xi \leq 1.60000000580399 \cdot 10^{-14}:\\
\;\;\;\;\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot zi\right) \cdot ux\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if xi < -9.99999996e-13 or 1.60000001e-14 < xi Initial program 99.5%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f3299.5
Applied rewrites99.5%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3269.3
Applied rewrites69.3%
if -9.99999996e-13 < xi < 1.60000001e-14Initial program 98.7%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3298.8
lift-*.f32N/A
*-commutativeN/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in xi around 0
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
Applied rewrites67.1%
Taylor expanded in maxCos around 0
Applied rewrites66.8%
Final simplification67.9%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (- (* (sin (* (* (PI) uy) 2.0)) yi) (* (* (* (- ux 1.0) maxCos) zi) ux)))
\begin{array}{l}
\\
\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot zi\right) \cdot ux
\end{array}
Initial program 99.1%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3299.1
lift-*.f32N/A
*-commutativeN/A
lower-*.f3299.1
Applied rewrites99.1%
Taylor expanded in xi around 0
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
Applied rewrites43.5%
Taylor expanded in maxCos around 0
Applied rewrites43.3%
Final simplification43.3%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (sin (* (* (PI) uy) 2.0)) yi))
\begin{array}{l}
\\
\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi
\end{array}
Initial program 99.1%
Taylor expanded in yi around inf
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
Applied rewrites38.2%
Taylor expanded in maxCos around 0
Applied rewrites38.0%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* (* (* yi (PI)) uy) 2.0) (fma (* (+ -0.5 ux) (* maxCos maxCos)) (* ux ux) 1.0)))
\begin{array}{l}
\\
\left(\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2\right) \cdot \mathsf{fma}\left(\left(-0.5 + ux\right) \cdot \left(maxCos \cdot maxCos\right), ux \cdot ux, 1\right)
\end{array}
Initial program 99.1%
Taylor expanded in yi around inf
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
Applied rewrites38.2%
Taylor expanded in ux around 0
Applied rewrites18.1%
Taylor expanded in uy around 0
Applied rewrites31.6%
Final simplification31.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (fma (* -0.5 (* maxCos maxCos)) (* ux ux) 1.0) (* (* (* yi (PI)) uy) 2.0)))
\begin{array}{l}
\\
\mathsf{fma}\left(-0.5 \cdot \left(maxCos \cdot maxCos\right), ux \cdot ux, 1\right) \cdot \left(\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2\right)
\end{array}
Initial program 99.1%
Taylor expanded in yi around inf
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
Applied rewrites38.2%
Taylor expanded in ux around 0
Applied rewrites18.1%
Taylor expanded in ux around 0
Applied rewrites18.1%
Taylor expanded in uy around 0
Applied rewrites31.6%
Final simplification31.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* (* maxCos ux) zi) (- 1.0 ux)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return ((maxCos * ux) * zi) * (1.0f - ux);
}
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 * ux) * zi) * (1.0e0 - ux)
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(maxCos * ux) * zi) * Float32(Float32(1.0) - ux)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = ((maxCos * ux) * zi) * (single(1.0) - ux); end
\begin{array}{l}
\\
\left(\left(maxCos \cdot ux\right) \cdot zi\right) \cdot \left(1 - ux\right)
\end{array}
Initial program 99.1%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f3212.5
Applied rewrites12.5%
Applied rewrites12.5%
Final simplification12.5%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* (- zi (* zi ux)) ux) maxCos))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return ((zi - (zi * ux)) * 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 - (zi * ux)) * ux) * maxcos
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(zi - Float32(zi * ux)) * ux) * maxCos) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = ((zi - (zi * ux)) * ux) * maxCos; end
\begin{array}{l}
\\
\left(\left(zi - zi \cdot ux\right) \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
lower-*.f32N/A
lower--.f3212.5
Applied rewrites12.5%
Taylor expanded in ux around 0
Applied rewrites12.5%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* zi (* maxCos (- 1.0 ux))) ux))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (zi * (maxCos * (1.0f - ux))) * ux;
}
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 * (maxcos * (1.0e0 - ux))) * ux
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(zi * Float32(maxCos * Float32(Float32(1.0) - ux))) * ux) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (zi * (maxCos * (single(1.0) - ux))) * ux; end
\begin{array}{l}
\\
\left(zi \cdot \left(maxCos \cdot \left(1 - ux\right)\right)\right) \cdot ux
\end{array}
Initial program 99.1%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f3212.5
Applied rewrites12.5%
Applied rewrites12.5%
(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
lower-*.f32N/A
lower--.f3212.5
Applied rewrites12.5%
Taylor expanded in ux around 0
Applied rewrites11.5%
herbie shell --seed 2024255
(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)))