
(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))))
(t_2 (* (PI) uy)))
(-
(+
(* yi (* (* (* (cos t_2) (sin t_2)) 2.0) 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}\\
t_2 := \mathsf{PI}\left(\right) \cdot uy\\
\left(yi \cdot \left(\left(\left(\cos t\_2 \cdot \sin t\_2\right) \cdot 2\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-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-*.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))))
(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 98.9%
Final simplification98.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(-
(+
(* (* (sin (* (+ uy uy) (PI))) (sqrt (- 1.0 (* t_0 t_0)))) yi)
(*
(*
(sqrt (- 1.0 (* (* (* (- ux) ux) maxCos) t_0)))
(cos (* (PI) (* 2.0 uy))))
xi))
(* (* (* (- 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(\sin \left(\left(uy + uy\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot yi + \left(\sqrt{1 - \left(\left(\left(-ux\right) \cdot ux\right) \cdot maxCos\right) \cdot t\_0} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\right) \cdot xi\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 inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f32N/A
unpow2N/A
distribute-lft-neg-inN/A
lower-*.f32N/A
lower-neg.f3298.9
Applied rewrites98.9%
lift-PI.f32N/A
lift-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
count-2N/A
distribute-rgt-outN/A
lower-*.f32N/A
lift-PI.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)))
(-
(+
(* (cos (* (* (PI) uy) 2.0)) xi)
(* (* (sin (* (+ uy uy) (PI))) (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\\
\left(\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot xi + \left(\sin \left(\left(uy + uy\right) \cdot \mathsf{PI}\left(\right)\right) \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 98.9%
Taylor expanded in ux around inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f32N/A
unpow2N/A
distribute-lft-neg-inN/A
lower-*.f32N/A
lower-neg.f3298.9
Applied rewrites98.9%
lift-PI.f32N/A
lift-*.f32N/A
lift-*.f32N/A
*-commutativeN/A
associate-*r*N/A
count-2N/A
distribute-rgt-outN/A
lower-*.f32N/A
lift-PI.f32N/A
lower-+.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.9
Applied rewrites98.9%
Final simplification98.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) uy) 2.0)))
(-
(+ (* (sin t_0) yi) (* (cos t_0) xi))
(* (* (* (- 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(\sin t\_0 \cdot yi + \cos t\_0 \cdot xi\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 inf
mul-1-negN/A
*-commutativeN/A
distribute-lft-neg-inN/A
lower-*.f32N/A
unpow2N/A
distribute-lft-neg-inN/A
lower-*.f32N/A
lower-neg.f3298.9
Applied rewrites98.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.7
Applied rewrites98.7%
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.7
Applied rewrites98.7%
Final simplification98.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(-
(+
(* (fma (* (* maxCos maxCos) -0.5) (* ux ux) 1.0) xi)
(* (* (sin (* (PI) (* 2.0 uy))) (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\\
\left(\mathsf{fma}\left(\left(maxCos \cdot maxCos\right) \cdot -0.5, ux \cdot ux, 1\right) \cdot xi + \left(\sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right) \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 98.9%
lift--.f32N/A
sub-negN/A
+-commutativeN/A
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
swap-sqrN/A
associate-*r*N/A
distribute-lft-neg-inN/A
lower-fma.f32N/A
Applied rewrites53.6%
Taylor expanded in uy around 0
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-*.f3287.8
Applied rewrites87.8%
Taylor expanded in ux around 0
Applied rewrites87.7%
Final simplification87.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (* (- ux 1.0) maxCos) ux) zi)))
(if (<= xi -1.99999996490334e-14)
(-
(*
(sqrt
(fma (* (- maxCos) maxCos) (* (pow (- 1.0 ux) 2.0) (* ux ux)) 1.0))
xi)
t_0)
(if (<= xi 4.9999998413276127e-20)
(- (* (sin (* (* (PI) uy) 2.0)) yi) t_0)
(+ (* (* maxCos ux) zi) xi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{if}\;xi \leq -1.99999996490334 \cdot 10^{-14}:\\
\;\;\;\;\sqrt{\mathsf{fma}\left(\left(-maxCos\right) \cdot maxCos, {\left(1 - ux\right)}^{2} \cdot \left(ux \cdot ux\right), 1\right)} \cdot xi - t\_0\\
\mathbf{elif}\;xi \leq 4.9999998413276127 \cdot 10^{-20}:\\
\;\;\;\;\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi - t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(maxCos \cdot ux\right) \cdot zi + xi\\
\end{array}
\end{array}
if xi < -1.99999996e-14Initial program 99.0%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites7.9%
if -1.99999996e-14 < xi < 4.99999984e-20Initial program 98.9%
Taylor expanded in xi around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites10.9%
Taylor expanded in ux around 0
Applied rewrites67.3%
if 4.99999984e-20 < xi 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.1
Applied rewrites99.1%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites8.0%
Taylor expanded in ux around 0
Applied rewrites66.0%
Applied rewrites67.0%
Final simplification53.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (* (- ux 1.0) maxCos) ux) zi)))
(if (<= xi -1.99999996490334e-14)
(- (* (sqrt (- 1.0 (pow (* (* maxCos (- 1.0 ux)) ux) 2.0))) xi) t_0)
(if (<= xi 4.9999998413276127e-20)
(- (* (sin (* (* (PI) uy) 2.0)) yi) t_0)
(+ (* (* maxCos ux) zi) xi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{if}\;xi \leq -1.99999996490334 \cdot 10^{-14}:\\
\;\;\;\;\sqrt{1 - {\left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right)}^{2}} \cdot xi - t\_0\\
\mathbf{elif}\;xi \leq 4.9999998413276127 \cdot 10^{-20}:\\
\;\;\;\;\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi - t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(maxCos \cdot ux\right) \cdot zi + xi\\
\end{array}
\end{array}
if xi < -1.99999996e-14Initial 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%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites7.3%
Applied rewrites70.4%
if -1.99999996e-14 < xi < 4.99999984e-20Initial program 98.9%
Taylor expanded in xi around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites9.4%
Taylor expanded in ux around 0
Applied rewrites67.3%
if 4.99999984e-20 < xi 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.1
Applied rewrites99.1%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites8.0%
Taylor expanded in ux around 0
Applied rewrites66.0%
Applied rewrites67.0%
Final simplification67.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos ux) zi)))
(if (<= xi -1.99999996490334e-14)
(/ (- (pow t_0 2.0) (* xi xi)) (- t_0 xi))
(if (<= xi 4.9999998413276127e-20)
(- (* (sin (* (* (PI) uy) 2.0)) yi) (* (* (* (- ux 1.0) maxCos) ux) zi))
(+ t_0 xi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot ux\right) \cdot zi\\
\mathbf{if}\;xi \leq -1.99999996490334 \cdot 10^{-14}:\\
\;\;\;\;\frac{{t\_0}^{2} - xi \cdot xi}{t\_0 - xi}\\
\mathbf{elif}\;xi \leq 4.9999998413276127 \cdot 10^{-20}:\\
\;\;\;\;\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 + xi\\
\end{array}
\end{array}
if xi < -1.99999996e-14Initial 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%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites7.3%
Taylor expanded in ux around 0
Applied rewrites69.6%
Applied rewrites69.9%
if -1.99999996e-14 < xi < 4.99999984e-20Initial program 98.9%
Taylor expanded in xi around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites10.2%
Taylor expanded in ux around 0
Applied rewrites67.3%
if 4.99999984e-20 < xi 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.1
Applied rewrites99.1%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites8.0%
Taylor expanded in ux around 0
Applied rewrites66.0%
Applied rewrites67.0%
Final simplification67.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (+ (* (* maxCos ux) zi) xi)))
(if (<= xi -1.99999996490334e-14)
t_0
(if (<= xi 4.9999998413276127e-20)
(- (* (sin (* (* (PI) uy) 2.0)) yi) (* (* (* (- ux 1.0) maxCos) ux) zi))
t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot ux\right) \cdot zi + xi\\
\mathbf{if}\;xi \leq -1.99999996490334 \cdot 10^{-14}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;xi \leq 4.9999998413276127 \cdot 10^{-20}:\\
\;\;\;\;\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 < -1.99999996e-14 or 4.99999984e-20 < xi 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%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites7.7%
Taylor expanded in ux around 0
Applied rewrites67.7%
Applied rewrites68.4%
if -1.99999996e-14 < xi < 4.99999984e-20Initial program 98.9%
Taylor expanded in xi around 0
*-commutativeN/A
lower-*.f32N/A
Applied rewrites10.0%
Taylor expanded in ux around 0
Applied rewrites67.3%
Final simplification67.8%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (* (* maxCos ux) zi) xi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return ((maxCos * ux) * zi) + 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 = ((maxcos * ux) * zi) + xi
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(maxCos * ux) * zi) + xi) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = ((maxCos * ux) * zi) + xi; end
\begin{array}{l}
\\
\left(maxCos \cdot ux\right) \cdot zi + xi
\end{array}
Initial program 98.9%
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-*.f3298.9
Applied rewrites98.9%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites13.7%
Taylor expanded in ux around 0
Applied rewrites46.2%
Applied rewrites49.9%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma zi (* maxCos ux) xi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return fmaf(zi, (maxCos * ux), xi);
}
function code(xi, yi, zi, ux, uy, maxCos) return fma(zi, Float32(maxCos * ux), xi) end
\begin{array}{l}
\\
\mathsf{fma}\left(zi, maxCos \cdot ux, xi\right)
\end{array}
Initial program 98.9%
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-*.f3298.9
Applied rewrites98.9%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites13.7%
Taylor expanded in ux around 0
Applied rewrites46.2%
Applied rewrites46.2%
(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.7
Applied rewrites13.7%
Taylor expanded in ux around 0
Applied rewrites11.8%
herbie shell --seed 2024288
(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)))