
(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 (* (* (- 1.0 ux) maxCos) ux)) (t_1 (* (* 2.0 uy) (PI)))) (+ (* (cos t_1) xi) (+ (* (* yi (sin t_1)) (sin (acos t_0))) (* zi t_0)))))
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
t_1 := \left(2 \cdot uy\right) \cdot \mathsf{PI}\left(\right)\\
\cos t\_1 \cdot xi + \left(\left(yi \cdot \sin t\_1\right) \cdot \sin \cos^{-1} t\_0 + zi \cdot t\_0\right)
\end{array}
\end{array}
Initial program 98.9%
Taylor expanded in ux around 0
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.f3298.9
Applied rewrites98.9%
Applied rewrites98.9%
Final simplification98.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(+
(+
(* (cos (* -2.0 (* (PI) uy))) xi)
(*
(* yi (sin (* (PI) (* 2.0 uy))))
(sin (acos (* (* maxCos (- 1.0 ux)) ux)))))
(* (* (* (- 1.0 ux) maxCos) ux) zi)))\begin{array}{l}
\\
\left(\cos \left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\right) \cdot xi + \left(yi \cdot \sin \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\right) \cdot \sin \cos^{-1} \left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right)\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\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
lift-sqrt.f32N/A
Applied rewrites98.9%
Taylor expanded in ux around 0
*-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.f3298.9
Applied rewrites98.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)) (* 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}
Initial program 98.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- 1.0 ux) maxCos) ux)))
(+
(+
(* (cos (* -2.0 (* (PI) uy))) xi)
(* (* (sin (* (* uy 2.0) (PI))) (sqrt (- 1.0 (* t_0 t_0)))) yi))
(* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\\
\left(\cos \left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot yi\right) + t\_0 \cdot zi
\end{array}
\end{array}
Initial program 98.9%
Taylor expanded in ux around 0
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.f3298.9
Applied rewrites98.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(+
(+
(* (cos (* -2.0 (* (PI) uy))) xi)
(*
(*
(sin (* (* uy 2.0) (PI)))
(sqrt (- 1.0 (* (* maxCos ux) (* maxCos ux)))))
yi))
(* (* (* (- 1.0 ux) maxCos) ux) zi)))\begin{array}{l}
\\
\left(\cos \left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\right) \cdot xi + \left(\sin \left(\left(uy \cdot 2\right) \cdot \mathsf{PI}\left(\right)\right) \cdot \sqrt{1 - \left(maxCos \cdot ux\right) \cdot \left(maxCos \cdot ux\right)}\right) \cdot yi\right) + \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
Initial program 98.9%
Taylor expanded in ux around 0
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.f3298.9
Applied rewrites98.9%
Taylor expanded in ux around 0
unpow2N/A
unpow2N/A
unswap-sqrN/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3298.6
Applied rewrites98.6%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) uy) -2.0)))
(+
(- (* (cos t_0) xi) (* (sin t_0) yi))
(* (* (* (- 1.0 ux) 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(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-fma.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
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3233.8
Applied rewrites33.8%
Applied rewrites98.6%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (* (- 1.0 ux) maxCos) ux) zi)) (t_1 (* (PI) uy)))
(if (or (<= yi -3.999999984016789e-11) (not (<= yi 1.4280000293354078e-8)))
(+
(*
(sqrt
(- 1.0 (* (* (* (- 1.0 ux) (- 1.0 ux)) (* ux ux)) (* maxCos maxCos))))
(* (sin (* t_1 2.0)) yi))
t_0)
(+ (* (cos (* -2.0 t_1)) xi) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
t_1 := \mathsf{PI}\left(\right) \cdot uy\\
\mathbf{if}\;yi \leq -3.999999984016789 \cdot 10^{-11} \lor \neg \left(yi \leq 1.4280000293354078 \cdot 10^{-8}\right):\\
\;\;\;\;\sqrt{1 - \left(\left(\left(1 - ux\right) \cdot \left(1 - ux\right)\right) \cdot \left(ux \cdot ux\right)\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\sin \left(t\_1 \cdot 2\right) \cdot yi\right) + t\_0\\
\mathbf{else}:\\
\;\;\;\;\cos \left(-2 \cdot t\_1\right) \cdot xi + t\_0\\
\end{array}
\end{array}
if yi < -3.99999998e-11 or 1.42800003e-8 < yi Initial program 98.4%
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 rewrites73.9%
Applied rewrites73.9%
if -3.99999998e-11 < yi < 1.42800003e-8Initial program 99.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.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
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3224.9
Applied rewrites24.9%
Taylor expanded in xi around inf
Applied rewrites77.3%
Final simplification76.1%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) uy))
(t_1 (* (sin (* t_0 2.0)) yi))
(t_2 (* (* (* (- 1.0 ux) maxCos) ux) zi)))
(if (<= yi -3.999999984016789e-11)
(+
(* (sqrt (- 1.0 (* (* (* ux ux) (* ux ux)) (* maxCos maxCos)))) t_1)
t_2)
(if (<= yi 1.4280000293354078e-8)
(+ (* (cos (* -2.0 t_0)) xi) t_2)
(+
(*
(sqrt (- 1.0 (* (* (fma -2.0 ux 1.0) (* ux ux)) (* maxCos maxCos))))
t_1)
t_2)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot uy\\
t_1 := \sin \left(t\_0 \cdot 2\right) \cdot yi\\
t_2 := \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{if}\;yi \leq -3.999999984016789 \cdot 10^{-11}:\\
\;\;\;\;\sqrt{1 - \left(\left(ux \cdot ux\right) \cdot \left(ux \cdot ux\right)\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot t\_1 + t\_2\\
\mathbf{elif}\;yi \leq 1.4280000293354078 \cdot 10^{-8}:\\
\;\;\;\;\cos \left(-2 \cdot t\_0\right) \cdot xi + t\_2\\
\mathbf{else}:\\
\;\;\;\;\sqrt{1 - \left(\mathsf{fma}\left(-2, ux, 1\right) \cdot \left(ux \cdot ux\right)\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot t\_1 + t\_2\\
\end{array}
\end{array}
if yi < -3.99999998e-11Initial program 98.3%
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 rewrites71.0%
Taylor expanded in ux around inf
Applied rewrites70.1%
if -3.99999998e-11 < yi < 1.42800003e-8Initial program 99.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.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
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3224.9
Applied rewrites24.9%
Taylor expanded in xi around inf
Applied rewrites77.3%
if 1.42800003e-8 < yi Initial program 98.5%
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 rewrites77.9%
Taylor expanded in ux around 0
Applied rewrites77.6%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (* (- 1.0 ux) maxCos) ux) zi)) (t_1 (* (PI) uy)))
(if (or (<= yi -3.999999984016789e-11) (not (<= yi 1.4280000293354078e-8)))
(+
(*
(sqrt (- 1.0 (* (* (* ux ux) (* ux ux)) (* maxCos maxCos))))
(* (sin (* t_1 2.0)) yi))
t_0)
(+ (* (cos (* -2.0 t_1)) xi) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
t_1 := \mathsf{PI}\left(\right) \cdot uy\\
\mathbf{if}\;yi \leq -3.999999984016789 \cdot 10^{-11} \lor \neg \left(yi \leq 1.4280000293354078 \cdot 10^{-8}\right):\\
\;\;\;\;\sqrt{1 - \left(\left(ux \cdot ux\right) \cdot \left(ux \cdot ux\right)\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot \left(\sin \left(t\_1 \cdot 2\right) \cdot yi\right) + t\_0\\
\mathbf{else}:\\
\;\;\;\;\cos \left(-2 \cdot t\_1\right) \cdot xi + t\_0\\
\end{array}
\end{array}
if yi < -3.99999998e-11 or 1.42800003e-8 < yi Initial program 98.4%
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 rewrites73.9%
Taylor expanded in ux around inf
Applied rewrites73.3%
if -3.99999998e-11 < yi < 1.42800003e-8Initial program 99.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.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
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3224.9
Applied rewrites24.9%
Taylor expanded in xi around inf
Applied rewrites77.3%
Final simplification75.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (PI) uy)) (t_1 (* (* (* (- 1.0 ux) maxCos) ux) zi)))
(if (or (<= yi -3.999999984016789e-11) (not (<= yi 1.4280000293354078e-8)))
(+ (* (sin (* t_0 2.0)) yi) t_1)
(+ (* (cos (* -2.0 t_0)) xi) t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot uy\\
t_1 := \left(\left(\left(1 - ux\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{if}\;yi \leq -3.999999984016789 \cdot 10^{-11} \lor \neg \left(yi \leq 1.4280000293354078 \cdot 10^{-8}\right):\\
\;\;\;\;\sin \left(t\_0 \cdot 2\right) \cdot yi + t\_1\\
\mathbf{else}:\\
\;\;\;\;\cos \left(-2 \cdot t\_0\right) \cdot xi + t\_1\\
\end{array}
\end{array}
if yi < -3.99999998e-11 or 1.42800003e-8 < yi Initial program 98.4%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.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
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3250.0
Applied rewrites50.0%
Taylor expanded in xi around 0
Applied rewrites73.2%
if -3.99999998e-11 < yi < 1.42800003e-8Initial program 99.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.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
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3224.9
Applied rewrites24.9%
Taylor expanded in xi around inf
Applied rewrites77.3%
Final simplification75.9%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (* (cos (* -2.0 (* (PI) uy))) xi) (* (* (* (- 1.0 ux) maxCos) ux) zi)))
\begin{array}{l}
\\
\cos \left(-2 \cdot \left(\mathsf{PI}\left(\right) \cdot uy\right)\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 ux around 0
*-commutativeN/A
lower-fma.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
*-commutativeN/A
lower-*.f32N/A
lower-sin.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3233.8
Applied rewrites34.1%
Taylor expanded in xi around inf
Applied rewrites57.3%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (* (sqrt (- 1.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 - ((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 - ((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(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) - ((ux * ux) * (maxCos * maxCos)))) * xi) + ((((single(1.0) - ux) * maxCos) * ux) * zi); end
\begin{array}{l}
\\
\sqrt{1 - \left(ux \cdot ux\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-*.f3250.9
Applied rewrites50.9%
Taylor expanded in ux around 0
Applied rewrites50.9%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (* 1.0 xi) (* (* (* (- 1.0 ux) maxCos) ux) zi)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (1.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 = (1.0e0 * xi) + ((((1.0e0 - ux) * maxcos) * ux) * zi)
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(1.0) * xi) + 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) * xi) + ((((single(1.0) - ux) * maxCos) * ux) * zi); end
\begin{array}{l}
\\
1 \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-*.f3250.9
Applied rewrites50.9%
Taylor expanded in ux around 0
Applied rewrites50.8%
(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 * maxCos) * Float32(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 maxCos\right) \cdot \left(\left(1 - ux\right) \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--.f3214.2
Applied rewrites14.2%
Applied rewrites14.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--.f3214.2
Applied rewrites14.2%
Taylor expanded in ux around 0
Applied rewrites12.2%
herbie shell --seed 2024337
(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)))