
(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 10 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
(+
(+
(*
(*
(cos (* (* uy 2.0) (PI)))
(sqrt (- 1.0 (* (* ux maxCos) (* ux maxCos)))))
xi)
(* (sin (* (* (PI) uy) 2.0)) yi))
(* (* (* (- 1.0 ux) maxCos) ux) zi)))\begin{array}{l}
\\
\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(ux \cdot maxCos\right) \cdot \left(ux \cdot maxCos\right)}\right) \cdot xi + \sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
Initial program 98.7%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.7
Applied rewrites98.7%
Taylor expanded in ux around 0
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3298.7
Applied rewrites98.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) uy)))
(+
(+ (* (cos (* -2.0 t_0)) xi) (* (sin (* t_0 2.0)) yi))
(* (* (* (- 1.0 ux) maxCos) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot uy\\
\left(\cos \left(-2 \cdot t\_0\right) \cdot xi + \sin \left(t\_0 \cdot 2\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 98.7%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.7
Applied rewrites98.7%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
cos-neg-revN/A
lower-cos.f32N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.7
Applied rewrites98.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux)))
(+
(+
(*
(*
(fma (* -2.0 (* uy uy)) (* (PI) (fabs (PI))) 1.0)
(sqrt (- 1.0 (* t_0 t_0))))
xi)
(* (sin (* (* (PI) uy) 2.0)) yi))
(* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
\left(\left(\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \mathsf{PI}\left(\right) \cdot \left|\mathsf{PI}\left(\right)\right|, 1\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot xi + \sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
\end{array}
Initial program 98.7%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.7
Applied rewrites98.7%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3256.2
Applied rewrites55.8%
Applied rewrites88.6%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (* (- 1.0 ux) maxCos) ux) zi)))
(if (or (<= yi -4.999999858590343e-10) (not (<= yi 4.99999991225835e-15)))
(+
(+
(*
(*
(fma (* -2.0 (* uy uy)) (* (PI) (PI)) 1.0)
(sqrt (- 1.0 (* (* maxCos ux) (* maxCos ux)))))
xi)
(* (sin (* (* (PI) uy) 2.0)) yi))
t_0)
(+
(*
(sqrt (- 1.0 (* (* (pow (- 1.0 ux) 2.0) (* ux ux)) (* maxCos maxCos))))
xi)
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{if}\;yi \leq -4.999999858590343 \cdot 10^{-10} \lor \neg \left(yi \leq 4.99999991225835 \cdot 10^{-15}\right):\\
\;\;\;\;\left(\left(\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - \left(maxCos \cdot ux\right) \cdot \left(maxCos \cdot ux\right)}\right) \cdot xi + \sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\right) + t\_0\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left({\left(1 - ux\right)}^{2} \cdot \left(ux \cdot ux\right)\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot xi + t\_0\\
\end{array}
\end{array}
if yi < -4.99999986e-10 or 4.99999991e-15 < yi Initial program 98.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.2
Applied rewrites98.2%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3272.2
Applied rewrites69.5%
Taylor expanded in ux around 0
unpow2N/A
unpow2N/A
unswap-sqrN/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3270.0
Applied rewrites69.6%
if -4.99999986e-10 < yi < 4.99999991e-15Initial program 99.0%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3271.9
Applied rewrites71.9%
Final simplification79.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux)) (t_1 (* t_0 zi)))
(if (or (<= yi -4.0000000467443897e-7) (not (<= yi 4.99999991225835e-15)))
(+
(+
(*
(*
(fma (* -2.0 (* uy uy)) (* (PI) (PI)) 1.0)
(sqrt (- 1.0 (* t_0 t_0))))
xi)
(* (* (* (PI) uy) 2.0) yi))
t_1)
(+
(*
(sqrt (- 1.0 (* (* (pow (- 1.0 ux) 2.0) (* ux ux)) (* maxCos maxCos))))
xi)
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := t\_0 \cdot zi\\
\mathbf{if}\;yi \leq -4.0000000467443897 \cdot 10^{-7} \lor \neg \left(yi \leq 4.99999991225835 \cdot 10^{-15}\right):\\
\;\;\;\;\left(\left(\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot xi + \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\right) + t\_1\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left({\left(1 - ux\right)}^{2} \cdot \left(ux \cdot ux\right)\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot xi + t\_1\\
\end{array}
\end{array}
if yi < -4.00000005e-7 or 4.99999991e-15 < yi Initial program 98.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.2
Applied rewrites98.2%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3275.6
Applied rewrites74.4%
Taylor expanded in uy around 0
Applied rewrites83.0%
if -4.00000005e-7 < yi < 4.99999991e-15Initial program 98.9%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3268.5
Applied rewrites68.5%
Final simplification73.1%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux)))
(if (or (<= yi -4.0000000467443897e-7) (not (<= yi 4.99999991225835e-15)))
(+
(+
(*
(*
(fma (* -2.0 (* uy uy)) (* (PI) (PI)) 1.0)
(sqrt (- 1.0 (* t_0 t_0))))
xi)
(* (* (* (PI) uy) 2.0) yi))
(* t_0 zi))
(+ (* (* zi ux) maxCos) xi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
\mathbf{if}\;yi \leq -4.0000000467443897 \cdot 10^{-7} \lor \neg \left(yi \leq 4.99999991225835 \cdot 10^{-15}\right):\\
\;\;\;\;\left(\left(\mathsf{fma}\left(-2 \cdot \left(uy \cdot uy\right), \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot xi + \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\right) + t\_0 \cdot zi\\
\mathbf{else}:\\
\;\;\;\;\left(zi \cdot ux\right) \cdot maxCos + xi\\
\end{array}
\end{array}
if yi < -4.00000005e-7 or 4.99999991e-15 < yi Initial program 98.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.2
Applied rewrites98.2%
Taylor expanded in uy around 0
+-commutativeN/A
associate-*r*N/A
lower-fma.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-PI.f3275.7
Applied rewrites74.2%
Taylor expanded in uy around 0
Applied rewrites82.2%
if -4.00000005e-7 < yi < 4.99999991e-15Initial program 98.9%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites13.9%
Taylor expanded in ux around 0
Applied rewrites61.0%
Applied rewrites66.6%
Final simplification71.7%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (* (* zi ux) maxCos) xi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return ((zi * ux) * maxCos) + 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 = ((zi * ux) * maxcos) + xi
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(zi * ux) * maxCos) + xi) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = ((zi * ux) * maxCos) + xi; end
\begin{array}{l}
\\
\left(zi \cdot ux\right) \cdot maxCos + xi
\end{array}
Initial program 98.7%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites11.9%
Taylor expanded in ux around 0
Applied rewrites49.1%
Applied rewrites53.2%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* maxCos ux) zi xi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return fmaf((maxCos * ux), zi, xi);
}
function code(xi, yi, zi, ux, uy, maxCos) return fma(Float32(maxCos * ux), zi, xi) end
\begin{array}{l}
\\
\mathsf{fma}\left(maxCos \cdot ux, zi, xi\right)
\end{array}
Initial program 98.7%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites11.9%
Taylor expanded in ux around 0
Applied rewrites49.1%
Taylor expanded in xi around 0
Applied rewrites11.1%
Taylor expanded in xi around 0
Applied rewrites49.1%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* maxCos zi) ux))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (maxCos * zi) * ux;
}
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 * zi) * ux
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(maxCos * zi) * ux) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (maxCos * zi) * ux; end
\begin{array}{l}
\\
\left(maxCos \cdot zi\right) \cdot ux
\end{array}
Initial program 98.7%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites11.9%
Taylor expanded in ux around 0
Applied rewrites49.1%
Taylor expanded in xi around 0
Applied rewrites11.1%
Applied rewrites11.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 98.7%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites11.9%
Taylor expanded in ux around 0
Applied rewrites49.1%
Taylor expanded in xi around 0
Applied rewrites11.1%
Applied rewrites11.1%
herbie shell --seed 2024346
(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)))