
(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 (* (* (- 1.0 ux) maxCos) ux))
(t_1 (* (PI) (* 2.0 uy)))
(t_2 (sin (acos t_0))))
(+ (fma (* (sin t_1) t_2) yi (* (cos t_1) (* t_2 xi))) (* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\\
t_2 := \sin \cos^{-1} t\_0\\
\mathsf{fma}\left(\sin t\_1 \cdot t\_2, yi, \cos t\_1 \cdot \left(t\_2 \cdot xi\right)\right) + t\_0 \cdot zi
\end{array}
\end{array}
Initial program 99.0%
Applied rewrites99.1%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (let* ((t_0 (* (PI) (* 2.0 uy)))) (fma (* maxCos ux) (* (- 1.0 ux) zi) (fma (cos t_0) xi (* (sin t_0) yi)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\\
\mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot zi, \mathsf{fma}\left(\cos t\_0, xi, \sin t\_0 \cdot yi\right)\right)
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites99.1%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (let* ((t_0 (* (PI) (* 2.0 uy)))) (fma (* maxCos ux) zi (fma (cos t_0) xi (* (sin t_0) yi)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\\
\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(\cos t\_0, xi, \sin t\_0 \cdot yi\right)\right)
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in ux around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites96.1%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) (* 2.0 uy))) (t_1 (* (PI) (PI))))
(if (<= uy 0.012000000104308128)
(+
xi
(fma
maxCos
(* ux (* zi (- 1.0 ux)))
(*
uy
(fma
2.0
(* yi (PI))
(*
uy
(fma
-2.0
(* xi t_1)
(* -1.3333333333333333 (* uy (* yi (* t_1 (PI)))))))))))
(fma (cos t_0) xi (* (sin t_0) yi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\\
t_1 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;uy \leq 0.012000000104308128:\\
\;\;\;\;xi + \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), uy \cdot \mathsf{fma}\left(2, yi \cdot \mathsf{PI}\left(\right), uy \cdot \mathsf{fma}\left(-2, xi \cdot t\_1, -1.3333333333333333 \cdot \left(uy \cdot \left(yi \cdot \left(t\_1 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos t\_0, xi, \sin t\_0 \cdot yi\right)\\
\end{array}
\end{array}
if uy < 0.0120000001Initial program 99.3%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites99.3%
Taylor expanded in uy around 0
lower-+.f32N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lift--.f32N/A
lower-*.f32N/A
Applied rewrites99.2%
lift-PI.f32N/A
lift-pow.f32N/A
unpow3N/A
pow2N/A
lower-*.f32N/A
pow2N/A
lift-*.f32N/A
lift-PI.f32N/A
lift-PI.f32N/A
lift-PI.f3299.2
Applied rewrites99.2%
if 0.0120000001 < uy Initial program 98.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites93.7%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* maxCos ux) (* (- 1.0 ux) zi) (+ (- xi (* 2.0 (* (* uy uy) (* xi (* (PI) (PI)))))) (* (sin (* (PI) (* 2.0 uy))) yi))))
\begin{array}{l}
\\
\mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot zi, \left(xi - 2 \cdot \left(\left(uy \cdot uy\right) \cdot \left(xi \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right) + \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites99.1%
lift-fma.f32N/A
lift-cos.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lift-sin.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lower-+.f32N/A
Applied rewrites99.0%
Taylor expanded in uy around 0
fp-cancel-sign-sub-invN/A
lower--.f32N/A
metadata-evalN/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
pow2N/A
lift-*.f32N/A
lift-PI.f32N/A
lift-PI.f32N/A
lift-*.f3292.5
Applied rewrites92.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) (* 2.0 uy))) (t_1 (* (- 1.0 ux) zi)))
(if (<= yi 1.000000031374395e-22)
(fma (* maxCos ux) t_1 (fma (cos t_0) xi (* (* 2.0 (* uy (PI))) yi)))
(fma (* maxCos ux) t_1 (+ xi (* (sin t_0) yi))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\\
t_1 := \left(1 - ux\right) \cdot zi\\
\mathbf{if}\;yi \leq 1.000000031374395 \cdot 10^{-22}:\\
\;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, t\_1, \mathsf{fma}\left(\cos t\_0, xi, \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, t\_1, xi + \sin t\_0 \cdot yi\right)\\
\end{array}
\end{array}
if yi < 1.00000003e-22Initial program 99.0%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites99.1%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-*.f32N/A
lift-PI.f3291.3
Applied rewrites91.3%
if 1.00000003e-22 < yi Initial program 99.0%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites98.9%
lift-fma.f32N/A
lift-cos.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lift-sin.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lower-+.f32N/A
Applied rewrites98.9%
Taylor expanded in uy around 0
Applied rewrites93.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) (PI))))
(if (<= uy 0.07000000029802322)
(+
xi
(fma
maxCos
(* ux (* zi (- 1.0 ux)))
(*
uy
(fma
2.0
(* yi (PI))
(*
uy
(fma
-2.0
(* xi t_0)
(* -1.3333333333333333 (* uy (* yi (* t_0 (PI)))))))))))
(fma
(* maxCos ux)
(* (- 1.0 ux) zi)
(+ xi (* (sin (* (PI) (* 2.0 uy))) yi))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;uy \leq 0.07000000029802322:\\
\;\;\;\;xi + \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), uy \cdot \mathsf{fma}\left(2, yi \cdot \mathsf{PI}\left(\right), uy \cdot \mathsf{fma}\left(-2, xi \cdot t\_0, -1.3333333333333333 \cdot \left(uy \cdot \left(yi \cdot \left(t\_0 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot zi, xi + \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)\\
\end{array}
\end{array}
if uy < 0.0700000003Initial program 99.2%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites99.3%
Taylor expanded in uy around 0
lower-+.f32N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lift--.f32N/A
lower-*.f32N/A
Applied rewrites97.0%
lift-PI.f32N/A
lift-pow.f32N/A
unpow3N/A
pow2N/A
lower-*.f32N/A
pow2N/A
lift-*.f32N/A
lift-PI.f32N/A
lift-PI.f32N/A
lift-PI.f3297.0
Applied rewrites97.0%
if 0.0700000003 < uy Initial program 97.6%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites97.8%
lift-fma.f32N/A
lift-cos.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lift-sin.f32N/A
lift-PI.f32N/A
lift-*.f32N/A
lift-*.f32N/A
lower-+.f32N/A
Applied rewrites97.6%
Taylor expanded in uy around 0
Applied rewrites61.3%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) (PI))))
(if (<= uy 0.07000000029802322)
(+
xi
(fma
maxCos
(* ux (* zi (- 1.0 ux)))
(*
uy
(fma
2.0
(* yi (PI))
(*
uy
(fma
-2.0
(* xi t_0)
(* -1.3333333333333333 (* uy (* yi (* t_0 (PI)))))))))))
(fma 1.0 xi (* (sin (* (PI) (* 2.0 uy))) yi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
\mathbf{if}\;uy \leq 0.07000000029802322:\\
\;\;\;\;xi + \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), uy \cdot \mathsf{fma}\left(2, yi \cdot \mathsf{PI}\left(\right), uy \cdot \mathsf{fma}\left(-2, xi \cdot t\_0, -1.3333333333333333 \cdot \left(uy \cdot \left(yi \cdot \left(t\_0 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(1, xi, \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot yi\right)\\
\end{array}
\end{array}
if uy < 0.0700000003Initial program 99.2%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites99.3%
Taylor expanded in uy around 0
lower-+.f32N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lift--.f32N/A
lower-*.f32N/A
Applied rewrites97.0%
lift-PI.f32N/A
lift-pow.f32N/A
unpow3N/A
pow2N/A
lower-*.f32N/A
pow2N/A
lift-*.f32N/A
lift-PI.f32N/A
lift-PI.f32N/A
lift-PI.f3297.0
Applied rewrites97.0%
if 0.0700000003 < uy Initial program 97.6%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites93.4%
Taylor expanded in uy around 0
Applied rewrites59.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) (PI))))
(+
xi
(fma
maxCos
(* ux (* zi (- 1.0 ux)))
(*
uy
(fma
2.0
(* yi (PI))
(*
uy
(fma
-2.0
(* xi t_0)
(* -1.3333333333333333 (* uy (* yi (* t_0 (PI)))))))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\\
xi + \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), uy \cdot \mathsf{fma}\left(2, yi \cdot \mathsf{PI}\left(\right), uy \cdot \mathsf{fma}\left(-2, xi \cdot t\_0, -1.3333333333333333 \cdot \left(uy \cdot \left(yi \cdot \left(t\_0 \cdot \mathsf{PI}\left(\right)\right)\right)\right)\right)\right)\right)
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites99.1%
Taylor expanded in uy around 0
lower-+.f32N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lift--.f32N/A
lower-*.f32N/A
Applied rewrites87.5%
lift-PI.f32N/A
lift-pow.f32N/A
unpow3N/A
pow2N/A
lower-*.f32N/A
pow2N/A
lift-*.f32N/A
lift-PI.f32N/A
lift-PI.f32N/A
lift-PI.f3287.5
Applied rewrites87.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(+
xi
(*
maxCos
(fma
ux
(* zi (- 1.0 ux))
(/
(* uy (fma -2.0 (* uy (* xi (* (PI) (PI)))) (* 2.0 (* yi (PI)))))
maxCos)))))\begin{array}{l}
\\
xi + maxCos \cdot \mathsf{fma}\left(ux, zi \cdot \left(1 - ux\right), \frac{uy \cdot \mathsf{fma}\left(-2, uy \cdot \left(xi \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right), 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)}{maxCos}\right)
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites99.1%
Taylor expanded in uy around 0
lower-+.f32N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lift--.f32N/A
lower-*.f32N/A
lower-fma.f32N/A
Applied rewrites83.5%
Taylor expanded in maxCos around inf
lower-*.f32N/A
lower-fma.f32N/A
lift-*.f32N/A
lift--.f32N/A
lower-/.f32N/A
Applied rewrites83.5%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ xi (fma maxCos (* ux (* zi (- 1.0 ux))) (* uy (fma -2.0 (* uy (* xi (* (PI) (PI)))) (* 2.0 (* yi (PI))))))))
\begin{array}{l}
\\
xi + \mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), uy \cdot \mathsf{fma}\left(-2, uy \cdot \left(xi \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right), 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right)
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites99.1%
Taylor expanded in uy around 0
lower-+.f32N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lift--.f32N/A
lower-*.f32N/A
lower-fma.f32N/A
Applied rewrites83.5%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ xi (fma maxCos (* ux zi) (* uy (fma -2.0 (* uy (* xi (* (PI) (PI)))) (* 2.0 (* yi (PI))))))))
\begin{array}{l}
\\
xi + \mathsf{fma}\left(maxCos, ux \cdot zi, uy \cdot \mathsf{fma}\left(-2, uy \cdot \left(xi \cdot \left(\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)\right)\right), 2 \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right)
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites99.1%
Taylor expanded in uy around 0
lower-+.f32N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lift--.f32N/A
lower-*.f32N/A
lower-fma.f32N/A
Applied rewrites83.5%
Taylor expanded in ux around 0
Applied rewrites80.9%
Final simplification80.9%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* maxCos ux) (* (- 1.0 ux) zi) (+ xi (* 2.0 (* uy (* yi (PI)))))))
\begin{array}{l}
\\
\mathsf{fma}\left(maxCos \cdot ux, \left(1 - ux\right) \cdot zi, xi + 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)\right)
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites99.1%
Taylor expanded in uy around 0
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lift-PI.f3279.3
Applied rewrites79.3%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ xi (fma 2.0 (* uy (* yi (PI))) (* maxCos (* ux (* zi (- 1.0 ux)))))))
\begin{array}{l}
\\
xi + \mathsf{fma}\left(2, uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right), maxCos \cdot \left(ux \cdot \left(zi \cdot \left(1 - ux\right)\right)\right)\right)
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites99.1%
Taylor expanded in uy around 0
lower-+.f32N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lift-PI.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lift--.f3279.2
Applied rewrites79.2%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ xi (* 2.0 (* uy (* yi (PI))))))
\begin{array}{l}
\\
xi + 2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites99.1%
Taylor expanded in uy around 0
lower-+.f32N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lift--.f32N/A
lower-*.f32N/A
lower-fma.f32N/A
Applied rewrites83.5%
Taylor expanded in yi around inf
lower-*.f32N/A
lower-*.f32N/A
lift-*.f32N/A
lift-PI.f3271.6
Applied rewrites71.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* 2.0 (* uy (* yi (PI)))))
\begin{array}{l}
\\
2 \cdot \left(uy \cdot \left(yi \cdot \mathsf{PI}\left(\right)\right)\right)
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f32N/A
*-commutativeN/A
Applied rewrites99.1%
Taylor expanded in uy around 0
lower-+.f32N/A
lower-fma.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lift--.f32N/A
lower-*.f32N/A
lower-fma.f32N/A
Applied rewrites83.5%
Taylor expanded in yi around inf
lower-*.f32N/A
lower-*.f32N/A
lift-*.f32N/A
lift-PI.f3228.4
Applied rewrites28.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 99.0%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift--.f3213.5
Applied rewrites13.5%
Taylor expanded in ux around 0
Applied rewrites12.1%
herbie shell --seed 2025051
(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)))