
(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 13 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 (* (* maxCos (- 1.0 ux)) ux)) (t_1 (* (PI) uy)))
(-
(+
(* (* (cos t_1) (* (sqrt (- 1.0 (pow t_0 2.0))) yi)) (* (sin t_1) 2.0))
(* xi (* (sqrt (- 1.0 (* t_0 t_0))) (cos (* (PI) (* 2.0 uy))))))
(* (* (* (- ux 1.0) maxCos) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
t_1 := \mathsf{PI}\left(\right) \cdot uy\\
\left(\left(\cos t\_1 \cdot \left(\sqrt{1 - {t\_0}^{2}} \cdot yi\right)\right) \cdot \left(\sin t\_1 \cdot 2\right) + xi \cdot \left(\sqrt{1 - t\_0 \cdot t\_0} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\right)\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 99.0%
lift-sin.f32N/A
lift-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*l*N/A
sin-2N/A
lower-*.f32N/A
lower-*.f32N/A
lower-sin.f32N/A
lower-*.f32N/A
lower-cos.f32N/A
lower-*.f3299.0
Applied rewrites99.0%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*r*N/A
Applied rewrites99.1%
Final simplification99.1%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux))
(t_1 (sqrt (- 1.0 (* t_0 t_0))))
(t_2 (* (PI) uy)))
(-
(+
(* (* (* (* (cos t_2) (sin t_2)) 2.0) t_1) yi)
(* xi (* t_1 (cos (* (PI) (* 2.0 uy))))))
(* (* (* (- ux 1.0) maxCos) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \mathsf{PI}\left(\right) \cdot uy\\
\left(\left(\left(\left(\cos t\_2 \cdot \sin t\_2\right) \cdot 2\right) \cdot t\_1\right) \cdot yi + xi \cdot \left(t\_1 \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\right)\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 99.0%
lift-sin.f32N/A
lift-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*l*N/A
sin-2N/A
lower-*.f32N/A
lower-*.f32N/A
lower-sin.f32N/A
lower-*.f32N/A
lower-cos.f32N/A
lower-*.f3299.0
Applied rewrites99.0%
Final simplification99.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux))
(t_1 (sqrt (- 1.0 (* t_0 t_0))))
(t_2 (* (PI) (* 2.0 uy))))
(-
(+ (* (* (sin t_2) t_1) yi) (* xi (* t_1 (cos t_2))))
(* (* (* (- ux 1.0) maxCos) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
t_2 := \mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\\
\left(\left(\sin t\_2 \cdot t\_1\right) \cdot yi + xi \cdot \left(t\_1 \cdot \cos t\_2\right)\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 99.0%
Final simplification99.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(-
(+
(* (sin (* (* (PI) uy) 2.0)) yi)
(* xi (* (sqrt (- 1.0 (* t_0 t_0))) (cos (* (PI) (* 2.0 uy))))))
(* (* (* (- ux 1.0) maxCos) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
\left(\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi + xi \cdot \left(\sqrt{1 - t\_0 \cdot t\_0} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\right)\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3299.0
Applied rewrites99.0%
Final simplification99.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)) (t_1 (sqrt (- 1.0 (* t_0 t_0)))))
(-
(+
(* (* (* (* (PI) uy) 2.0) t_1) yi)
(* xi (* t_1 (cos (* (PI) (* 2.0 uy))))))
(* (* (* (- ux 1.0) maxCos) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
t_1 := \sqrt{1 - t\_0 \cdot t\_0}\\
\left(\left(\left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot t\_1\right) \cdot yi + xi \cdot \left(t\_1 \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\right)\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3291.7
Applied rewrites91.7%
Final simplification91.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)) (t_1 (* (* (PI) uy) 2.0)))
(-
(+ (* (cos t_1) xi) (* (* t_1 (sqrt (- 1.0 (* t_0 t_0)))) yi))
(* (* (* (- ux 1.0) maxCos) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
t_1 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
\left(\cos t\_1 \cdot xi + \left(t\_1 \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot yi\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3291.7
Applied rewrites91.7%
Taylor expanded in maxCos around 0
lower-cos.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f3291.6
Applied rewrites91.6%
Final simplification91.6%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (* (- ux 1.0) maxCos) ux) zi))
(t_1
(- (* (sqrt (- 1.0 (pow (* (* maxCos (- 1.0 ux)) ux) 2.0))) xi) t_0)))
(if (<= xi -7.500000085108846e-20)
t_1
(if (<= xi 4.9599999233763485e-22)
(-
(*
(sqrt (- 1.0 (* (* ux ux) (* maxCos maxCos))))
(* (sin (* (* (PI) uy) 2.0)) yi))
t_0)
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
t_1 := \sqrt{1 - {\left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right)}^{2}} \cdot xi - t\_0\\
\mathbf{if}\;xi \leq -7.500000085108846 \cdot 10^{-20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;xi \leq 4.9599999233763485 \cdot 10^{-22}:\\
\;\;\;\;\sqrt{1 - \left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if xi < -7.50000009e-20 or 4.95999992e-22 < xi Initial program 99.2%
lift-*.f32N/A
lift-PI.f32N/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f32N/A
lower-sqrt.f32N/A
lift-PI.f32N/A
lower-sqrt.f3299.0
Applied rewrites99.0%
Taylor expanded in uy around 0
+-commutativeN/A
lower-fma.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f329.9
Applied rewrites9.9%
Applied rewrites68.0%
if -7.50000009e-20 < xi < 4.95999992e-22Initial program 98.8%
Applied rewrites65.3%
Taylor expanded in xi around 0
lower-*.f32N/A
lower-*.f32N/A
lower-sin.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f3272.6
Applied rewrites72.6%
Taylor expanded in ux around 0
Applied rewrites72.6%
Final simplification70.0%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (- (* (+ (* (* (* yi (PI)) uy) 2.0) xi) (sqrt (- 1.0 (* (* maxCos maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0)))))) (* (* (* (- ux 1.0) maxCos) ux) zi)))
\begin{array}{l}
\\
\left(\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2 + xi\right) \cdot \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right)} - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
Initial program 99.0%
Taylor expanded in uy around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites52.5%
Applied rewrites84.0%
Final simplification84.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (* (- ux 1.0) maxCos) ux) zi))
(t_1
(- (* (sqrt (- 1.0 (pow (* (* maxCos (- 1.0 ux)) ux) 2.0))) xi) t_0)))
(if (<= xi -7.500000085108846e-20)
t_1
(if (<= xi 4.9599999233763485e-22)
(- (* (sin (* (* (PI) uy) 2.0)) yi) t_0)
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
t_1 := \sqrt{1 - {\left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right)}^{2}} \cdot xi - t\_0\\
\mathbf{if}\;xi \leq -7.500000085108846 \cdot 10^{-20}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;xi \leq 4.9599999233763485 \cdot 10^{-22}:\\
\;\;\;\;\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi - t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if xi < -7.50000009e-20 or 4.95999992e-22 < xi Initial program 99.2%
lift-*.f32N/A
lift-PI.f32N/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f32N/A
lower-sqrt.f32N/A
lift-PI.f32N/A
lower-sqrt.f3299.0
Applied rewrites99.0%
Taylor expanded in uy around 0
+-commutativeN/A
lower-fma.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f329.9
Applied rewrites9.9%
Applied rewrites68.0%
if -7.50000009e-20 < xi < 4.95999992e-22Initial program 98.8%
Applied rewrites65.3%
Taylor expanded in xi around 0
lower-*.f32N/A
lower-*.f32N/A
lower-sin.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f3272.6
Applied rewrites72.6%
Taylor expanded in maxCos around 0
Applied rewrites72.6%
Final simplification70.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* (* zi ux) maxCos) xi)))
(if (<= xi -7.500000085108846e-20)
t_0
(if (<= xi 3.99999987306209e-21)
(- (* (sin (* (* (PI) uy) 2.0)) yi) (* (* (* (- ux 1.0) maxCos) ux) zi))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(zi \cdot ux\right) \cdot maxCos + xi\\
\mathbf{if}\;xi \leq -7.500000085108846 \cdot 10^{-20}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;xi \leq 3.99999987306209 \cdot 10^{-21}:\\
\;\;\;\;\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if xi < -7.50000009e-20 or 3.9999999e-21 < xi Initial program 99.2%
lift-*.f32N/A
lift-PI.f32N/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f32N/A
lower-sqrt.f32N/A
lift-PI.f32N/A
lower-sqrt.f3299.0
Applied rewrites99.0%
Taylor expanded in uy around 0
+-commutativeN/A
lower-fma.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f329.0
Applied rewrites9.0%
Taylor expanded in ux around 0
Applied rewrites64.7%
Applied rewrites66.7%
if -7.50000009e-20 < xi < 3.9999999e-21Initial program 98.8%
Applied rewrites65.8%
Taylor expanded in xi around 0
lower-*.f32N/A
lower-*.f32N/A
lower-sin.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f3272.6
Applied rewrites72.6%
Taylor expanded in maxCos around 0
Applied rewrites72.5%
Final simplification69.3%
(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;
}
real(4) function code(xi, yi, zi, ux, uy, maxcos)
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 99.0%
lift-*.f32N/A
lift-PI.f32N/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f32N/A
lower-sqrt.f32N/A
lift-PI.f32N/A
lower-sqrt.f3298.9
Applied rewrites98.9%
Taylor expanded in uy around 0
+-commutativeN/A
lower-fma.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f3213.9
Applied rewrites13.9%
Taylor expanded in ux around 0
Applied rewrites45.6%
Applied rewrites49.9%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma maxCos (* zi ux) xi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return fmaf(maxCos, (zi * ux), xi);
}
function code(xi, yi, zi, ux, uy, maxCos) return fma(maxCos, Float32(zi * ux), xi) end
\begin{array}{l}
\\
\mathsf{fma}\left(maxCos, zi \cdot ux, xi\right)
\end{array}
Initial program 99.0%
lift-*.f32N/A
lift-PI.f32N/A
add-sqr-sqrtN/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lift-PI.f32N/A
lower-sqrt.f32N/A
lift-PI.f32N/A
lower-sqrt.f3298.9
Applied rewrites98.9%
Taylor expanded in uy around 0
+-commutativeN/A
lower-fma.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f3213.9
Applied rewrites13.9%
Taylor expanded in ux around 0
Applied rewrites45.6%
Taylor expanded in ux around 0
Applied rewrites45.6%
Final simplification45.6%
(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;
}
real(4) function code(xi, yi, zi, ux, uy, maxcos)
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--.f3213.9
Applied rewrites13.9%
Taylor expanded in ux around 0
Applied rewrites12.0%
Final simplification12.0%
herbie shell --seed 2024266
(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)))