
(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 17 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 ux) 1.0) ux) maxCos) (+ ux 1.0)) zi))))\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) - \frac{\left(\left(ux \cdot ux - 1\right) \cdot ux\right) \cdot maxCos}{ux + 1} \cdot zi
\end{array}
\end{array}
Initial program 98.8%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lift--.f32N/A
flip--N/A
associate-*l/N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
metadata-evalN/A
lower--.f32N/A
lower-*.f32N/A
lower-*.f3298.8
Applied rewrites98.8%
lift-/.f32N/A
lift-/.f32N/A
clear-numN/A
lower-/.f3298.8
lift-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3298.8
Applied rewrites98.8%
Final simplification98.8%
(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)))))
(+
(* (* (- maxCos (* maxCos ux)) ux) zi)
(+ (* 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(maxCos - maxCos \cdot ux\right) \cdot ux\right) \cdot zi + \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 98.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.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)))
(-
(+
(* (sin (* (* (PI) uy) 2.0)) yi)
(* xi (* (sqrt (- 1.0 (* t_0 t_0))) (cos (* (PI) (* 2.0 uy))))))
(* (* (- 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(\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(ux - 1\right) \cdot \left(maxCos \cdot ux\right)\right) \cdot zi
\end{array}
\end{array}
Initial program 98.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.8
Applied rewrites98.8%
lift-*.f32N/A
lift--.f32N/A
lift-*.f32N/A
associate-*l*N/A
lift-*.f32N/A
lower-*.f32N/A
lift--.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)))
(-
(+
(* (sin (* (* (PI) uy) 2.0)) yi)
(* xi (* (sqrt (- 1.0 (* t_0 t_0))) (cos (* (PI) (* 2.0 uy))))))
(* (* (* (- 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(\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 ux\right) \cdot zi
\end{array}
\end{array}
Initial program 98.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower-sin.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))))))
(* (* (- maxCos (* maxCos ux)) 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(maxCos - maxCos \cdot ux\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 98.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in ux around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.7
Applied rewrites98.7%
Final simplification98.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) uy) 2.0)))
(-
(+ (* (cos t_0) xi) (* (sin t_0) yi))
(* (* (* (- ux 1.0) maxCos) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
\left(\cos t\_0 \cdot xi + \sin t\_0 \cdot yi\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 98.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.8
Applied rewrites98.8%
Taylor expanded in ux around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.6
Applied rewrites98.6%
Final simplification98.6%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(+
(+
(* (* (* (* yi (PI)) uy) 2.0) 1.0)
(* xi (* (sqrt (- 1.0 (* t_0 t_0))) (cos (* (PI) (* 2.0 uy))))))
(* (* (- maxCos (* maxCos ux)) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
\left(\left(\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2\right) \cdot 1 + 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(maxCos - maxCos \cdot ux\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 98.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in uy around 0
associate-*r*N/A
lower-*.f32N/A
lower-*.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
sub-negN/A
lower--.f32N/A
Applied rewrites90.3%
Taylor expanded in ux around 0
Applied rewrites90.3%
Final simplification90.3%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (* (+ (* (* (* yi (PI)) uy) 2.0) xi) (sqrt (- 1.0 (* (* maxCos maxCos) (* (pow (- 1.0 ux) 2.0) (* ux ux)))))) (* (* (- maxCos (* maxCos ux)) ux) zi)))
\begin{array}{l}
\\
\left(\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2 + xi\right) \cdot \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left({\left(1 - ux\right)}^{2} \cdot \left(ux \cdot ux\right)\right)} + \left(\left(maxCos - maxCos \cdot ux\right) \cdot ux\right) \cdot zi
\end{array}
Initial program 98.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in uy around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites57.8%
Applied rewrites83.0%
Final simplification83.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* yi (sin (* (PI) (* 2.0 uy)))) (* (* zi ux) maxCos))))
(if (<= yi -4.999999980020986e-12)
t_0
(if (<= yi 4.999999969612645e-9)
(+
(*
(sqrt
(- 1.0 (* (* maxCos maxCos) (* (pow (- 1.0 ux) 2.0) (* ux ux)))))
xi)
(* (* (- maxCos (* maxCos ux)) ux) zi))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := yi \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) + \left(zi \cdot ux\right) \cdot maxCos\\
\mathbf{if}\;yi \leq -4.999999980020986 \cdot 10^{-12}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;yi \leq 4.999999969612645 \cdot 10^{-9}:\\
\;\;\;\;\sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left({\left(1 - ux\right)}^{2} \cdot \left(ux \cdot ux\right)\right)} \cdot xi + \left(\left(maxCos - maxCos \cdot ux\right) \cdot ux\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if yi < -4.99999998e-12 or 4.99999997e-9 < yi Initial program 98.9%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites6.7%
Taylor expanded in ux around 0
Applied rewrites7.4%
Applied rewrites69.0%
if -4.99999998e-12 < yi < 4.99999997e-9Initial program 98.7%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites71.5%
Final simplification70.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (fma (* (* yi (PI)) uy) 2.0 xi))
(t_1 (+ (* yi (sin (* (PI) (* 2.0 uy)))) (* (* zi ux) maxCos))))
(if (<= yi -4.999999980020986e-12)
t_1
(if (<= yi 4.999999969612645e-9)
(+
(fma (* (* (+ -0.5 ux) (* maxCos maxCos)) t_0) (* ux ux) t_0)
(* (* (- maxCos (* maxCos ux)) ux) zi))
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy, 2, xi\right)\\
t_1 := yi \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) + \left(zi \cdot ux\right) \cdot maxCos\\
\mathbf{if}\;yi \leq -4.999999980020986 \cdot 10^{-12}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;yi \leq 4.999999969612645 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(-0.5 + ux\right) \cdot \left(maxCos \cdot maxCos\right)\right) \cdot t\_0, ux \cdot ux, t\_0\right) + \left(\left(maxCos - maxCos \cdot ux\right) \cdot ux\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if yi < -4.99999998e-12 or 4.99999997e-9 < yi Initial program 98.9%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites5.5%
Taylor expanded in ux around 0
Applied rewrites7.4%
Applied rewrites69.0%
if -4.99999998e-12 < yi < 4.99999997e-9Initial program 98.7%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in uy around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites71.5%
Taylor expanded in ux around 0
Applied rewrites71.3%
Final simplification48.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (sin (* (* (PI) uy) 2.0)) yi))
(t_1 (fma (* (* yi (PI)) uy) 2.0 xi)))
(if (<= yi -4.999999980020986e-12)
t_0
(if (<= yi 4.999999969612645e-9)
(+
(fma (* (* (+ -0.5 ux) (* maxCos maxCos)) t_1) (* ux ux) t_1)
(* (* (- maxCos (* maxCos ux)) ux) zi))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\\
t_1 := \mathsf{fma}\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy, 2, xi\right)\\
\mathbf{if}\;yi \leq -4.999999980020986 \cdot 10^{-12}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;yi \leq 4.999999969612645 \cdot 10^{-9}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(-0.5 + ux\right) \cdot \left(maxCos \cdot maxCos\right)\right) \cdot t\_1, ux \cdot ux, t\_1\right) + \left(\left(maxCos - maxCos \cdot ux\right) \cdot ux\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if yi < -4.99999998e-12 or 4.99999997e-9 < yi Initial program 98.9%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites5.4%
Taylor expanded in ux around 0
Applied rewrites67.4%
if -4.99999998e-12 < yi < 4.99999997e-9Initial program 98.7%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in uy around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites71.5%
Taylor expanded in ux around 0
Applied rewrites71.3%
Final simplification48.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* yi (PI)) uy))
(t_1 (fma (* maxCos ux) zi (* t_0 2.0)))
(t_2 (fma t_0 2.0 xi)))
(if (<= yi -4.999999980020986e-12)
t_1
(if (<= yi 5.000000058430487e-8)
(+
(fma (* (* (+ -0.5 ux) (* maxCos maxCos)) t_2) (* ux ux) t_2)
(* (* (- maxCos (* maxCos ux)) ux) zi))
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
t_1 := \mathsf{fma}\left(maxCos \cdot ux, zi, t\_0 \cdot 2\right)\\
t_2 := \mathsf{fma}\left(t\_0, 2, xi\right)\\
\mathbf{if}\;yi \leq -4.999999980020986 \cdot 10^{-12}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;yi \leq 5.000000058430487 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(\left(\left(-0.5 + ux\right) \cdot \left(maxCos \cdot maxCos\right)\right) \cdot t\_2, ux \cdot ux, t\_2\right) + \left(\left(maxCos - maxCos \cdot ux\right) \cdot ux\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if yi < -4.99999998e-12 or 5.00000006e-8 < yi Initial program 98.8%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites6.6%
Taylor expanded in ux around 0
Applied rewrites7.3%
Applied rewrites7.3%
Taylor expanded in uy around 0
Applied rewrites54.6%
if -4.99999998e-12 < yi < 5.00000006e-8Initial program 98.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in uy around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites71.2%
Taylor expanded in ux around 0
Applied rewrites71.0%
Final simplification66.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* yi (PI)) uy)) (t_1 (fma (* maxCos ux) zi (* t_0 2.0))))
(if (<= yi -4.999999980020986e-12)
t_1
(if (<= yi 5.000000058430487e-8)
(+
(*
(fma 2.0 t_0 xi)
(fma (* (+ -0.5 ux) (* maxCos maxCos)) (* ux ux) 1.0))
(* (* (- maxCos (* maxCos ux)) ux) zi))
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
t_1 := \mathsf{fma}\left(maxCos \cdot ux, zi, t\_0 \cdot 2\right)\\
\mathbf{if}\;yi \leq -4.999999980020986 \cdot 10^{-12}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;yi \leq 5.000000058430487 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(2, t\_0, xi\right) \cdot \mathsf{fma}\left(\left(-0.5 + ux\right) \cdot \left(maxCos \cdot maxCos\right), ux \cdot ux, 1\right) + \left(\left(maxCos - maxCos \cdot ux\right) \cdot ux\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if yi < -4.99999998e-12 or 5.00000006e-8 < yi Initial program 98.8%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites5.3%
Taylor expanded in ux around 0
Applied rewrites7.8%
Applied rewrites7.3%
Taylor expanded in uy around 0
Applied rewrites55.3%
if -4.99999998e-12 < yi < 5.00000006e-8Initial program 98.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in uy around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites71.2%
Taylor expanded in ux around 0
Applied rewrites71.0%
Final simplification66.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* yi (PI)) uy)) (t_1 (fma (* maxCos ux) zi (* t_0 2.0))))
(if (<= yi -4.999999980020986e-12)
t_1
(if (<= yi 5.000000058430487e-8)
(+ (* (fma 2.0 t_0 xi) 1.0) (* (* (- maxCos (* maxCos ux)) ux) zi))
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
t_1 := \mathsf{fma}\left(maxCos \cdot ux, zi, t\_0 \cdot 2\right)\\
\mathbf{if}\;yi \leq -4.999999980020986 \cdot 10^{-12}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;yi \leq 5.000000058430487 \cdot 10^{-8}:\\
\;\;\;\;\mathsf{fma}\left(2, t\_0, xi\right) \cdot 1 + \left(\left(maxCos - maxCos \cdot ux\right) \cdot ux\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if yi < -4.99999998e-12 or 5.00000006e-8 < yi Initial program 98.8%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites5.4%
Taylor expanded in ux around 0
Applied rewrites7.3%
Applied rewrites7.3%
Taylor expanded in uy around 0
Applied rewrites55.3%
if -4.99999998e-12 < yi < 5.00000006e-8Initial program 98.8%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in uy around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites71.2%
Taylor expanded in ux around 0
Applied rewrites71.0%
Final simplification66.5%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (if (<= (* (* maxCos (- 1.0 ux)) ux) 6.469999883074173e-12) (fma (* maxCos ux) zi (* (* (* yi (PI)) uy) 2.0)) (* (* (* zi ux) maxCos) (- 1.0 ux))))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux \leq 6.469999883074173 \cdot 10^{-12}:\\
\;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, zi, \left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(zi \cdot ux\right) \cdot maxCos\right) \cdot \left(1 - ux\right)\\
\end{array}
\end{array}
if (*.f32 (*.f32 (-.f32 #s(literal 1 binary32) ux) maxCos) ux) < 6.46999988e-12Initial program 98.8%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites6.4%
Taylor expanded in ux around 0
Applied rewrites10.2%
Applied rewrites10.3%
Taylor expanded in uy around 0
Applied rewrites30.2%
if 6.46999988e-12 < (*.f32 (*.f32 (-.f32 #s(literal 1 binary32) ux) maxCos) ux) Initial program 98.7%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3236.6
Applied rewrites36.6%
Applied rewrites36.7%
Final simplification31.4%
(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 98.8%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3215.6
Applied rewrites15.6%
Applied rewrites15.7%
(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 98.8%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3215.6
Applied rewrites15.6%
Taylor expanded in ux around 0
Applied rewrites13.1%
herbie shell --seed 2024327
(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)))