
(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 (* (* (- 1.0 ux) maxCos) ux)) (t_1 (* (* uy 2.0) (PI))))
(+
(+
(* (* (cos t_1) (sqrt (- 1.0 (* t_0 t_0)))) xi)
(*
(*
(sin t_1)
(sqrt
(*
(-
(/
(+
(/ (- (/ 1.0 (* ux ux)) (* maxCos maxCos)) ux)
(* (* maxCos maxCos) 2.0))
ux)
(* maxCos maxCos))
(pow ux 4.0))))
yi))
(* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\\
\left(\left(\cos t\_1 \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot xi + \left(\sin t\_1 \cdot \sqrt{\left(\frac{\frac{\frac{1}{ux \cdot ux} - maxCos \cdot maxCos}{ux} + \left(maxCos \cdot maxCos\right) \cdot 2}{ux} - maxCos \cdot maxCos\right) \cdot {ux}^{4}}\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
\end{array}
Initial program 98.9%
Taylor expanded in ux around -inf
Applied rewrites98.9%
Final simplification98.9%
(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}
Initial program 98.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux)))
(+
(+
(* (* (cos (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* t_0 t_0)))) xi)
(* (sin (* (PI) (* 2.0 uy))) yi))
(* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot xi + \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
\end{array}
Initial program 98.9%
Taylor expanded in ux around 0
Applied rewrites98.8%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (fma (cos (* -2.0 (* (PI) uy))) xi (* (sin (* (PI) (* 2.0 uy))) yi)) (* (* (* (- 1.0 ux) maxCos) ux) zi)))
\begin{array}{l}
\\
\mathsf{fma}\left(\cos \left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\right), xi, \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
Initial program 98.9%
Taylor expanded in ux around 0
Applied rewrites98.2%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (cos (* -2.0 (* (PI) uy))) xi (fma (sin (* (PI) (* 2.0 uy))) yi (* (* (* (- 1.0 ux) zi) ux) maxCos))))
\begin{array}{l}
\\
\mathsf{fma}\left(\cos \left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\right), xi, \mathsf{fma}\left(\sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right), yi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)\right)
\end{array}
Initial program 98.9%
Taylor expanded in maxCos around 0
Applied rewrites98.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) uy)))
(if (<= uy 0.0022799998987466097)
(+
(fma (* maxCos ux) (* zi (- 1.0 ux)) xi)
(*
(fma
(fma
(* (* (pow (PI) 3.0) yi) uy)
-1.3333333333333333
(* (* (* (PI) (PI)) xi) -2.0))
uy
(* (* (PI) yi) 2.0))
uy))
(fma
(* zi ux)
maxCos
(fma (cos (* t_0 -2.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.0022799998987466097:\\
\;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, zi \cdot \left(1 - ux\right), xi\right) + \mathsf{fma}\left(\mathsf{fma}\left(\left({\mathsf{PI}\left(\right)}^{3} \cdot yi\right) \cdot uy, -1.3333333333333333, \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot xi\right) \cdot -2\right), uy, \left(\mathsf{PI}\left(\right) \cdot yi\right) \cdot 2\right) \cdot uy\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(zi \cdot ux, maxCos, \mathsf{fma}\left(\cos \left(t\_0 \cdot -2\right), xi, \sin \left(t\_0 \cdot 2\right) \cdot yi\right)\right)\\
\end{array}
\end{array}
if uy < 0.0022799999Initial program 99.2%
Taylor expanded in maxCos around 0
Applied rewrites98.3%
Taylor expanded in uy around 0
Applied rewrites98.4%
if 0.0022799999 < uy Initial program 98.1%
Taylor expanded in ux around -inf
Applied rewrites98.2%
Applied rewrites97.9%
Taylor expanded in ux around 0
Applied rewrites93.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) uy)))
(if (<= uy 0.0022799998987466097)
(+
(fma (* maxCos ux) (* zi (- 1.0 ux)) xi)
(*
(fma
(fma
(* (* (pow (PI) 3.0) yi) uy)
-1.3333333333333333
(* (* (* (PI) (PI)) xi) -2.0))
uy
(* (* (PI) yi) 2.0))
uy))
(fma
(* maxCos ux)
zi
(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.0022799998987466097:\\
\;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, zi \cdot \left(1 - ux\right), xi\right) + \mathsf{fma}\left(\mathsf{fma}\left(\left({\mathsf{PI}\left(\right)}^{3} \cdot yi\right) \cdot uy, -1.3333333333333333, \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot xi\right) \cdot -2\right), uy, \left(\mathsf{PI}\left(\right) \cdot yi\right) \cdot 2\right) \cdot uy\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(\cos \left(-2 \cdot t\_0\right), xi, \sin \left(t\_0 \cdot 2\right) \cdot yi\right)\right)\\
\end{array}
\end{array}
if uy < 0.0022799999Initial program 99.2%
Taylor expanded in maxCos around 0
Applied rewrites98.3%
Taylor expanded in uy around 0
Applied rewrites98.4%
if 0.0022799999 < uy Initial program 98.1%
Taylor expanded in ux around -inf
Applied rewrites98.2%
Taylor expanded in ux around 0
Applied rewrites93.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(if (<= uy 0.0022799998987466097)
(+
(fma (* maxCos ux) (* zi (- 1.0 ux)) xi)
(*
(fma
(fma
(* (* (pow (PI) 3.0) yi) uy)
-1.3333333333333333
(* (* (* (PI) (PI)) xi) -2.0))
uy
(* (* (PI) yi) 2.0))
uy))
(fma
(cos (* -2.0 (* (PI) uy)))
xi
(fma (sin (* (PI) (* 2.0 uy))) yi (* (* zi ux) maxCos)))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \leq 0.0022799998987466097:\\
\;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, zi \cdot \left(1 - ux\right), xi\right) + \mathsf{fma}\left(\mathsf{fma}\left(\left({\mathsf{PI}\left(\right)}^{3} \cdot yi\right) \cdot uy, -1.3333333333333333, \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot xi\right) \cdot -2\right), uy, \left(\mathsf{PI}\left(\right) \cdot yi\right) \cdot 2\right) \cdot uy\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\right), xi, \mathsf{fma}\left(\sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right), yi, \left(zi \cdot ux\right) \cdot maxCos\right)\right)\\
\end{array}
\end{array}
if uy < 0.0022799999Initial program 99.2%
Taylor expanded in maxCos around 0
Applied rewrites98.3%
Taylor expanded in uy around 0
Applied rewrites98.4%
if 0.0022799999 < uy Initial program 98.1%
Taylor expanded in ux around 0
Applied rewrites93.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(if (<= uy 0.010599999688565731)
(+
(fma (* maxCos ux) (* zi (- 1.0 ux)) xi)
(*
(fma
(fma
(* (* (pow (PI) 3.0) yi) uy)
-1.3333333333333333
(* (* (* (PI) (PI)) xi) -2.0))
uy
(* (* (PI) yi) 2.0))
uy))
(fma (cos (* -2.0 (* (PI) uy))) xi (* (sin (* (PI) (* 2.0 uy))) yi))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;uy \leq 0.010599999688565731:\\
\;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, zi \cdot \left(1 - ux\right), xi\right) + \mathsf{fma}\left(\mathsf{fma}\left(\left({\mathsf{PI}\left(\right)}^{3} \cdot yi\right) \cdot uy, -1.3333333333333333, \left(\left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right) \cdot xi\right) \cdot -2\right), uy, \left(\mathsf{PI}\left(\right) \cdot yi\right) \cdot 2\right) \cdot uy\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\right), xi, \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)\\
\end{array}
\end{array}
if uy < 0.0105999997Initial program 99.1%
Taylor expanded in maxCos around 0
Applied rewrites98.3%
Taylor expanded in uy around 0
Applied rewrites98.3%
if 0.0105999997 < uy Initial program 98.0%
Taylor expanded in ux around 0
Applied rewrites88.1%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (fma (* -2.0 (* uy uy)) (* (PI) (PI)) 1.0) xi (fma (sin (* (PI) (* 2.0 uy))) 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(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right), yi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)\right)
\end{array}
Initial program 98.9%
Taylor expanded in maxCos around 0
Applied rewrites98.2%
Taylor expanded in uy around 0
Applied rewrites92.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(if (<= yi -8.00000002901995e-15)
(fma
1.0
xi
(fma (sin (* (PI) (* 2.0 uy))) yi (* (* (* (- 1.0 ux) zi) ux) maxCos)))
(fma
(cos (* -2.0 (* (PI) uy)))
xi
(fma (* maxCos ux) (* zi (- 1.0 ux)) (* (* (* (PI) yi) uy) 2.0)))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;yi \leq -8.00000002901995 \cdot 10^{-15}:\\
\;\;\;\;\mathsf{fma}\left(1, xi, \mathsf{fma}\left(\sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right), yi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\right), xi, \mathsf{fma}\left(maxCos \cdot ux, zi \cdot \left(1 - ux\right), \left(\left(\mathsf{PI}\left(\right) \cdot yi\right) \cdot uy\right) \cdot 2\right)\right)\\
\end{array}
\end{array}
if yi < -8.00000003e-15Initial program 98.6%
Taylor expanded in maxCos around 0
Applied rewrites98.5%
Taylor expanded in uy around 0
Applied rewrites93.9%
if -8.00000003e-15 < yi Initial program 99.0%
Taylor expanded in maxCos around 0
Applied rewrites98.1%
Taylor expanded in uy around 0
Applied rewrites93.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* zi (- 1.0 ux))))
(if (<= uy 0.05000000074505806)
(+
(fma (* maxCos ux) t_0 xi)
(* (fma (PI) (* (* xi (PI)) (* uy -2.0)) (* (* yi (PI)) 2.0)) uy))
(fma (cos (* -2.0 (* (PI) uy))) xi (* (* maxCos ux) t_0)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := zi \cdot \left(1 - ux\right)\\
\mathbf{if}\;uy \leq 0.05000000074505806:\\
\;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, t\_0, xi\right) + \mathsf{fma}\left(\mathsf{PI}\left(\right), \left(xi \cdot \mathsf{PI}\left(\right)\right) \cdot \left(uy \cdot -2\right), \left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right) \cdot uy\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos \left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\right), xi, \left(maxCos \cdot ux\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if uy < 0.0500000007Initial program 99.1%
Taylor expanded in maxCos around 0
Applied rewrites98.3%
Taylor expanded in uy around 0
Applied rewrites93.4%
Applied rewrites93.4%
if 0.0500000007 < uy Initial program 97.9%
Taylor expanded in maxCos around 0
Applied rewrites97.7%
Taylor expanded in yi around 0
Applied rewrites63.4%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma 1.0 xi (fma (sin (* (PI) (* 2.0 uy))) yi (* (* (* (- 1.0 ux) zi) ux) maxCos))))
\begin{array}{l}
\\
\mathsf{fma}\left(1, xi, \mathsf{fma}\left(\sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right), yi, \left(\left(\left(1 - ux\right) \cdot zi\right) \cdot ux\right) \cdot maxCos\right)\right)
\end{array}
Initial program 98.9%
Taylor expanded in maxCos around 0
Applied rewrites98.2%
Taylor expanded in uy around 0
Applied rewrites88.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(if (<= (* (* (- 1.0 ux) maxCos) ux) 7.000000051862236e-17)
(+
(fma
(* -2.0 (- (* (* (* (PI) (PI)) xi) uy) (* (PI) yi)))
uy
(* (* zi ux) maxCos))
xi)
(*
(fma (* (- 1.0 ux) ux) maxCos (/ (fma (* uy yi) (* (PI) 2.0) xi) zi))
zi)))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux \leq 7.000000051862236 \cdot 10^{-17}:\\
\;\;\;\;\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(zi \cdot ux\right) \cdot maxCos\right) + xi\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(1 - ux\right) \cdot ux, maxCos, \frac{\mathsf{fma}\left(uy \cdot yi, \mathsf{PI}\left(\right) \cdot 2, xi\right)}{zi}\right) \cdot zi\\
\end{array}
\end{array}
if (*.f32 (*.f32 (-.f32 #s(literal 1 binary32) ux) maxCos) ux) < 7.00000005e-17Initial program 98.8%
Taylor expanded in maxCos around 0
Applied rewrites98.8%
Taylor expanded in uy around 0
Applied rewrites85.3%
Taylor expanded in ux around 0
Applied rewrites85.0%
if 7.00000005e-17 < (*.f32 (*.f32 (-.f32 #s(literal 1 binary32) ux) maxCos) ux) Initial program 99.0%
Taylor expanded in maxCos around 0
Applied rewrites97.2%
Taylor expanded in xi around inf
Applied rewrites40.2%
Taylor expanded in zi around inf
Applied rewrites97.2%
Taylor expanded in uy around 0
Applied rewrites86.1%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (fma (* maxCos ux) (* zi (- 1.0 ux)) xi) (* (fma (PI) (* (* xi (PI)) (* uy -2.0)) (* (* yi (PI)) 2.0)) uy)))
\begin{array}{l}
\\
\mathsf{fma}\left(maxCos \cdot ux, zi \cdot \left(1 - ux\right), xi\right) + \mathsf{fma}\left(\mathsf{PI}\left(\right), \left(xi \cdot \mathsf{PI}\left(\right)\right) \cdot \left(uy \cdot -2\right), \left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot 2\right) \cdot uy
\end{array}
Initial program 98.9%
Taylor expanded in maxCos around 0
Applied rewrites98.2%
Taylor expanded in uy around 0
Applied rewrites85.8%
Applied rewrites85.8%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (fma (* (- maxCos) (- (* zi ux) zi)) ux (* (* -2.0 (- (* (* (* (PI) (PI)) xi) uy) (* (PI) yi))) uy)) xi))
\begin{array}{l}
\\
\mathsf{fma}\left(\left(-maxCos\right) \cdot \left(zi \cdot ux - zi\right), ux, \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)\right) \cdot uy\right) + xi
\end{array}
Initial program 98.9%
Taylor expanded in maxCos around 0
Applied rewrites98.2%
Taylor expanded in uy around 0
Applied rewrites85.8%
Taylor expanded in ux around 0
Applied rewrites85.8%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* -2.0 (- (* (* (* (PI) (PI)) xi) uy) (* (PI) yi))) uy (fma (* (* zi ux) maxCos) (- 1.0 ux) 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, \mathsf{fma}\left(\left(zi \cdot ux\right) \cdot maxCos, 1 - ux, xi\right)\right)
\end{array}
Initial program 98.9%
Taylor expanded in maxCos around 0
Applied rewrites98.2%
Taylor expanded in xi around inf
Applied rewrites50.8%
Taylor expanded in uy around 0
Applied rewrites43.6%
Taylor expanded in uy around 0
Applied rewrites85.8%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (fma (* maxCos ux) (* zi (- 1.0 ux)) xi) (* (* (* (PI) yi) 2.0) uy)))
\begin{array}{l}
\\
\mathsf{fma}\left(maxCos \cdot ux, zi \cdot \left(1 - ux\right), xi\right) + \left(\left(\mathsf{PI}\left(\right) \cdot yi\right) \cdot 2\right) \cdot uy
\end{array}
Initial program 98.9%
Taylor expanded in maxCos around 0
Applied rewrites98.2%
Taylor expanded in uy around 0
Applied rewrites85.8%
Taylor expanded in xi around 0
Applied rewrites82.1%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (fma (* zi ux) maxCos (* (* (* (PI) yi) uy) 2.0)) xi))
\begin{array}{l}
\\
\mathsf{fma}\left(zi \cdot ux, maxCos, \left(\left(\mathsf{PI}\left(\right) \cdot yi\right) \cdot uy\right) \cdot 2\right) + xi
\end{array}
Initial program 98.9%
Taylor expanded in uy around 0
Applied rewrites82.7%
Taylor expanded in ux around 0
Applied rewrites78.0%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (if (or (<= xi -5.000000156871975e-23) (not (<= xi 2.00000009162741e-18))) xi (* (* (* (PI) yi) uy) 2.0)))
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;xi \leq -5.000000156871975 \cdot 10^{-23} \lor \neg \left(xi \leq 2.00000009162741 \cdot 10^{-18}\right):\\
\;\;\;\;xi\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{PI}\left(\right) \cdot yi\right) \cdot uy\right) \cdot 2\\
\end{array}
\end{array}
if xi < -5.00000016e-23 or 2.00000009e-18 < xi Initial program 99.1%
Taylor expanded in maxCos around 0
Applied rewrites98.0%
Taylor expanded in xi around inf
Applied rewrites71.8%
Taylor expanded in uy around 0
Applied rewrites60.6%
if -5.00000016e-23 < xi < 2.00000009e-18Initial program 98.6%
Taylor expanded in maxCos around 0
Applied rewrites98.5%
Taylor expanded in uy around 0
Applied rewrites86.7%
Taylor expanded in yi around inf
Applied rewrites52.7%
Final simplification57.3%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* (* (PI) yi) uy) 2.0 xi))
\begin{array}{l}
\\
\mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot yi\right) \cdot uy, 2, xi\right)
\end{array}
Initial program 98.9%
Taylor expanded in uy around 0
Applied rewrites82.7%
Taylor expanded in ux around 0
Applied rewrites72.2%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 xi)
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return xi;
}
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 = xi
end function
function code(xi, yi, zi, ux, uy, maxCos) return xi end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = xi; end
\begin{array}{l}
\\
xi
\end{array}
Initial program 98.9%
Taylor expanded in maxCos around 0
Applied rewrites98.2%
Taylor expanded in xi around inf
Applied rewrites50.8%
Taylor expanded in uy around 0
Applied rewrites43.6%
herbie shell --seed 2025019
(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)))