
(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 24 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 (asin (* (* maxCos (- 1.0 ux)) ux)))
(t_1 (* (* (- 1.0 ux) maxCos) ux))
(t_2 (fma (- uy) (* (PI) 2.0) (/ (PI) 2.0))))
(+
(+
(* (/ (+ (sin (- t_2 t_0)) (sin (+ t_2 t_0))) 2.0) xi)
(* (* (sin (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* t_1 t_1)))) yi))
(* t_1 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin^{-1} \left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right)\\
t_1 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_2 := \mathsf{fma}\left(-uy, \mathsf{PI}\left(\right) \cdot 2, \frac{\mathsf{PI}\left(\right)}{2}\right)\\
\left(\frac{\sin \left(t\_2 - t\_0\right) + \sin \left(t\_2 + t\_0\right)}{2} \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_1 \cdot t\_1}\right) \cdot yi\right) + t\_1 \cdot zi
\end{array}
\end{array}
Initial program 98.8%
lift-*.f32N/A
lift-cos.f32N/A
cos-neg-revN/A
sin-+PI/2-revN/A
lift-sqrt.f32N/A
lift--.f32N/A
lift-*.f32N/A
cos-asin-revN/A
sin-cos-multN/A
lower-/.f32N/A
Applied rewrites99.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) uy)))
(fma
(sin (fma (* -2.0 (PI)) uy (/ (PI) 2.0)))
xi
(fma
(* 2.0 (* (sin t_0) (cos t_0)))
yi
(* (* (* (- 1.0 ux) zi) ux) maxCos)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot uy\\
\mathsf{fma}\left(\sin \left(\mathsf{fma}\left(-2 \cdot \mathsf{PI}\left(\right), uy, \frac{\mathsf{PI}\left(\right)}{2}\right)\right), xi, \mathsf{fma}\left(2 \cdot \left(\sin t\_0 \cdot \cos t\_0\right), yi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)\right)
\end{array}
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Applied rewrites98.8%
Applied rewrites98.9%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (sin (fma (* -2.0 (PI)) uy (/ (PI) 2.0))) xi (fma (- 1.0 ux) (* (* zi maxCos) ux) (* (sin (* (* uy (PI)) 2.0)) yi))))
\begin{array}{l}
\\
\mathsf{fma}\left(\sin \left(\mathsf{fma}\left(-2 \cdot \mathsf{PI}\left(\right), uy, \frac{\mathsf{PI}\left(\right)}{2}\right)\right), xi, \mathsf{fma}\left(1 - ux, \left(zi \cdot maxCos\right) \cdot ux, \sin \left(\left(uy \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right) \cdot yi\right)\right)
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Applied rewrites98.8%
Applied rewrites98.9%
Applied rewrites98.9%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (- 1.0 ux) (* (* ux maxCos) zi) (fma (cos (* -2.0 (* (PI) uy))) xi (* (sin (* (* 2.0 uy) (PI))) yi))))
\begin{array}{l}
\\
\mathsf{fma}\left(1 - ux, \left(ux \cdot maxCos\right) \cdot zi, \mathsf{fma}\left(\cos \left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\right), xi, \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot yi\right)\right)
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Applied rewrites98.8%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (sin (* (* 2.0 uy) (PI))) yi (fma (* zi (* (- 1.0 ux) maxCos)) ux (* (cos (* -2.0 (* (PI) uy))) xi))))
\begin{array}{l}
\\
\mathsf{fma}\left(\sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right), yi, \mathsf{fma}\left(zi \cdot \left(\left(1 - ux\right) \cdot maxCos\right), ux, \cos \left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\right) \cdot xi\right)\right)
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Applied rewrites98.8%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (let* ((t_0 (* (* (PI) uy) 2.0))) (fma (cos t_0) xi (fma (sin t_0) yi (* (* (* (- 1.0 ux) zi) ux) maxCos)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
\mathsf{fma}\left(\cos t\_0, xi, \mathsf{fma}\left(\sin t\_0, yi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)\right)
\end{array}
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (let* ((t_0 (* (* (PI) uy) 2.0))) (fma (cos t_0) xi (fma (sin t_0) yi (* (* zi ux) maxCos)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
\mathsf{fma}\left(\cos t\_0, xi, \mathsf{fma}\left(\sin t\_0, yi, \left(zi \cdot ux\right) \cdot maxCos\right)\right)
\end{array}
\end{array}
Initial program 98.8%
Taylor expanded in ux around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites95.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) uy)))
(if (<= uy 0.004000000189989805)
(fma
(fma
(fma
(* (* (pow (PI) 3.0) yi) uy)
-1.3333333333333333
(* -2.0 (* (* (PI) (PI)) xi)))
uy
(* (* yi (PI)) 2.0))
uy
(fma (* (* zi (- 1.0 ux)) ux) maxCos xi))
(fma (cos (* -2.0 t_0)) xi (* (sin (* t_0 2.0)) yi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot uy\\
\mathbf{if}\;uy \leq 0.004000000189989805:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\left({\mathsf{PI}\left(\right)}^{3} \cdot yi\right) \cdot uy, -1.3333333333333333, -2 \cdot \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot xi\right)\right), uy, \left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right), uy, \mathsf{fma}\left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux, maxCos, xi\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(-2 \cdot t\_0\right), xi, \sin \left(t\_0 \cdot 2\right) \cdot yi\right)\\
\end{array}
\end{array}
if uy < 0.00400000019Initial program 99.2%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites99.1%
Taylor expanded in uy around 0
Applied rewrites97.4%
Taylor expanded in uy around 0
Applied rewrites99.2%
if 0.00400000019 < uy Initial program 98.0%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites97.8%
Taylor expanded in zi around 0
Applied rewrites93.9%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (fma (* -2.0 (* uy uy)) (* (PI) (PI)) 1.0) xi (fma (sin (* (* (PI) uy) 2.0)) yi (* (* (* (- 1.0 ux) zi) ux) maxCos))))
\begin{array}{l}
\\
\mathsf{fma}\left(\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right), xi, \mathsf{fma}\left(\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right), yi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)\right)
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Taylor expanded in uy around 0
Applied rewrites92.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (* (- 1.0 ux) zi) ux) maxCos)) (t_1 (* (* (PI) uy) 2.0)))
(if (<= yi 1.3999999839026675e-15)
(fma (cos t_1) xi (fma (* (* (PI) yi) uy) 2.0 t_0))
(fma 1.0 xi (fma (sin t_1) yi t_0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\\
t_1 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
\mathbf{if}\;yi \leq 1.3999999839026675 \cdot 10^{-15}:\\
\;\;\;\;\mathsf{fma}\left(\cos t\_1, xi, \mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot yi\right) \cdot uy, 2, t\_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1, xi, \mathsf{fma}\left(\sin t\_1, yi, t\_0\right)\right)\\
\end{array}
\end{array}
if yi < 1.39999998e-15Initial program 98.9%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.8%
Taylor expanded in uy around 0
Applied rewrites93.9%
if 1.39999998e-15 < yi Initial program 98.6%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.4%
Taylor expanded in uy around 0
Applied rewrites96.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) (PI))))
(*
(-
(fma
maxCos
(/ zi ux)
(+
(/ (fma (* uy yi) (* (PI) 2.0) xi) (* ux ux))
(*
uy
(*
(/
(fma
(* (* (* t_0 (PI)) yi) uy)
-1.3333333333333333
(* -2.0 (* t_0 xi)))
(* ux ux))
uy))))
(* zi maxCos))
(* ux ux))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
\left(\mathsf{fma}\left(maxCos, \frac{zi}{ux}, \frac{\mathsf{fma}\left(uy \cdot yi, \mathsf{PI}\left(\right) \cdot 2, xi\right)}{ux \cdot ux} + uy \cdot \left(\frac{\mathsf{fma}\left(\left(\left(t\_0 \cdot \mathsf{PI}\left(\right)\right) \cdot yi\right) \cdot uy, -1.3333333333333333, -2 \cdot \left(t\_0 \cdot xi\right)\right)}{ux \cdot ux} \cdot uy\right)\right) - zi \cdot maxCos\right) \cdot \left(ux \cdot ux\right)
\end{array}
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Taylor expanded in ux around inf
Applied rewrites98.4%
Taylor expanded in uy around 0
Applied rewrites88.2%
Applied rewrites88.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(if (<= uy 0.07000000029802322)
(+
(fma
(* -2.0 (- (* (* (* (PI) (PI)) xi) uy) (* (PI) yi)))
uy
(* (* (* (- 1.0 ux) ux) zi) maxCos))
xi)
(* (sin (* (PI) (fma -2.0 uy 0.5))) xi)))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \leq 0.07000000029802322:\\
\;\;\;\;\mathsf{fma}\left(-2 \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot xi\right) \cdot uy - \mathsf{PI}\left(\right) \cdot yi\right), uy, \left(\left(\left(1 - ux\right) \cdot ux\right) \cdot zi\right) \cdot maxCos\right) + xi\\
\mathbf{else}:\\
\;\;\;\;\sin \left(\mathsf{PI}\left(\right) \cdot \mathsf{fma}\left(-2, uy, 0.5\right)\right) \cdot xi\\
\end{array}
\end{array}
if uy < 0.0700000003Initial program 99.2%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites99.1%
Taylor expanded in uy around 0
Applied rewrites92.8%
Applied rewrites92.9%
if 0.0700000003 < uy Initial program 96.5%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites96.5%
Applied rewrites96.4%
Applied rewrites97.6%
Taylor expanded in xi around inf
Applied rewrites58.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(if (<= uy 0.07000000029802322)
(+
(fma
(* -2.0 (- (* (* (* (PI) (PI)) xi) uy) (* (PI) yi)))
uy
(* (* (* (- 1.0 ux) ux) zi) maxCos))
xi)
(* (cos (* -2.0 (* (PI) uy))) xi)))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \leq 0.07000000029802322:\\
\;\;\;\;\mathsf{fma}\left(-2 \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot xi\right) \cdot uy - \mathsf{PI}\left(\right) \cdot yi\right), uy, \left(\left(\left(1 - ux\right) \cdot ux\right) \cdot zi\right) \cdot maxCos\right) + xi\\
\mathbf{else}:\\
\;\;\;\;\cos \left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\right) \cdot xi\\
\end{array}
\end{array}
if uy < 0.0700000003Initial program 99.2%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites99.1%
Taylor expanded in uy around 0
Applied rewrites92.8%
Applied rewrites92.9%
if 0.0700000003 < uy Initial program 96.5%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites96.5%
Taylor expanded in xi around inf
Applied rewrites57.5%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (fma (* -2.0 (- (* (* (* (PI) (PI)) xi) uy) (* (PI) yi))) uy (* (* (* (- 1.0 ux) ux) zi) maxCos)) xi))
\begin{array}{l}
\\
\mathsf{fma}\left(-2 \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot xi\right) \cdot uy - \mathsf{PI}\left(\right) \cdot yi\right), uy, \left(\left(\left(1 - ux\right) \cdot ux\right) \cdot zi\right) \cdot maxCos\right) + xi
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Taylor expanded in uy around 0
Applied rewrites85.0%
Applied rewrites85.1%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* -2.0 (- (* (* (* (PI) (PI)) xi) uy) (* yi (PI)))) uy (fma (* (* zi (- 1.0 ux)) ux) maxCos xi)))
\begin{array}{l}
\\
\mathsf{fma}\left(-2 \cdot \left(\left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot xi\right) \cdot uy - yi \cdot \mathsf{PI}\left(\right)\right), uy, \mathsf{fma}\left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux, maxCos, xi\right)\right)
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Applied rewrites98.8%
Taylor expanded in uy around 0
Applied rewrites85.1%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* -2.0 uy) (fma (PI) (* (PI) (* xi uy)) (* (- (PI)) yi)) (fma (* maxCos ux) zi xi)))
\begin{array}{l}
\\
\mathsf{fma}\left(-2 \cdot uy, \mathsf{fma}\left(\mathsf{PI}\left(\right), \mathsf{PI}\left(\right) \cdot \left(xi \cdot uy\right), \left(-\mathsf{PI}\left(\right)\right) \cdot yi\right), \mathsf{fma}\left(maxCos \cdot ux, zi, xi\right)\right)
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Taylor expanded in uy around 0
Applied rewrites85.0%
Taylor expanded in ux around 0
Applied rewrites82.3%
Applied rewrites82.3%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* -2.0 uy) (- (* (* (* (PI) (PI)) xi) uy) (* yi (PI))) (fma (* maxCos ux) zi xi)))
\begin{array}{l}
\\
\mathsf{fma}\left(-2 \cdot uy, \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot xi\right) \cdot uy - yi \cdot \mathsf{PI}\left(\right), \mathsf{fma}\left(maxCos \cdot ux, zi, xi\right)\right)
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Taylor expanded in uy around 0
Applied rewrites85.0%
Taylor expanded in ux around 0
Applied rewrites82.3%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* (* yi (PI)) uy) 2.0 (fma (* (* zi (- 1.0 ux)) ux) maxCos xi)))
\begin{array}{l}
\\
\mathsf{fma}\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy, 2, \mathsf{fma}\left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux, maxCos, xi\right)\right)
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Applied rewrites98.8%
Taylor expanded in uy around 0
Applied rewrites80.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(if (<= yi -1.0000000036274937e-15)
(* (* (* yi (PI)) uy) 2.0)
(if (<= yi 9.9999998245167e-14)
(fma (* ux maxCos) (* (- 1.0 ux) zi) xi)
(* (PI) (* yi (* 2.0 uy))))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;yi \leq -1.0000000036274937 \cdot 10^{-15}:\\
\;\;\;\;\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2\\
\mathbf{elif}\;yi \leq 9.9999998245167 \cdot 10^{-14}:\\
\;\;\;\;\mathsf{fma}\left(ux \cdot maxCos, \left(1 - ux\right) \cdot zi, xi\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{PI}\left(\right) \cdot \left(yi \cdot \left(2 \cdot uy\right)\right)\\
\end{array}
\end{array}
if yi < -1e-15Initial program 99.1%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Taylor expanded in uy around 0
Applied rewrites87.5%
Taylor expanded in yi around inf
Applied rewrites55.3%
if -1e-15 < yi < 9.99999982e-14Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.9%
Taylor expanded in uy around 0
Applied rewrites65.0%
if 9.99999982e-14 < yi Initial program 98.6%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.4%
Taylor expanded in uy around 0
Applied rewrites78.8%
Taylor expanded in yi around inf
Applied rewrites51.6%
Applied rewrites51.7%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* -2.0 uy) (* (- yi) (PI)) (fma (* maxCos ux) zi xi)))
\begin{array}{l}
\\
\mathsf{fma}\left(-2 \cdot uy, \left(-yi\right) \cdot \mathsf{PI}\left(\right), \mathsf{fma}\left(maxCos \cdot ux, zi, xi\right)\right)
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Taylor expanded in uy around 0
Applied rewrites85.0%
Taylor expanded in ux around 0
Applied rewrites82.3%
Taylor expanded in xi around 0
Applied rewrites77.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* (* yi uy) (PI)) 2.0))
\begin{array}{l}
\\
\left(\left(yi \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot 2
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Taylor expanded in uy around 0
Applied rewrites85.0%
Taylor expanded in yi around inf
Applied rewrites32.4%
Applied rewrites32.4%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* (* yi uy) 2.0) (PI)))
\begin{array}{l}
\\
\left(\left(yi \cdot uy\right) \cdot 2\right) \cdot \mathsf{PI}\left(\right)
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Taylor expanded in uy around 0
Applied rewrites85.0%
Taylor expanded in yi around inf
Applied rewrites32.4%
Applied rewrites32.4%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (PI) (* yi (* 2.0 uy))))
\begin{array}{l}
\\
\mathsf{PI}\left(\right) \cdot \left(yi \cdot \left(2 \cdot uy\right)\right)
\end{array}
Initial program 98.8%
Taylor expanded in maxCos around 0
+-commutativeN/A
associate-+l+N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites98.7%
Taylor expanded in uy around 0
Applied rewrites85.0%
Taylor expanded in yi around inf
Applied rewrites32.4%
Applied rewrites32.4%
(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;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(4) function code(xi, yi, zi, ux, uy, maxcos)
use fmin_fmax_functions
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--.f3213.7
Applied rewrites13.7%
Taylor expanded in ux around 0
Applied rewrites12.6%
herbie shell --seed 2024352
(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)))