
(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 15 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 (* (PI) (* 2.0 uy)))
(t_1 (* (* maxCos (- 1.0 ux)) ux))
(t_2 (sqrt (- 1.0 (* t_1 t_1)))))
(+
(* zi (* (* (* (- (/ 1.0 ux) 1.0) ux) maxCos) ux))
(+ (* yi (* (sin t_0) t_2)) (* xi (* t_2 (cos t_0)))))))\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\\
t_2 := \sqrt{1 - t\_1 \cdot t\_1}\\
zi \cdot \left(\left(\left(\left(\frac{1}{ux} - 1\right) \cdot ux\right) \cdot maxCos\right) \cdot ux\right) + \left(yi \cdot \left(\sin t\_0 \cdot t\_2\right) + xi \cdot \left(t\_2 \cdot \cos t\_0\right)\right)
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f3298.9
Applied rewrites98.9%
Taylor expanded in maxCos around 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))))
(-
(+ (* yi (* (sin t_2) t_1)) (* xi (* t_1 (cos t_2))))
(* (* (* (+ -1.0 ux) 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(yi \cdot \left(\sin t\_2 \cdot t\_1\right) + xi \cdot \left(t\_1 \cdot \cos t\_2\right)\right) - \left(\left(\left(-1 + ux\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)))
(-
(+
(* (cos (* (* (PI) uy) 2.0)) xi)
(* yi (* (sin (* (PI) (* 2.0 uy))) (sqrt (- 1.0 (* t_0 t_0))))))
(* (* (* (+ -1.0 ux) 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(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right)\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 maxCos around 0
*-commutativeN/A
lower-*.f32N/A
lower-cos.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 (* (* maxCos (- 1.0 ux)) ux)) (t_1 (sqrt (- 1.0 (* t_0 t_0)))))
(+
(* (* (* (- (/ maxCos ux) maxCos) ux) ux) zi)
(+ (* (* 1.0 t_1) xi) (* yi (* (sin (* (PI) (* 2.0 uy))) t_1))))))\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(\frac{maxCos}{ux} - maxCos\right) \cdot ux\right) \cdot ux\right) \cdot zi + \left(\left(1 \cdot t\_1\right) \cdot xi + yi \cdot \left(\sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \cdot t\_1\right)\right)
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f3298.9
Applied rewrites98.9%
Taylor expanded in uy around 0
Applied rewrites90.4%
Final simplification90.4%
(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))))))
(* (* (* (+ -1.0 ux) 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(-1 + ux\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.f3289.3
Applied rewrites89.3%
Final simplification89.3%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0
(sqrt
(- 1.0 (* (* maxCos maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0))))))
(t_1
(-
(* t_0 (* (* (* yi (PI)) uy) 2.0))
(* (* (* (+ -1.0 ux) maxCos) ux) zi))))
(if (<= yi -9.999999960041972e-12)
t_1
(if (<= yi 2.00000009162741e-18)
(+ (* t_0 xi) (* zi (* (* (* (- (/ 1.0 ux) 1.0) ux) maxCos) ux)))
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right)}\\
t_1 := t\_0 \cdot \left(\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2\right) - \left(\left(\left(-1 + ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{if}\;yi \leq -9.999999960041972 \cdot 10^{-12}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;yi \leq 2.00000009162741 \cdot 10^{-18}:\\
\;\;\;\;t\_0 \cdot xi + zi \cdot \left(\left(\left(\left(\frac{1}{ux} - 1\right) \cdot ux\right) \cdot maxCos\right) \cdot ux\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if yi < -9.99999996e-12 or 2.00000009e-18 < yi Initial program 98.7%
Taylor expanded in maxCos around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3253.4
Applied rewrites53.4%
Taylor expanded in uy around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites21.3%
Taylor expanded in xi around 0
Applied rewrites61.7%
if -9.99999996e-12 < yi < 2.00000009e-18Initial program 99.2%
Taylor expanded in ux around inf
*-commutativeN/A
lower-*.f32N/A
+-commutativeN/A
mul-1-negN/A
unsub-negN/A
lower--.f32N/A
lower-/.f3299.1
Applied rewrites99.1%
Taylor expanded in maxCos around 0
Applied rewrites99.2%
Taylor expanded in uy around 0
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-*.f3269.3
Applied rewrites69.3%
Final simplification65.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0
(sqrt
(- 1.0 (* (* maxCos maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0))))))
(t_1 (* (* (* (+ -1.0 ux) maxCos) ux) zi))
(t_2 (- (* t_0 (* (* (* yi (PI)) uy) 2.0)) t_1)))
(if (<= yi -9.999999960041972e-12)
t_2
(if (<= yi 2.00000009162741e-18) (- (* t_0 xi) t_1) t_2))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(\left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}\right)}\\
t_1 := \left(\left(\left(-1 + ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
t_2 := t\_0 \cdot \left(\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2\right) - t\_1\\
\mathbf{if}\;yi \leq -9.999999960041972 \cdot 10^{-12}:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;yi \leq 2.00000009162741 \cdot 10^{-18}:\\
\;\;\;\;t\_0 \cdot xi - t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_2\\
\end{array}
\end{array}
if yi < -9.99999996e-12 or 2.00000009e-18 < yi Initial program 98.7%
Taylor expanded in maxCos around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3253.4
Applied rewrites53.4%
Taylor expanded in uy around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites21.3%
Taylor expanded in xi around 0
Applied rewrites61.7%
if -9.99999996e-12 < yi < 2.00000009e-18Initial program 99.2%
lift-*.f32N/A
*-commutativeN/A
lift-PI.f32N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f32N/A
pow2N/A
lower-pow.f32N/A
lift-PI.f32N/A
lower-cbrt.f32N/A
lower-*.f32N/A
lift-PI.f32N/A
lower-cbrt.f3299.0
lift-*.f32N/A
*-commutativeN/A
lower-*.f3299.0
Applied rewrites99.0%
Taylor expanded in uy around 0
lower-*.f32N/A
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-*.f3269.3
Applied rewrites69.3%
Final simplification65.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(if (<= xi 3.99999987306209e-21)
(- (fma (* (* yi (PI)) uy) 2.0 xi) (* (* (* (+ -1.0 ux) maxCos) ux) zi))
(fma
xi
(sqrt (fma (* (- maxCos) maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0)) 1.0))
(* (* (* zi (- 1.0 ux)) ux) maxCos))))\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;xi \leq 3.99999987306209 \cdot 10^{-21}:\\
\;\;\;\;\mathsf{fma}\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy, 2, xi\right) - \left(\left(\left(-1 + ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(xi, \sqrt{\mathsf{fma}\left(\left(-maxCos\right) \cdot maxCos, \left(ux \cdot ux\right) \cdot {\left(1 - ux\right)}^{2}, 1\right)}, \left(\left(zi \cdot \left(1 - ux\right)\right) \cdot ux\right) \cdot maxCos\right)\\
\end{array}
\end{array}
if xi < 3.9999999e-21Initial program 98.9%
Taylor expanded in maxCos around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3254.1
Applied rewrites54.1%
Taylor expanded in uy around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites40.2%
Taylor expanded in maxCos around 0
Applied rewrites39.9%
if 3.9999999e-21 < xi Initial program 99.0%
Taylor expanded in uy around 0
+-commutativeN/A
lower-fma.f32N/A
Applied rewrites35.7%
Final simplification36.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (- (* (sqrt (- 1.0 (* (* maxCos maxCos) (* (* ux ux) (pow (- 1.0 ux) 2.0))))) xi) (* (* (* (+ -1.0 ux) 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) - ((((-1.0f + ux) * 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) - (((((-1.0e0) + ux) * 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(Float32(-1.0) + ux) * 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) - ((((single(-1.0) + ux) * 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(-1 + ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
Initial program 99.0%
lift-*.f32N/A
*-commutativeN/A
lift-PI.f32N/A
add-cube-cbrtN/A
associate-*l*N/A
lower-*.f32N/A
pow2N/A
lower-pow.f32N/A
lift-PI.f32N/A
lower-cbrt.f32N/A
lower-*.f32N/A
lift-PI.f32N/A
lower-cbrt.f3298.4
lift-*.f32N/A
*-commutativeN/A
lower-*.f3298.4
Applied rewrites98.4%
Taylor expanded in uy around 0
lower-*.f32N/A
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-*.f3246.6
Applied rewrites46.6%
Final simplification46.6%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* yi (PI))) (t_1 (* (sqrt -1.0) (- 1.0 ux))))
(if (<= xi 2.0999999333575973e-20)
(- (fma (* t_0 uy) 2.0 xi) (* (* (* (+ -1.0 ux) maxCos) ux) zi))
(fma
xi
(* (* maxCos ux) t_1)
(fma
(* (* maxCos ux) zi)
(- 1.0 ux)
(* (* maxCos 2.0) (* (* ux uy) (* t_0 t_1))))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := yi \cdot \mathsf{PI}\left(\right)\\
t_1 := \sqrt{-1} \cdot \left(1 - ux\right)\\
\mathbf{if}\;xi \leq 2.0999999333575973 \cdot 10^{-20}:\\
\;\;\;\;\mathsf{fma}\left(t\_0 \cdot uy, 2, xi\right) - \left(\left(\left(-1 + ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(xi, \left(maxCos \cdot ux\right) \cdot t\_1, \mathsf{fma}\left(\left(maxCos \cdot ux\right) \cdot zi, 1 - ux, \left(maxCos \cdot 2\right) \cdot \left(\left(ux \cdot uy\right) \cdot \left(t\_0 \cdot t\_1\right)\right)\right)\right)\\
\end{array}
\end{array}
if xi < 2.09999993e-20Initial program 98.9%
Taylor expanded in maxCos around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3254.3
Applied rewrites54.3%
Taylor expanded in uy around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites40.3%
Taylor expanded in maxCos around 0
Applied rewrites40.0%
if 2.09999993e-20 < xi Initial program 99.0%
Taylor expanded in maxCos around inf
*-commutativeN/A
lower-*.f32N/A
Applied rewrites8.5%
Taylor expanded in uy around 0
Applied rewrites11.5%
Applied rewrites55.9%
Final simplification39.0%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (- (fma (* (* yi (PI)) uy) 2.0 xi) (* (* (* (+ -1.0 ux) maxCos) ux) zi)))
\begin{array}{l}
\\
\mathsf{fma}\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy, 2, xi\right) - \left(\left(\left(-1 + ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around inf
*-commutativeN/A
lower-*.f32N/A
lower--.f32N/A
lower-/.f32N/A
unpow2N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-pow.f32N/A
lower--.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3251.6
Applied rewrites51.6%
Taylor expanded in uy around 0
associate-*r*N/A
distribute-rgt-outN/A
lower-*.f32N/A
Applied rewrites46.6%
Taylor expanded in maxCos around 0
Applied rewrites46.3%
Final simplification46.6%
(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;
}
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)) * 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--.f3213.4
Applied rewrites13.4%
(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.0%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f3213.4
Applied rewrites13.4%
Applied rewrites13.4%
Final simplification13.4%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* (- 1.0 ux) ux) (* zi maxCos)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return ((1.0f - ux) * ux) * (zi * 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 * maxcos)
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(Float32(1.0) - ux) * ux) * Float32(zi * maxCos)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = ((single(1.0) - ux) * ux) * (zi * maxCos); end
\begin{array}{l}
\\
\left(\left(1 - ux\right) \cdot ux\right) \cdot \left(zi \cdot maxCos\right)
\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.4
Applied rewrites13.4%
Applied rewrites13.4%
Final simplification13.4%
(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.4
Applied rewrites13.4%
Taylor expanded in ux around 0
Applied rewrites11.4%
herbie shell --seed 2024267
(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)))