
(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 18 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 (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))
(* (* (* (- 1.0 ux) ux) maxCos) 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) + \left(\left(\left(1 - ux\right) \cdot ux\right) \cdot maxCos\right) \cdot zi
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3299.0
Applied rewrites99.0%
(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 99.0%
Taylor expanded in ux around 0
associate-*r*N/A
*-commutativeN/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f3298.9
Applied rewrites98.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) (* 2.0 uy)))
(t_1 (* (* (- 1.0 ux) maxCos) ux))
(t_2 (* (cos (* 2.0 (* uy (PI)))) xi)))
(if (<= uy 0.003800000064074993)
(+ (+ t_2 (* (* t_0 (sqrt (- 1.0 (* t_1 t_1)))) yi)) (* t_1 zi))
(+ (+ t_2 (* (sin t_0) yi)) (* (* maxCos ux) zi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\\
t_1 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_2 := \cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot xi\\
\mathbf{if}\;uy \leq 0.003800000064074993:\\
\;\;\;\;\left(t\_2 + \left(t\_0 \cdot \sqrt{1 - t\_1 \cdot t\_1}\right) \cdot yi\right) + t\_1 \cdot zi\\
\mathbf{else}:\\
\;\;\;\;\left(t\_2 + \sin t\_0 \cdot yi\right) + \left(maxCos \cdot ux\right) \cdot zi\\
\end{array}
\end{array}
if uy < 0.00380000006Initial program 99.3%
Taylor expanded in uy around 0
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f3298.7
Applied rewrites98.7%
Taylor expanded in ux around 0
lower-cos.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3298.6
Applied rewrites98.6%
if 0.00380000006 < uy Initial program 98.0%
Taylor expanded in ux around 0
associate-*r*N/A
*-commutativeN/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f3298.0
Applied rewrites98.0%
Taylor expanded in ux around 0
lower-cos.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3298.0
Applied rewrites98.0%
Taylor expanded in ux around 0
Applied rewrites95.4%
Final simplification97.7%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (let* ((t_0 (* 2.0 (* uy (PI))))) (fma maxCos (* ux (* zi (- 1.0 ux))) (fma xi (cos t_0) (* yi (sin t_0))))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\\
\mathsf{fma}\left(maxCos, ux \cdot \left(zi \cdot \left(1 - ux\right)\right), \mathsf{fma}\left(xi, \cos t\_0, yi \cdot \sin t\_0\right)\right)
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3299.0
Applied rewrites99.0%
Taylor expanded in maxCos around 0
lower-fma.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
lower-fma.f32N/A
Applied rewrites98.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) (* 2.0 uy))) (t_1 (* (* (- 1.0 ux) maxCos) ux)))
(if (<= uy 0.003800000064074993)
(+
(+
(* (cos (* 2.0 (* uy (PI)))) xi)
(* (* t_0 (sqrt (- 1.0 (* t_1 t_1)))) yi))
(* t_1 zi))
(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)\\
t_1 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
\mathbf{if}\;uy \leq 0.003800000064074993:\\
\;\;\;\;\left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot xi + \left(t\_0 \cdot \sqrt{1 - t\_1 \cdot t\_1}\right) \cdot yi\right) + t\_1 \cdot zi\\
\mathbf{else}:\\
\;\;\;\;\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}
if uy < 0.00380000006Initial program 99.3%
Taylor expanded in uy around 0
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f3298.7
Applied rewrites98.7%
Taylor expanded in ux around 0
lower-cos.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3298.6
Applied rewrites98.6%
if 0.00380000006 < uy Initial program 98.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 rewrites95.4%
Final simplification97.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) (* 2.0 uy))) (t_1 (* (* (- 1.0 ux) maxCos) ux)))
(if (<= uy 0.003800000064074993)
(+
(+
(* (cos (* 2.0 (* uy (PI)))) xi)
(* (* t_0 (sqrt (- 1.0 (* t_1 t_1)))) yi))
(* t_1 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)\\
t_1 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
\mathbf{if}\;uy \leq 0.003800000064074993:\\
\;\;\;\;\left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot xi + \left(t\_0 \cdot \sqrt{1 - t\_1 \cdot t\_1}\right) \cdot yi\right) + t\_1 \cdot zi\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos t\_0, xi, \sin t\_0 \cdot yi\right)\\
\end{array}
\end{array}
if uy < 0.00380000006Initial program 99.3%
Taylor expanded in uy around 0
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f3298.7
Applied rewrites98.7%
Taylor expanded in ux around 0
lower-cos.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3298.6
Applied rewrites98.6%
if 0.00380000006 < uy Initial program 98.0%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
associate-*r*N/A
*-commutativeN/A
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites92.0%
Final simplification96.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux)))
(+
(+
(* (cos (* 2.0 (* uy (PI)))) xi)
(* (* (* (PI) (* 2.0 uy)) (sqrt (- 1.0 (* t_0 t_0)))) yi))
(* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
\left(\cos \left(2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\right) \cdot xi + \left(\left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in uy around 0
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f3290.7
Applied rewrites90.7%
Taylor expanded in ux around 0
lower-cos.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3290.7
Applied rewrites90.7%
Final simplification90.7%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (let* ((t_0 (* 2.0 (* uy (PI))))) (+ (+ (* (cos t_0) xi) (* t_0 yi)) (* (* (* (- 1.0 ux) maxCos) ux) zi))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 \cdot \left(uy \cdot \mathsf{PI}\left(\right)\right)\\
\left(\cos t\_0 \cdot xi + t\_0 \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in ux around 0
associate-*r*N/A
*-commutativeN/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f3298.9
Applied rewrites98.9%
Taylor expanded in ux around 0
lower-cos.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3298.8
Applied rewrites98.8%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3290.6
Applied rewrites90.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (+ (* 1.0 xi) (* (sin (* (PI) (* 2.0 uy))) yi)) (* (* (* (- 1.0 ux) maxCos) ux) zi)))
\begin{array}{l}
\\
\left(1 \cdot 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 99.0%
Taylor expanded in ux around 0
associate-*r*N/A
*-commutativeN/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f3298.9
Applied rewrites98.9%
Taylor expanded in ux around 0
lower-cos.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3298.8
Applied rewrites98.8%
Taylor expanded in uy around 0
Applied rewrites87.8%
(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))))) (+ (+ (* (* 1.0 t_1) xi) (* (* (* (PI) (* 2.0 uy)) 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}\\
\left(\left(1 \cdot t\_1\right) \cdot xi + \left(\left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot t\_1\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in uy around 0
associate-*r*N/A
*-commutativeN/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f3290.7
Applied rewrites90.7%
Taylor expanded in uy around 0
Applied rewrites80.9%
Final simplification80.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* ux (- 1.0 ux))))
(+
(* xi (sqrt (- 1.0 (* (* maxCos maxCos) (* t_0 t_0)))))
(* (* (* (- 1.0 ux) ux) maxCos) zi))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
float t_0 = ux * (1.0f - ux);
return (xi * sqrtf((1.0f - ((maxCos * maxCos) * (t_0 * t_0))))) + ((((1.0f - ux) * ux) * maxCos) * zi);
}
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
real(4) :: t_0
t_0 = ux * (1.0e0 - ux)
code = (xi * sqrt((1.0e0 - ((maxcos * maxcos) * (t_0 * t_0))))) + ((((1.0e0 - ux) * ux) * maxcos) * zi)
end function
function code(xi, yi, zi, ux, uy, maxCos) t_0 = Float32(ux * Float32(Float32(1.0) - ux)) return Float32(Float32(xi * sqrt(Float32(Float32(1.0) - Float32(Float32(maxCos * maxCos) * Float32(t_0 * t_0))))) + Float32(Float32(Float32(Float32(Float32(1.0) - ux) * ux) * maxCos) * zi)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) t_0 = ux * (single(1.0) - ux); tmp = (xi * sqrt((single(1.0) - ((maxCos * maxCos) * (t_0 * t_0))))) + ((((single(1.0) - ux) * ux) * maxCos) * zi); end
\begin{array}{l}
\\
\begin{array}{l}
t_0 := ux \cdot \left(1 - ux\right)\\
xi \cdot \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(t\_0 \cdot t\_0\right)} + \left(\left(\left(1 - ux\right) \cdot ux\right) \cdot maxCos\right) \cdot zi
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3299.0
Applied rewrites99.0%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
lower-*.f32N/A
pow2N/A
lower-*.f32N/A
pow-prod-downN/A
lower-pow.f32N/A
lower-*.f32N/A
lower--.f3254.2
Applied rewrites54.2%
unpow2N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower--.f3254.2
Applied rewrites54.2%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (* xi (+ 1.0 (* (* ux ux) (fma -0.5 (* maxCos maxCos) (* (* maxCos maxCos) ux))))) (* (* (* (- 1.0 ux) ux) maxCos) zi)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (xi * (1.0f + ((ux * ux) * fmaf(-0.5f, (maxCos * maxCos), ((maxCos * maxCos) * ux))))) + ((((1.0f - ux) * ux) * maxCos) * zi);
}
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(xi * Float32(Float32(1.0) + Float32(Float32(ux * ux) * fma(Float32(-0.5), Float32(maxCos * maxCos), Float32(Float32(maxCos * maxCos) * ux))))) + Float32(Float32(Float32(Float32(Float32(1.0) - ux) * ux) * maxCos) * zi)) end
\begin{array}{l}
\\
xi \cdot \left(1 + \left(ux \cdot ux\right) \cdot \mathsf{fma}\left(-0.5, maxCos \cdot maxCos, \left(maxCos \cdot maxCos\right) \cdot ux\right)\right) + \left(\left(\left(1 - ux\right) \cdot ux\right) \cdot maxCos\right) \cdot zi
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3299.0
Applied rewrites99.0%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
lower-*.f32N/A
pow2N/A
lower-*.f32N/A
pow-prod-downN/A
lower-pow.f32N/A
lower-*.f32N/A
lower--.f3254.2
Applied rewrites54.2%
Taylor expanded in ux around 0
lower-+.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-fma.f32N/A
pow2N/A
lower-*.f32N/A
lower-*.f32N/A
pow2N/A
lower-*.f3254.1
Applied rewrites54.1%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (+ xi (* -0.5 (* (* maxCos maxCos) (* (* ux ux) xi)))) (* (* (* (- 1.0 ux) ux) maxCos) zi)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (xi + (-0.5f * ((maxCos * maxCos) * ((ux * ux) * xi)))) + ((((1.0f - ux) * ux) * maxCos) * zi);
}
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 + ((-0.5e0) * ((maxcos * maxcos) * ((ux * ux) * xi)))) + ((((1.0e0 - ux) * ux) * maxcos) * zi)
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(xi + Float32(Float32(-0.5) * Float32(Float32(maxCos * maxCos) * Float32(Float32(ux * ux) * xi)))) + Float32(Float32(Float32(Float32(Float32(1.0) - ux) * ux) * maxCos) * zi)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (xi + (single(-0.5) * ((maxCos * maxCos) * ((ux * ux) * xi)))) + ((((single(1.0) - ux) * ux) * maxCos) * zi); end
\begin{array}{l}
\\
\left(xi + -0.5 \cdot \left(\left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot xi\right)\right)\right) + \left(\left(\left(1 - ux\right) \cdot ux\right) \cdot maxCos\right) \cdot zi
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3299.0
Applied rewrites99.0%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
lower-*.f32N/A
pow2N/A
lower-*.f32N/A
pow-prod-downN/A
lower-pow.f32N/A
lower-*.f32N/A
lower--.f3254.2
Applied rewrites54.2%
Taylor expanded in ux around 0
lower-+.f32N/A
lower-*.f32N/A
lower-*.f32N/A
pow2N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3254.1
Applied rewrites54.1%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ xi (* (* (* (- 1.0 ux) ux) maxCos) zi)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return xi + ((((1.0f - ux) * ux) * maxCos) * zi);
}
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 + ((((1.0e0 - ux) * ux) * maxcos) * zi)
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(xi + Float32(Float32(Float32(Float32(Float32(1.0) - ux) * ux) * maxCos) * zi)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = xi + ((((single(1.0) - ux) * ux) * maxCos) * zi); end
\begin{array}{l}
\\
xi + \left(\left(\left(1 - ux\right) \cdot ux\right) \cdot maxCos\right) \cdot zi
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3299.0
Applied rewrites99.0%
Taylor expanded in uy around 0
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
lower-*.f32N/A
pow2N/A
lower-*.f32N/A
pow-prod-downN/A
lower-pow.f32N/A
lower-*.f32N/A
lower--.f3254.2
Applied rewrites54.2%
Taylor expanded in ux around 0
Applied rewrites54.1%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* (* zi (- 1.0 ux)) ux) maxCos))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return ((zi * (1.0f - ux)) * 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 * (1.0e0 - ux)) * ux) * maxcos
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(zi * Float32(Float32(1.0) - ux)) * ux) * maxCos) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = ((zi * (single(1.0) - ux)) * ux) * maxCos; end
\begin{array}{l}
\\
\left(\left(zi \cdot \left(1 - ux\right)\right) \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
lower-*.f32N/A
lower--.f3215.2
Applied rewrites15.2%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* maxCos (* ux (- 1.0 ux))) zi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (maxCos * (ux * (1.0f - ux))) * zi;
}
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 = (maxcos * (ux * (1.0e0 - ux))) * zi
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(maxCos * Float32(ux * Float32(Float32(1.0) - ux))) * zi) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (maxCos * (ux * (single(1.0) - ux))) * zi; end
\begin{array}{l}
\\
\left(maxCos \cdot \left(ux \cdot \left(1 - ux\right)\right)\right) \cdot zi
\end{array}
Initial program 99.0%
Taylor expanded in zi around inf
Applied rewrites97.6%
Taylor expanded in zi around inf
lower-*.f32N/A
lower-*.f32N/A
lower--.f3215.2
Applied rewrites15.2%
(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
lower-*.f32N/A
lower--.f3215.2
Applied rewrites15.2%
Taylor expanded in ux around 0
Applied rewrites12.1%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* maxCos ux) zi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (maxCos * ux) * zi;
}
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 = (maxcos * ux) * zi
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(maxCos * ux) * zi) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (maxCos * ux) * zi; end
\begin{array}{l}
\\
\left(maxCos \cdot ux\right) \cdot zi
\end{array}
Initial program 99.0%
Taylor expanded in zi around inf
Applied rewrites97.6%
Taylor expanded in zi around inf
lower-*.f32N/A
lower-*.f32N/A
lower--.f3215.2
Applied rewrites15.2%
Taylor expanded in ux around 0
Applied rewrites12.1%
herbie shell --seed 2025044
(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)))