
(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 (* (* (- ux 1.0) maxCos) ux)) (t_1 (* (PI) (* 2.0 uy))))
(-
(+
(* (sqrt (- 1.0 (pow (* (* maxCos (- 1.0 ux)) ux) 2.0))) (* (sin t_1) yi))
(* xi (* (sqrt (- 1.0 (* t_0 t_0))) (cos t_1))))
(* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\\
t_1 := \mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\\
\left(\sqrt{1 - {\left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right)}^{2}} \cdot \left(\sin t\_1 \cdot yi\right) + xi \cdot \left(\sqrt{1 - t\_0 \cdot t\_0} \cdot \cos t\_1\right)\right) - t\_0 \cdot zi
\end{array}
\end{array}
Initial program 99.0%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3299.0
lift-*.f32N/A
*-commutativeN/A
lower-*.f3299.0
lift-*.f32N/A
*-commutativeN/A
lower-*.f3299.0
Applied rewrites99.0%
Final simplification99.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- ux 1.0) maxCos) 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)))) (* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(ux - 1\right) \cdot maxCos\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) - t\_0 \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 (* (PI) (* 2.0 uy))) (t_1 (* (* (- ux 1.0) maxCos) ux)))
(-
(+
(* (sqrt (- 1.0 (* (* maxCos maxCos) (* ux ux)))) (* (sin t_0) yi))
(* xi (* (sqrt (- 1.0 (* t_1 t_1))) (cos t_0))))
(* t_1 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\\
t_1 := \left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\\
\left(\sqrt{1 - \left(maxCos \cdot maxCos\right) \cdot \left(ux \cdot ux\right)} \cdot \left(\sin t\_0 \cdot yi\right) + xi \cdot \left(\sqrt{1 - t\_1 \cdot t\_1} \cdot \cos t\_0\right)\right) - t\_1 \cdot zi
\end{array}
\end{array}
Initial program 99.0%
lift-*.f32N/A
*-commutativeN/A
lift-*.f32N/A
associate-*r*N/A
lower-*.f32N/A
lower-*.f3299.0
lift-*.f32N/A
*-commutativeN/A
lower-*.f3299.0
lift-*.f32N/A
*-commutativeN/A
lower-*.f3299.0
Applied rewrites99.0%
Taylor expanded in ux around 0
*-commutativeN/A
lower-*.f32N/A
unpow2N/A
lower-*.f32N/A
unpow2N/A
lower-*.f3299.0
Applied rewrites99.0%
Final simplification99.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- ux 1.0) maxCos) ux)))
(-
(+
(* (sin (* (* (PI) uy) 2.0)) yi)
(* xi (* (sqrt (- 1.0 (* t_0 t_0))) (cos (* (PI) (* 2.0 uy))))))
(* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\\
\left(\sin \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot yi + xi \cdot \left(\sqrt{1 - t\_0 \cdot t\_0} \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\right)\right) - t\_0 \cdot zi
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in maxCos around 0
*-commutativeN/A
lower-*.f32N/A
lower-sin.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))
(t_1 (* (* (- ux 1.0) maxCos) ux))
(t_2 (sqrt (- 1.0 (* t_1 t_1)))))
(if (<= (* 2.0 uy) 0.0009500000160187483)
(-
(+ (* (* t_0 t_2) yi) (* xi (* t_2 (cos (* (PI) (* 2.0 uy))))))
(* t_1 zi))
(+ (* (+ (* (/ (cos t_0) yi) xi) (sin t_0)) yi) (* (* zi ux) maxCos)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
t_1 := \left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\\
t_2 := \sqrt{1 - t\_1 \cdot t\_1}\\
\mathbf{if}\;2 \cdot uy \leq 0.0009500000160187483:\\
\;\;\;\;\left(\left(t\_0 \cdot t\_2\right) \cdot yi + xi \cdot \left(t\_2 \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\right)\right) - t\_1 \cdot zi\\
\mathbf{else}:\\
\;\;\;\;\left(\frac{\cos t\_0}{yi} \cdot xi + \sin t\_0\right) \cdot yi + \left(zi \cdot ux\right) \cdot maxCos\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 9.50000016e-4Initial program 99.3%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3299.2
Applied rewrites99.2%
if 9.50000016e-4 < (*.f32 uy #s(literal 2 binary32)) Initial program 98.5%
Applied rewrites88.5%
Taylor expanded in yi around -inf
Applied rewrites98.2%
Taylor expanded in ux around 0
Applied rewrites94.2%
Final simplification97.4%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) uy) 2.0)))
(-
(* (+ (* (/ (cos t_0) yi) xi) (sin t_0)) yi)
(* (* (* (- ux 1.0) zi) ux) maxCos))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
\left(\frac{\cos t\_0}{yi} \cdot xi + \sin t\_0\right) \cdot yi - \left(\left(\left(ux - 1\right) \cdot zi\right) \cdot ux\right) \cdot maxCos
\end{array}
\end{array}
Initial program 99.0%
Applied rewrites83.4%
Taylor expanded in yi around -inf
Applied rewrites98.8%
Taylor expanded in maxCos around 0
Applied rewrites97.9%
Final simplification97.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) uy) 2.0))
(t_1 (* (* (- ux 1.0) maxCos) ux))
(t_2 (sqrt (- 1.0 (* t_1 t_1)))))
(if (<= (* 2.0 uy) 0.0015999999595806003)
(-
(+ (* (* t_0 t_2) yi) (* xi (* t_2 (cos (* (PI) (* 2.0 uy))))))
(* t_1 zi))
(* (- yi) (- (* (/ (cos t_0) (- yi)) xi) (sin t_0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
t_1 := \left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\\
t_2 := \sqrt{1 - t\_1 \cdot t\_1}\\
\mathbf{if}\;2 \cdot uy \leq 0.0015999999595806003:\\
\;\;\;\;\left(\left(t\_0 \cdot t\_2\right) \cdot yi + xi \cdot \left(t\_2 \cdot \cos \left(\mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\right)\right)\right) - t\_1 \cdot zi\\
\mathbf{else}:\\
\;\;\;\;\left(-yi\right) \cdot \left(\frac{\cos t\_0}{-yi} \cdot xi - \sin t\_0\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00159999996Initial program 99.4%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3299.1
Applied rewrites99.1%
if 0.00159999996 < (*.f32 uy #s(literal 2 binary32)) Initial program 98.4%
Applied rewrites88.4%
Taylor expanded in yi around -inf
Applied rewrites98.2%
Taylor expanded in maxCos around 0
Applied rewrites89.3%
Final simplification95.8%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) uy) 2.0))
(t_1 (* (* (- ux 1.0) maxCos) ux))
(t_2 (cos t_0)))
(if (<= (* 2.0 uy) 0.0015999999595806003)
(- (+ (* t_2 xi) (* (* t_0 (sqrt (- 1.0 (* t_1 t_1)))) yi)) (* t_1 zi))
(* (- yi) (- (* (/ t_2 (- yi)) xi) (sin t_0))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
t_1 := \left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\\
t_2 := \cos t\_0\\
\mathbf{if}\;2 \cdot uy \leq 0.0015999999595806003:\\
\;\;\;\;\left(t\_2 \cdot xi + \left(t\_0 \cdot \sqrt{1 - t\_1 \cdot t\_1}\right) \cdot yi\right) - t\_1 \cdot zi\\
\mathbf{else}:\\
\;\;\;\;\left(-yi\right) \cdot \left(\frac{t\_2}{-yi} \cdot xi - \sin t\_0\right)\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.00159999996Initial program 99.4%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3299.1
Applied rewrites99.1%
Taylor expanded in maxCos around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.7
Applied rewrites98.7%
if 0.00159999996 < (*.f32 uy #s(literal 2 binary32)) Initial program 98.4%
Applied rewrites88.4%
Taylor expanded in yi around -inf
Applied rewrites98.2%
Taylor expanded in maxCos around 0
Applied rewrites89.3%
Final simplification95.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (- ux 1.0) maxCos) ux)) (t_1 (* (* (PI) uy) 2.0)))
(-
(+ (* (cos t_1) xi) (* (* t_1 (sqrt (- 1.0 (* t_0 t_0)))) yi))
(* t_0 zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\\
t_1 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
\left(\cos t\_1 \cdot xi + \left(t\_1 \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot yi\right) - t\_0 \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.f3291.1
Applied rewrites91.1%
Taylor expanded in maxCos around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3290.8
Applied rewrites90.8%
Final simplification90.8%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (- (* (sqrt (- 1.0 (pow (* (* maxCos (- 1.0 ux)) ux) 2.0))) 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 - powf(((maxCos * (1.0f - ux)) * ux), 2.0f))) * 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 - (((maxcos * (1.0e0 - ux)) * ux) ** 2.0e0))) * 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(maxCos * Float32(Float32(1.0) - ux)) * ux) ^ Float32(2.0)))) * xi) - Float32(Float32(Float32(Float32(ux - Float32(1.0)) * maxCos) * ux) * zi)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (sqrt((single(1.0) - (((maxCos * (single(1.0) - ux)) * ux) ^ single(2.0)))) * xi) - ((((ux - single(1.0)) * maxCos) * ux) * zi); end
\begin{array}{l}
\\
\sqrt{1 - {\left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right)}^{2}} \cdot xi - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
Initial program 99.0%
Applied rewrites83.4%
Taylor expanded in uy around 0
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
mul-1-negN/A
lower-neg.f32N/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites51.8%
Applied rewrites51.8%
Final simplification51.8%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (- (* (sqrt (- 1.0 (* (* (* maxCos ux) (* (* maxCos (- 1.0 ux)) ux)) (- 1.0 ux)))) xi) (* (* (* (- ux 1.0) zi) ux) maxCos)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (sqrtf((1.0f - (((maxCos * ux) * ((maxCos * (1.0f - ux)) * ux)) * (1.0f - ux)))) * xi) - ((((ux - 1.0f) * 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 = (sqrt((1.0e0 - (((maxcos * ux) * ((maxcos * (1.0e0 - ux)) * ux)) * (1.0e0 - ux)))) * xi) - ((((ux - 1.0e0) * zi) * ux) * maxcos)
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(sqrt(Float32(Float32(1.0) - Float32(Float32(Float32(maxCos * ux) * Float32(Float32(maxCos * Float32(Float32(1.0) - ux)) * ux)) * Float32(Float32(1.0) - ux)))) * xi) - Float32(Float32(Float32(Float32(ux - Float32(1.0)) * zi) * ux) * maxCos)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (sqrt((single(1.0) - (((maxCos * ux) * ((maxCos * (single(1.0) - ux)) * ux)) * (single(1.0) - ux)))) * xi) - ((((ux - single(1.0)) * zi) * ux) * maxCos); end
\begin{array}{l}
\\
\sqrt{1 - \left(\left(maxCos \cdot ux\right) \cdot \left(\left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\right)\right) \cdot \left(1 - ux\right)} \cdot xi - \left(\left(\left(ux - 1\right) \cdot zi\right) \cdot ux\right) \cdot maxCos
\end{array}
Initial program 99.0%
Applied rewrites83.4%
Taylor expanded in uy around 0
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
mul-1-negN/A
lower-neg.f32N/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites51.8%
Applied rewrites51.8%
Final simplification51.8%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (- (* (sqrt (- 1.0 (* (* ux ux) (* maxCos maxCos)))) xi) (* (* (* (- ux 1.0) zi) ux) maxCos)))
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) * 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 = (sqrt((1.0e0 - ((ux * ux) * (maxcos * maxcos)))) * xi) - ((((ux - 1.0e0) * zi) * ux) * maxcos)
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(ux - Float32(1.0)) * zi) * ux) * maxCos)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (sqrt((single(1.0) - ((ux * ux) * (maxCos * maxCos)))) * xi) - ((((ux - single(1.0)) * zi) * ux) * maxCos); end
\begin{array}{l}
\\
\sqrt{1 - \left(ux \cdot ux\right) \cdot \left(maxCos \cdot maxCos\right)} \cdot xi - \left(\left(\left(ux - 1\right) \cdot zi\right) \cdot ux\right) \cdot maxCos
\end{array}
Initial program 99.0%
Applied rewrites83.4%
Taylor expanded in uy around 0
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
mul-1-negN/A
lower-neg.f32N/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites51.8%
Taylor expanded in ux around 0
Applied rewrites51.6%
Final simplification51.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (+ (* (* zi ux) maxCos) xi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return ((zi * ux) * maxCos) + 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 = ((zi * ux) * maxcos) + xi
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(zi * ux) * maxCos) + xi) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = ((zi * ux) * maxCos) + xi; end
\begin{array}{l}
\\
\left(zi \cdot ux\right) \cdot maxCos + xi
\end{array}
Initial program 99.0%
Applied rewrites83.4%
Taylor expanded in uy around 0
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
mul-1-negN/A
lower-neg.f32N/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites51.8%
Taylor expanded in ux around 0
Applied rewrites43.8%
Applied rewrites49.0%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma maxCos (* zi ux) xi))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return fmaf(maxCos, (zi * ux), xi);
}
function code(xi, yi, zi, ux, uy, maxCos) return fma(maxCos, Float32(zi * ux), xi) end
\begin{array}{l}
\\
\mathsf{fma}\left(maxCos, zi \cdot ux, xi\right)
\end{array}
Initial program 99.0%
Applied rewrites83.4%
Taylor expanded in uy around 0
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-*.f32N/A
lower--.f32N/A
mul-1-negN/A
lower-neg.f32N/A
lower-*.f32N/A
lower-sqrt.f32N/A
lower--.f32N/A
*-commutativeN/A
lower-*.f32N/A
Applied rewrites51.8%
Taylor expanded in ux around 0
Applied rewrites43.8%
Taylor expanded in ux around 0
Applied rewrites43.8%
Final simplification43.8%
(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--.f3214.9
Applied rewrites14.9%
Taylor expanded in ux around 0
Applied rewrites12.8%
herbie shell --seed 2024244
(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)))