
(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 14 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))))
(t_2 (* (* 2.0 uy) (PI))))
(-
(+ (* yi (* (sin t_2) t_1)) (* 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 := \left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\\
\left(yi \cdot \left(\sin t\_2 \cdot t\_1\right) + xi \cdot \left(t\_1 \cdot \cos t\_2\right)\right) - \left(\left(ux - 1\right) \cdot \left(maxCos \cdot ux\right)\right) \cdot zi
\end{array}
\end{array}
Initial program 99.1%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.2
Applied rewrites99.2%
Final simplification99.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(-
(+
(* (cos (* (* (PI) uy) 2.0)) xi)
(* yi (* (sin (* (* 2.0 uy) (PI))) (sqrt (- 1.0 (* t_0 t_0))))))
(* (* (- 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(\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot xi + yi \cdot \left(\sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right)\right) - \left(\left(ux - 1\right) \cdot \left(maxCos \cdot ux\right)\right) \cdot zi
\end{array}
\end{array}
Initial program 99.1%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.2
Applied rewrites99.2%
Taylor expanded in ux around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3299.2
Applied rewrites99.2%
Final simplification99.2%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(+
(* (* (- maxCos (* maxCos ux)) ux) zi)
(+
(* (cos (* (* (PI) uy) 2.0)) xi)
(* yi (* (sin (* (* 2.0 uy) (PI))) (sqrt (- 1.0 (* t_0 t_0)))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
\left(\left(maxCos - maxCos \cdot ux\right) \cdot ux\right) \cdot zi + \left(\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot xi + yi \cdot \left(\sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right)\right)
\end{array}
\end{array}
Initial program 99.1%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.2
Applied rewrites99.2%
Taylor expanded in ux around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3299.2
Applied rewrites99.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-*.f3299.1
Applied rewrites99.1%
Final simplification99.1%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(-
(+
(* (cos (* (* (PI) uy) 2.0)) xi)
(* yi (* (sin (* (* 2.0 uy) (PI))) (sqrt (- 1.0 (* t_0 t_0))))))
(* (* (* (- 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(\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot xi + yi \cdot \left(\sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right)\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 99.1%
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.f3299.1
Applied rewrites99.1%
Final simplification99.1%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(-
(+
(*
(*
(sqrt (- 1.0 (* (* maxCos ux) (* maxCos ux))))
(sin (* (* 2.0 uy) (PI))))
yi)
(* (cos (* (* (PI) uy) 2.0)) xi))
(* (* (- ux 1.0) (* maxCos ux)) zi)))\begin{array}{l}
\\
\left(\left(\sqrt{1 - \left(maxCos \cdot ux\right) \cdot \left(maxCos \cdot ux\right)} \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right)\right) \cdot yi + \cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot xi\right) - \left(\left(ux - 1\right) \cdot \left(maxCos \cdot ux\right)\right) \cdot zi
\end{array}
Initial program 99.1%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.2
Applied rewrites99.2%
Taylor expanded in ux around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3299.2
Applied rewrites99.2%
Taylor expanded in ux around 0
unpow2N/A
unpow2N/A
unswap-sqrN/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3299.0
Applied rewrites99.0%
Final simplification99.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(if (<= xi -1.5000000170217692e-19)
(+ (* 1.0 xi) (* zi (* (* maxCos ux) (- 1.0 ux))))
(if (<= xi 1.999999936531045e-20)
(-
(* (* 1.0 yi) (sin (* (* 2.0 uy) (PI))))
(* (* (* (- ux 1.0) maxCos) ux) zi))
(-
(*
(sqrt (- 1.0 (* (* maxCos maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0)))))
xi)
(* (/ -1.0 (/ (+ ux 1.0) (* (- 1.0 (* ux ux)) (* maxCos ux)))) zi)))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;xi \leq -1.5000000170217692 \cdot 10^{-19}:\\
\;\;\;\;1 \cdot xi + zi \cdot \left(\left(maxCos \cdot ux\right) \cdot \left(1 - ux\right)\right)\\
\mathbf{elif}\;xi \leq 1.999999936531045 \cdot 10^{-20}:\\
\;\;\;\;\left(1 \cdot yi\right) \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right)} \cdot xi - \frac{-1}{\frac{ux + 1}{\left(1 - ux \cdot ux\right) \cdot \left(maxCos \cdot ux\right)}} \cdot zi\\
\end{array}
\end{array}
if xi < -1.50000002e-19Initial program 99.4%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.4
Applied rewrites99.4%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites69.5%
Taylor expanded in ux around 0
Applied rewrites69.5%
if -1.50000002e-19 < xi < 1.99999994e-20Initial program 99.0%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites7.6%
Taylor expanded in ux around 0
Applied rewrites15.5%
Applied rewrites26.5%
Applied rewrites71.2%
if 1.99999994e-20 < xi Initial program 99.2%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lift--.f32N/A
flip--N/A
associate-*l/N/A
clear-numN/A
lower-/.f32N/A
lower-/.f32N/A
+-commutativeN/A
lower-+.f32N/A
lower-*.f32N/A
metadata-evalN/A
lower--.f32N/A
lower-*.f32N/A
lower-*.f3299.2
Applied rewrites99.2%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites71.2%
Final simplification70.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(-
(+
(* 1.0 xi)
(* yi (* (sin (* (* 2.0 uy) (PI))) (sqrt (- 1.0 (* t_0 t_0))))))
(* (* (- 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(1 \cdot xi + yi \cdot \left(\sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right)\right) - \left(\left(ux - 1\right) \cdot \left(maxCos \cdot ux\right)\right) \cdot zi
\end{array}
\end{array}
Initial program 99.1%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.2
Applied rewrites99.2%
Taylor expanded in uy around 0
sub-negN/A
mul-1-negN/A
lower-sqrt.f32N/A
mul-1-negN/A
sub-negN/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-*.f3290.7
Applied rewrites90.7%
Taylor expanded in ux around 0
Applied rewrites90.7%
Final simplification90.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* 1.0 xi) (* zi (* (* maxCos ux) (- 1.0 ux))))))
(if (<= xi -1.5000000170217692e-19)
t_0
(if (<= xi 1.999999936531045e-20)
(-
(* (* 1.0 yi) (sin (* (* 2.0 uy) (PI))))
(* (* (* (- ux 1.0) maxCos) ux) zi))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 \cdot xi + zi \cdot \left(\left(maxCos \cdot ux\right) \cdot \left(1 - ux\right)\right)\\
\mathbf{if}\;xi \leq -1.5000000170217692 \cdot 10^{-19}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;xi \leq 1.999999936531045 \cdot 10^{-20}:\\
\;\;\;\;\left(1 \cdot yi\right) \cdot \sin \left(\left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if xi < -1.50000002e-19 or 1.99999994e-20 < xi Initial program 99.3%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.3
Applied rewrites99.3%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites70.5%
Taylor expanded in ux around 0
Applied rewrites70.5%
if -1.50000002e-19 < xi < 1.99999994e-20Initial program 99.0%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites8.0%
Taylor expanded in ux around 0
Applied rewrites15.4%
Applied rewrites28.2%
Applied rewrites71.2%
Final simplification70.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (sin (* (* (PI) uy) 2.0)) yi)))
(if (<= yi -5.999999759184749e-13)
t_0
(if (<= yi 4.99999991225835e-14)
(-
(* (sqrt (- 1.0 (* (* ux ux) (* maxCos maxCos)))) xi)
(* (* (- ux 1.0) (* maxCos ux)) zi))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\\
\mathbf{if}\;yi \leq -5.999999759184749 \cdot 10^{-13}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;yi \leq 4.99999991225835 \cdot 10^{-14}:\\
\;\;\;\;\sqrt{1 - \left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot xi - \left(\left(ux - 1\right) \cdot \left(maxCos \cdot ux\right)\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if yi < -5.99999976e-13 or 4.99999991e-14 < yi Initial program 98.9%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites5.8%
Taylor expanded in ux around 0
Applied rewrites57.2%
if -5.99999976e-13 < yi < 4.99999991e-14Initial program 99.3%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.4
Applied rewrites99.4%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites73.2%
Taylor expanded in ux around 0
Applied rewrites73.2%
Final simplification66.5%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (- (* (sqrt (- 1.0 (* (* ux ux) (* maxCos maxCos)))) 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 - ((ux * ux) * (maxCos * maxCos)))) * 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 - ((ux * ux) * (maxcos * maxcos)))) * 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(ux * ux) * Float32(maxCos * maxCos)))) * xi) - Float32(Float32(Float32(ux - Float32(1.0)) * Float32(maxCos * ux)) * zi)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (sqrt((single(1.0) - ((ux * ux) * (maxCos * maxCos)))) * xi) - (((ux - single(1.0)) * (maxCos * ux)) * zi); end
\begin{array}{l}
\\
\sqrt{1 - \left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot xi - \left(\left(ux - 1\right) \cdot \left(maxCos \cdot ux\right)\right) \cdot zi
\end{array}
Initial program 99.1%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.2
Applied rewrites99.2%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites56.6%
Taylor expanded in ux around 0
Applied rewrites56.6%
Final simplification56.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (* 1.0 xi) (* zi (* (* maxCos ux) (- 1.0 ux)))))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (1.0f * xi) + (zi * ((maxCos * ux) * (1.0f - 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 = (1.0e0 * xi) + (zi * ((maxcos * ux) * (1.0e0 - ux)))
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(1.0) * xi) + Float32(zi * Float32(Float32(maxCos * ux) * Float32(Float32(1.0) - ux)))) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (single(1.0) * xi) + (zi * ((maxCos * ux) * (single(1.0) - ux))); end
\begin{array}{l}
\\
1 \cdot xi + zi \cdot \left(\left(maxCos \cdot ux\right) \cdot \left(1 - ux\right)\right)
\end{array}
Initial program 99.1%
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f3299.2
Applied rewrites99.2%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites56.6%
Taylor expanded in ux around 0
Applied rewrites56.6%
Final simplification56.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* zi (* maxCos ux)) (- 1.0 ux)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (zi * (maxCos * ux)) * (1.0f - 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 * ux)) * (1.0e0 - ux)
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(zi * Float32(maxCos * ux)) * Float32(Float32(1.0) - ux)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (zi * (maxCos * ux)) * (single(1.0) - ux); end
\begin{array}{l}
\\
\left(zi \cdot \left(maxCos \cdot ux\right)\right) \cdot \left(1 - ux\right)
\end{array}
Initial program 99.1%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3213.5
Applied rewrites13.5%
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(zi * Float32(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}
\\
zi \cdot \left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right)
\end{array}
Initial program 99.1%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3213.5
Applied rewrites13.5%
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 99.1%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3213.5
Applied rewrites13.5%
Taylor expanded in ux around 0
Applied rewrites12.3%
herbie shell --seed 2024325
(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)))