
(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 (sqrt (- 1.0 (* t_0 t_0)))))
(-
(+
(*
yi
(*
(sin (* (sqrt (PI)) (* (sqrt (pow (cbrt (PI)) 3.0)) (* 2.0 uy))))
t_1))
(* 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(yi \cdot \left(\sin \left(\sqrt{\mathsf{PI}\left(\right)} \cdot \left(\sqrt{{\left(\sqrt[3]{\mathsf{PI}\left(\right)}\right)}^{3}} \cdot \left(2 \cdot uy\right)\right)\right) \cdot t\_1\right) + 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 98.9%
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.6
Applied rewrites98.6%
rem-3cbrt-lftN/A
lift-cbrt.f32N/A
lift-cbrt.f32N/A
lift-cbrt.f32N/A
pow3N/A
lower-pow.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 (* (PI) (* 2.0 uy))))
(-
(+
(* (* (sin t_1) (sqrt (- 1.0 (* t_0 t_0)))) yi)
(* (sqrt (- 1.0 (pow t_0 2.0))) (* xi (cos t_1))))
(* (* (* (- 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 \left(2 \cdot uy\right)\\
\left(\left(\sin t\_1 \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot yi + \sqrt{1 - {t\_0}^{2}} \cdot \left(xi \cdot \cos t\_1\right)\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 98.9%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3298.9
lift-*.f32N/A
*-commutativeN/A
lower-*.f3298.9
lift-*.f32N/A
*-commutativeN/A
lower-*.f3298.9
Applied rewrites98.9%
Final simplification98.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) (* 2.0 uy))) (t_1 (* (* maxCos (- 1.0 ux)) ux)))
(-
(+
(* (* (sqrt (- 1.0 (* (* maxCos ux) (* maxCos ux)))) (sin t_0)) yi)
(* xi (* (sqrt (- 1.0 (* t_1 t_1))) (cos t_0))))
(* (* (* (- ux 1.0) maxCos) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\\
t_1 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
\left(\left(\sqrt{1 - \left(maxCos \cdot ux\right) \cdot \left(maxCos \cdot ux\right)} \cdot \sin t\_0\right) \cdot yi + xi \cdot \left(\sqrt{1 - t\_1 \cdot t\_1} \cdot \cos t\_0\right)\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 98.9%
Taylor expanded in ux around 0
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3298.9
Applied rewrites98.9%
Final simplification98.9%
(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 98.9%
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.9
Applied rewrites98.9%
Final simplification98.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) uy) 2.0)))
(-
(+ (* (cos t_0) xi) (* (sin t_0) yi))
(* (* (* (- ux 1.0) maxCos) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
\left(\cos t\_0 \cdot xi + \sin t\_0 \cdot yi\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 98.9%
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.9
Applied rewrites98.9%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.8
Applied rewrites98.8%
Final simplification98.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) uy) 2.0)) (t_1 (fma (cos t_0) xi (* (sin t_0) yi))))
(if (<= yi -3.99999992980668e-14)
t_1
(if (<= yi 1.99999996490334e-14)
(-
(*
(sqrt
(- 1.0 (* (* maxCos maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0)))))
xi)
(* (* (* (- ux 1.0) maxCos) ux) zi))
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
t_1 := \mathsf{fma}\left(\cos t\_0, xi, \sin t\_0 \cdot yi\right)\\
\mathbf{if}\;yi \leq -3.99999992980668 \cdot 10^{-14}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;yi \leq 1.99999996490334 \cdot 10^{-14}:\\
\;\;\;\;\sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right)} \cdot xi - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if yi < -3.99999993e-14 or 1.99999996e-14 < yi Initial program 98.6%
Taylor expanded in ux around 0
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3298.6
Applied rewrites98.6%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3251.7
Applied rewrites51.7%
if -3.99999993e-14 < yi < 1.99999996e-14Initial program 99.1%
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-*.f3260.7
Applied rewrites60.7%
Final simplification56.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(-
(+
(*
(* (* (* (PI) uy) 2.0) (sqrt (- 1.0 (* (* maxCos ux) (* maxCos ux)))))
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(\left(\left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot \sqrt{1 - \left(maxCos \cdot ux\right) \cdot \left(maxCos \cdot ux\right)}\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 98.9%
Taylor expanded in ux around 0
*-commutativeN/A
unpow2N/A
unpow2N/A
unswap-sqrN/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3298.9
Applied rewrites98.9%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3290.2
Applied rewrites90.2%
Final simplification90.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (* (- ux 1.0) maxCos) ux) zi))
(t_1 (* (* maxCos (- 1.0 ux)) ux)))
(if (<= (* 2.0 uy) 0.004000000189989805)
(-
(*
(sqrt (- 1.0 (* (* maxCos maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0)))))
xi)
t_0)
(-
(+
(*
(*
(fma (* (* uy uy) -2.0) (* (PI) (PI)) 1.0)
(sqrt (- 1.0 (* t_1 t_1))))
xi)
(* (sin (* (* (PI) uy) 2.0)) yi))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
t_1 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
\mathbf{if}\;2 \cdot uy \leq 0.004000000189989805:\\
\;\;\;\;\sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right)} \cdot xi - t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot \sqrt{1 - t\_1 \cdot t\_1}\right) \cdot xi + \sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\right) - t\_0\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00400000019Initial program 99.1%
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-*.f3252.9
Applied rewrites52.9%
if 0.00400000019 < (*.f32 uy #s(literal 2 binary32)) Initial program 98.5%
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.3
Applied rewrites98.3%
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.f3237.5
Applied rewrites37.7%
Final simplification55.9%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (- (* (sqrt (- 1.0 (* (* maxCos maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0))))) xi) (* (* (* (- ux 1.0) maxCos) ux) zi)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (sqrtf((1.0f - ((maxCos * maxCos) * ((ux * ux) * powf((1.0f - ux), 2.0f))))) * xi) - ((((ux - 1.0f) * maxCos) * ux) * zi);
}
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 = (sqrt((1.0e0 - ((maxcos * maxcos) * ((ux * ux) * ((1.0e0 - ux) ** 2.0e0))))) * xi) - ((((ux - 1.0e0) * maxcos) * ux) * zi)
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(maxCos * maxCos) * Float32(Float32(ux * ux) * (Float32(Float32(1.0) - ux) ^ Float32(2.0)))))) * xi) - Float32(Float32(Float32(Float32(ux - Float32(1.0)) * maxCos) * ux) * zi)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (sqrt((single(1.0) - ((maxCos * maxCos) * ((ux * ux) * ((single(1.0) - ux) ^ single(2.0)))))) * xi) - ((((ux - single(1.0)) * maxCos) * ux) * zi); end
\begin{array}{l}
\\
\sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right)} \cdot xi - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
Initial 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-*.f3245.7
Applied rewrites45.7%
Final simplification45.7%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* (/ (* (- 1.0 (* ux ux)) zi) (+ ux 1.0)) ux) maxCos))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return ((((1.0f - (ux * ux)) * zi) / (ux + 1.0f)) * 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 = ((((1.0e0 - (ux * ux)) * zi) / (ux + 1.0e0)) * ux) * maxcos
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(Float32(Float32(Float32(1.0) - Float32(ux * ux)) * zi) / Float32(ux + Float32(1.0))) * ux) * maxCos) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = ((((single(1.0) - (ux * ux)) * zi) / (ux + single(1.0))) * ux) * maxCos; end
\begin{array}{l}
\\
\left(\frac{\left(1 - ux \cdot ux\right) \cdot zi}{ux + 1} \cdot ux\right) \cdot maxCos
\end{array}
Initial program 98.9%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3213.6
Applied rewrites13.6%
Applied rewrites13.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* zi (- 1.0 ux)) (* maxCos ux)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (zi * (1.0f - ux)) * (maxCos * ux);
}
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 * (1.0e0 - ux)) * (maxcos * ux)
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(zi * Float32(Float32(1.0) - ux)) * Float32(maxCos * ux)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (zi * (single(1.0) - ux)) * (maxCos * ux); end
\begin{array}{l}
\\
\left(zi \cdot \left(1 - ux\right)\right) \cdot \left(maxCos \cdot ux\right)
\end{array}
Initial program 98.9%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3213.6
Applied rewrites13.6%
Applied rewrites13.6%
Final simplification13.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* zi (* maxCos (- 1.0 ux))) ux))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (zi * (maxCos * (1.0f - ux))) * ux;
}
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 * (maxcos * (1.0e0 - ux))) * ux
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(zi * Float32(maxCos * Float32(Float32(1.0) - ux))) * ux) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (zi * (maxCos * (single(1.0) - ux))) * ux; end
\begin{array}{l}
\\
\left(zi \cdot \left(maxCos \cdot \left(1 - ux\right)\right)\right) \cdot ux
\end{array}
Initial program 98.9%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3213.6
Applied rewrites13.6%
Applied rewrites13.6%
Final simplification13.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 98.9%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3213.6
Applied rewrites13.6%
Taylor expanded in ux around 0
Applied rewrites11.9%
herbie shell --seed 2024308
(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)))