
(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 (* (PI) (* 2.0 uy)))
(t_1 (sin (acos (* (* maxCos (- 1.0 ux)) ux)))))
(+
(* xi (* t_1 (cos t_0)))
(- (* yi (* (sin t_0) t_1)) (* zi (* (* maxCos (+ -1.0 ux)) ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\\
t_1 := \sin \cos^{-1} \left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right)\\
xi \cdot \left(t\_1 \cdot \cos t\_0\right) + \left(yi \cdot \left(\sin t\_0 \cdot t\_1\right) - zi \cdot \left(\left(maxCos \cdot \left(-1 + ux\right)\right) \cdot ux\right)\right)
\end{array}
\end{array}
Initial program 98.9%
Applied rewrites98.9%
Final simplification98.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (sin (acos (* (* maxCos (- 1.0 ux)) ux))))
(t_1 (* (PI) (* 2.0 uy))))
(+
(* yi (* (sin t_1) t_0))
(- (* xi (* t_0 (cos t_1))) (* zi (* (* maxCos (+ -1.0 ux)) ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \cos^{-1} \left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right)\\
t_1 := \mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\\
yi \cdot \left(\sin t\_1 \cdot t\_0\right) + \left(xi \cdot \left(t\_0 \cdot \cos t\_1\right) - zi \cdot \left(\left(maxCos \cdot \left(-1 + ux\right)\right) \cdot ux\right)\right)
\end{array}
\end{array}
Initial program 98.9%
Applied rewrites98.9%
Final simplification98.9%
(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))
(* (* (* (+ -1.0 ux) maxCos) ux) 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) - \left(\left(\left(-1 + ux\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 (* (* (- 1.0 ux) maxCos) ux)))
(-
(+
(* (* (cos (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* t_0 t_0)))) xi)
(* (sin (* (* (PI) uy) 2.0)) yi))
(* (* (* (+ -1.0 ux) maxCos) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot xi + \sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi\right) - \left(\left(\left(-1 + ux\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
count-2-revN/A
distribute-lft-inN/A
count-2-revN/A
lower-sin.f32N/A
count-2-revN/A
distribute-lft-inN/A
count-2-revN/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
(-
(+
(* (* (cos (* (* uy 2.0) (PI))) 1.0) xi)
(*
(* 2.0 (* (* (PI) yi) uy))
(sqrt (- 1.0 (* (* (pow (- 1.0 ux) 2.0) (* ux ux)) (* maxCos maxCos))))))
(* (* (* (+ -1.0 ux) maxCos) ux) zi)))\begin{array}{l}
\\
\left(\left(\cos \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot 1\right) \cdot xi + \left(2 \cdot \left(\left(\mathsf{PI}\left(\right) \cdot yi\right) \cdot uy\right)\right) \cdot \sqrt{1 - \left({\left(1 - ux\right)}^{2} \cdot \left(ux \cdot ux\right)\right) \cdot \left(maxCos \cdot maxCos\right)}\right) - \left(\left(\left(-1 + ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
Initial program 98.9%
Taylor expanded in uy around 0
associate-*r*N/A
lower-*.f32N/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.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-*.f3291.0
Applied rewrites91.0%
Taylor expanded in ux around 0
Applied rewrites90.4%
Final simplification90.4%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) uy))
(t_1
(sqrt
(- 1.0 (* (* (pow (- 1.0 ux) 2.0) (* ux ux)) (* maxCos maxCos))))))
(if (or (<= xi -4.999999918875795e-18) (not (<= xi 4.9999998413276127e-20)))
(* (* (cos (* -2.0 t_0)) xi) t_1)
(-
(* t_1 (* (sin (* t_0 2.0)) yi))
(* (* (* (+ -1.0 ux) maxCos) ux) zi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot uy\\
t_1 := \sqrt{1 - \left({\left(1 - ux\right)}^{2} \cdot \left(ux \cdot ux\right)\right) \cdot \left(maxCos \cdot maxCos\right)}\\
\mathbf{if}\;xi \leq -4.999999918875795 \cdot 10^{-18} \lor \neg \left(xi \leq 4.9999998413276127 \cdot 10^{-20}\right):\\
\;\;\;\;\left(\cos \left(-2 \cdot t\_0\right) \cdot xi\right) \cdot t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_1 \cdot \left(\sin \left(t\_0 \cdot 2\right) \cdot yi\right) - \left(\left(\left(-1 + ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\end{array}
\end{array}
if xi < -4.99999992e-18 or 4.99999984e-20 < xi 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--.f328.0
Applied rewrites8.0%
Taylor expanded in ux around inf
Applied rewrites7.6%
Taylor expanded in xi around inf
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
cos-neg-revN/A
lower-cos.f32N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites81.3%
if -4.99999992e-18 < xi < 4.99999984e-20Initial program 98.6%
Taylor expanded in xi 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-*.f32N/A
Applied rewrites67.9%
Final simplification75.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) uy)) (t_1 (* t_0 2.0)))
(if (or (<= xi -5.000000097707407e-25) (not (<= xi 4.999999999099794e-24)))
(*
(* (cos (* -2.0 t_0)) xi)
(sqrt (- 1.0 (* (* (pow (- 1.0 ux) 2.0) (* ux ux)) (* maxCos maxCos)))))
(-
(fma (cos t_1) xi (* (sin t_1) yi))
(* (* (* (+ -1.0 ux) maxCos) ux) zi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot uy\\
t_1 := t\_0 \cdot 2\\
\mathbf{if}\;xi \leq -5.000000097707407 \cdot 10^{-25} \lor \neg \left(xi \leq 4.999999999099794 \cdot 10^{-24}\right):\\
\;\;\;\;\left(\cos \left(-2 \cdot t\_0\right) \cdot xi\right) \cdot \sqrt{1 - \left({\left(1 - ux\right)}^{2} \cdot \left(ux \cdot ux\right)\right) \cdot \left(maxCos \cdot maxCos\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos t\_1, xi, \sin t\_1 \cdot yi\right) - \left(\left(\left(-1 + ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\end{array}
\end{array}
if xi < -5.0000001e-25 or 5e-24 < xi Initial program 99.0%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f328.9
Applied rewrites8.9%
Taylor expanded in ux around inf
Applied rewrites7.8%
Taylor expanded in xi around inf
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
cos-neg-revN/A
lower-cos.f32N/A
distribute-lft-neg-inN/A
metadata-evalN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites74.5%
if -5.0000001e-25 < xi < 5e-24Initial program 98.6%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
count-2-revN/A
distribute-lft-inN/A
count-2-revN/A
lower-cos.f32N/A
count-2-revN/A
distribute-lft-inN/A
count-2-revN/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites54.6%
Final simplification67.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) uy) 2.0)) (t_1 (* (* (* (+ -1.0 ux) maxCos) ux) zi)))
(if (or (<= xi -1.000000023742228e-32) (not (<= xi 3.250000001880056e-26)))
(-
(*
(sqrt (- 1.0 (* (* (pow (- 1.0 ux) 2.0) (* ux ux)) (* maxCos maxCos))))
xi)
t_1)
(- (fma (cos t_0) xi (* (sin t_0) yi)) t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
t_1 := \left(\left(\left(-1 + ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{if}\;xi \leq -1.000000023742228 \cdot 10^{-32} \lor \neg \left(xi \leq 3.250000001880056 \cdot 10^{-26}\right):\\
\;\;\;\;\sqrt{1 - \left({\left(1 - ux\right)}^{2} \cdot \left(ux \cdot ux\right)\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot xi - t\_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\cos t\_0, xi, \sin t\_0 \cdot yi\right) - t\_1\\
\end{array}
\end{array}
if xi < -1.00000002e-32 or 3.25e-26 < xi Initial program 99.0%
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-*.f3262.7
Applied rewrites62.7%
if -1.00000002e-32 < xi < 3.25e-26Initial program 98.6%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
count-2-revN/A
distribute-lft-inN/A
count-2-revN/A
lower-cos.f32N/A
count-2-revN/A
distribute-lft-inN/A
count-2-revN/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites60.5%
Final simplification61.9%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (- (* (sqrt (- 1.0 (* (* (pow (- 1.0 ux) 2.0) (* ux ux)) (* maxCos maxCos)))) 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 - ((powf((1.0f - ux), 2.0f) * (ux * ux)) * (maxCos * maxCos)))) * 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 - ((((1.0e0 - ux) ** 2.0e0) * (ux * ux)) * (maxcos * maxcos)))) * 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((Float32(Float32(1.0) - ux) ^ Float32(2.0)) * Float32(ux * ux)) * Float32(maxCos * maxCos)))) * 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) - ((((single(1.0) - ux) ^ single(2.0)) * (ux * ux)) * (maxCos * maxCos)))) * xi) - ((((single(-1.0) + ux) * maxCos) * ux) * zi); end
\begin{array}{l}
\\
\sqrt{1 - \left({\left(1 - ux\right)}^{2} \cdot \left(ux \cdot ux\right)\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot xi - \left(\left(\left(-1 + ux\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-*.f3255.1
Applied rewrites55.1%
Final simplification55.1%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (- 1.0 ux) (* (* ux maxCos) zi)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (1.0f - ux) * ((ux * maxCos) * 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 = (1.0e0 - ux) * ((ux * maxcos) * zi)
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(1.0) - ux) * Float32(Float32(ux * maxCos) * zi)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (single(1.0) - ux) * ((ux * maxCos) * zi); end
\begin{array}{l}
\\
\left(1 - ux\right) \cdot \left(\left(ux \cdot maxCos\right) \cdot zi\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%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* (* (- 1.0 ux) zi) ux) maxCos))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (((1.0f - ux) * 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 = (((1.0e0 - ux) * zi) * ux) * maxcos
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(Float32(Float32(1.0) - ux) * zi) * ux) * maxCos) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (((single(1.0) - ux) * zi) * ux) * maxCos; end
\begin{array}{l}
\\
\left(\left(\left(1 - ux\right) \cdot zi\right) \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%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* (* (- 1.0 ux) maxCos) ux) zi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (((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 = (((1.0e0 - ux) * maxcos) * ux) * zi
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(Float32(Float32(1.0) - ux) * maxCos) * ux) * zi) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (((single(1.0) - ux) * maxCos) * ux) * zi; end
\begin{array}{l}
\\
\left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\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 (* zi ux)) ux) maxCos))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return ((zi - (zi * 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 - (zi * ux)) * ux) * maxcos
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(zi - Float32(zi * ux)) * ux) * maxCos) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = ((zi - (zi * ux)) * ux) * maxCos; end
\begin{array}{l}
\\
\left(\left(zi - zi \cdot ux\right) \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 inf
Applied rewrites8.6%
Taylor expanded in ux around 0
Applied rewrites13.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 rewrites12.4%
herbie shell --seed 2024326
(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)))