
(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 12 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) (* 2.0 uy))))
(-
(+ (* yi (* (sin t_2) t_1)) (* xi (* t_1 (cos t_2))))
(* (- ux 1.0) (* zi (* maxCos ux))))))\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(ux - 1\right) \cdot \left(zi \cdot \left(maxCos \cdot ux\right)\right)
\end{array}
\end{array}
Initial program 99.0%
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3299.0
Applied rewrites99.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))))))
(* (- ux 1.0) (* zi (* maxCos ux))))))\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(ux - 1\right) \cdot \left(zi \cdot \left(maxCos \cdot ux\right)\right)
\end{array}
\end{array}
Initial program 99.0%
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3299.0
Applied rewrites99.0%
Taylor expanded in ux around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3299.0
Applied rewrites99.0%
Final simplification99.0%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(-
(+
(* (fma (* (* uy uy) -2.0) (* (sqrt (* (PI) (PI))) (PI)) 1.0) xi)
(* yi (* (sin (* (PI) (* 2.0 uy))) (sqrt (- 1.0 (* t_0 t_0))))))
(* (- ux 1.0) (* zi (* maxCos ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
\left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \sqrt{\mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right)} \cdot \mathsf{PI}\left(\right), 1\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(ux - 1\right) \cdot \left(zi \cdot \left(maxCos \cdot ux\right)\right)
\end{array}
\end{array}
Initial program 99.0%
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3299.0
Applied rewrites99.0%
Taylor expanded in ux around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3299.0
Applied rewrites99.0%
Taylor expanded in uy around 0
Applied rewrites89.5%
Applied rewrites89.9%
Final simplification89.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) uy) 2.0))
(t_3 (* (- ux 1.0) (* zi (* maxCos ux)))))
(if (<= (* 2.0 uy) 0.11299999803304672)
(- (+ (* (* t_2 t_1) yi) (* (cos t_2) xi)) t_3)
(-
(+
(* (fma (* (* uy uy) -2.0) (* (PI) (PI)) 1.0) xi)
(* yi (* (sin (* (PI) (* 2.0 uy))) t_1)))
t_3))))\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 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
t_3 := \left(ux - 1\right) \cdot \left(zi \cdot \left(maxCos \cdot ux\right)\right)\\
\mathbf{if}\;2 \cdot uy \leq 0.11299999803304672:\\
\;\;\;\;\left(\left(t\_2 \cdot t\_1\right) \cdot yi + \cos t\_2 \cdot xi\right) - t\_3\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 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) - t\_3\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.112999998Initial program 99.2%
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3299.2
Applied rewrites99.2%
Taylor expanded in ux around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3299.2
Applied rewrites99.2%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3294.9
Applied rewrites94.9%
if 0.112999998 < (*.f32 uy #s(literal 2 binary32)) Initial program 97.7%
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3297.7
Applied rewrites97.7%
Taylor expanded in ux around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3297.7
Applied rewrites97.7%
Taylor expanded in uy around 0
Applied rewrites66.3%
Final simplification87.1%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)) (t_1 (* (* (PI) uy) 2.0)))
(-
(+ (* (* t_1 (sqrt (- 1.0 (* t_0 t_0)))) yi) (* (cos t_1) xi))
(* (- ux 1.0) (* zi (* maxCos ux))))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
t_1 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
\left(\left(t\_1 \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot yi + \cos t\_1 \cdot xi\right) - \left(ux - 1\right) \cdot \left(zi \cdot \left(maxCos \cdot ux\right)\right)
\end{array}
\end{array}
Initial program 99.0%
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3299.0
Applied rewrites99.0%
Taylor expanded in ux around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3299.0
Applied rewrites99.0%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3287.7
Applied rewrites87.7%
Final simplification87.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) uy) 2.0)) (t_1 (* (* maxCos (- 1.0 ux)) ux)))
(if (<= yi -5.000000229068525e-19)
(-
(+
(* (fma (* (* uy uy) -2.0) (* (PI) (PI)) 1.0) xi)
(* (* t_0 (sqrt (- 1.0 (* t_1 t_1)))) yi))
(* (- ux 1.0) (* zi (* maxCos ux))))
(if (<= yi 1.9999999920083944e-12)
(-
(* (sqrt (- 1.0 (pow t_1 2.0))) xi)
(* (* (* (- ux 1.0) maxCos) ux) zi))
(* (sin t_0) yi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
t_1 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
\mathbf{if}\;yi \leq -5.000000229068525 \cdot 10^{-19}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot xi + \left(t\_0 \cdot \sqrt{1 - t\_1 \cdot t\_1}\right) \cdot yi\right) - \left(ux - 1\right) \cdot \left(zi \cdot \left(maxCos \cdot ux\right)\right)\\
\mathbf{elif}\;yi \leq 1.9999999920083944 \cdot 10^{-12}:\\
\;\;\;\;\sqrt{1 - {t\_1}^{2}} \cdot xi - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;\sin t\_0 \cdot yi\\
\end{array}
\end{array}
if yi < -5.00000023e-19Initial program 99.0%
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3299.0
Applied rewrites99.0%
Taylor expanded in ux around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3299.0
Applied rewrites99.0%
Taylor expanded in uy around 0
Applied rewrites93.1%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3282.6
Applied rewrites82.6%
if -5.00000023e-19 < yi < 1.99999999e-12Initial program 99.1%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites17.5%
Applied rewrites6.8%
Applied rewrites72.7%
if 1.99999999e-12 < yi Initial program 98.6%
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3298.6
Applied rewrites98.6%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites6.4%
Taylor expanded in ux around 0
Applied rewrites69.9%
Final simplification71.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (PI) uy) 2.0)) (t_1 (* (* maxCos (- 1.0 ux)) ux)))
(if (<= yi -5.000000229068525e-19)
(-
(+
(* (fma (* (* uy uy) -2.0) (* (PI) (PI)) 1.0) xi)
(* (* t_0 (sqrt (- 1.0 (* t_1 t_1)))) yi))
(* (- ux 1.0) (* zi (* maxCos ux))))
(if (<= yi 1.9999999920083944e-12)
(+ (* (* zi ux) maxCos) xi)
(* (sin t_0) yi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\\
t_1 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
\mathbf{if}\;yi \leq -5.000000229068525 \cdot 10^{-19}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot xi + \left(t\_0 \cdot \sqrt{1 - t\_1 \cdot t\_1}\right) \cdot yi\right) - \left(ux - 1\right) \cdot \left(zi \cdot \left(maxCos \cdot ux\right)\right)\\
\mathbf{elif}\;yi \leq 1.9999999920083944 \cdot 10^{-12}:\\
\;\;\;\;\left(zi \cdot ux\right) \cdot maxCos + xi\\
\mathbf{else}:\\
\;\;\;\;\sin t\_0 \cdot yi\\
\end{array}
\end{array}
if yi < -5.00000023e-19Initial program 99.0%
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3299.0
Applied rewrites99.0%
Taylor expanded in ux around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3299.0
Applied rewrites99.0%
Taylor expanded in uy around 0
Applied rewrites93.1%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3282.6
Applied rewrites81.3%
if -5.00000023e-19 < yi < 1.99999999e-12Initial program 99.1%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites17.5%
Taylor expanded in ux around 0
Applied rewrites63.2%
Applied rewrites68.3%
if 1.99999999e-12 < yi Initial program 98.6%
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3298.6
Applied rewrites98.6%
Taylor expanded in xi around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites6.5%
Taylor expanded in ux around 0
Applied rewrites69.9%
Final simplification66.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* maxCos (- 1.0 ux)) ux)))
(if (<= xi -5.999999941330714e-10)
(fma maxCos (* zi ux) xi)
(if (<= xi 1.5000000170217692e-18)
(-
(+
(* (fma (* (* uy uy) -2.0) (* (PI) (PI)) 1.0) xi)
(* (* (* (* (PI) uy) 2.0) (sqrt (- 1.0 (* t_0 t_0)))) yi))
(* (- ux 1.0) (* zi (* maxCos ux))))
(+ (* (* zi ux) maxCos) xi)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(maxCos \cdot \left(1 - ux\right)\right) \cdot ux\\
\mathbf{if}\;xi \leq -5.999999941330714 \cdot 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(maxCos, zi \cdot ux, xi\right)\\
\mathbf{elif}\;xi \leq 1.5000000170217692 \cdot 10^{-18}:\\
\;\;\;\;\left(\mathsf{fma}\left(\left(uy \cdot uy\right) \cdot -2, \mathsf{PI}\left(\right) \cdot \mathsf{PI}\left(\right), 1\right) \cdot xi + \left(\left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot \sqrt{1 - t\_0 \cdot t\_0}\right) \cdot yi\right) - \left(ux - 1\right) \cdot \left(zi \cdot \left(maxCos \cdot ux\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(zi \cdot ux\right) \cdot maxCos + xi\\
\end{array}
\end{array}
if xi < -5.99999994e-10Initial program 99.4%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites6.9%
Taylor expanded in ux around 0
Applied rewrites76.0%
Applied rewrites76.0%
if -5.99999994e-10 < xi < 1.50000002e-18Initial program 98.8%
lift-*.f32N/A
lift-*.f32N/A
lift-*.f32N/A
associate-*l*N/A
associate-*l*N/A
lower-*.f32N/A
lower-*.f32N/A
lower-*.f3298.8
Applied rewrites98.8%
Taylor expanded in ux around 0
lower-cos.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3298.8
Applied rewrites98.8%
Taylor expanded in uy around 0
Applied rewrites92.9%
Taylor expanded in uy around 0
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower-PI.f3281.1
Applied rewrites80.5%
if 1.50000002e-18 < xi Initial program 99.1%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites8.7%
Taylor expanded in ux around 0
Applied rewrites65.1%
Applied rewrites67.3%
Final simplification76.9%
(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%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites13.6%
Taylor expanded in ux around 0
Applied rewrites44.8%
Applied rewrites48.2%
(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%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites13.6%
Taylor expanded in ux around 0
Applied rewrites44.8%
Applied rewrites44.8%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* zi maxCos) ux))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return (zi * maxCos) * 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) * ux
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(zi * maxCos) * ux) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = (zi * maxCos) * ux; end
\begin{array}{l}
\\
\left(zi \cdot maxCos\right) \cdot ux
\end{array}
Initial program 99.0%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites13.6%
Taylor expanded in ux around 0
Applied rewrites44.8%
Taylor expanded in xi around 0
Applied rewrites11.6%
Applied rewrites11.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* zi (* maxCos ux)))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return zi * (maxCos * 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 * ux)
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(zi * Float32(maxCos * ux)) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = zi * (maxCos * ux); end
\begin{array}{l}
\\
zi \cdot \left(maxCos \cdot ux\right)
\end{array}
Initial program 99.0%
Taylor expanded in uy around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f32N/A
Applied rewrites13.6%
Taylor expanded in ux around 0
Applied rewrites44.8%
Taylor expanded in xi around 0
Applied rewrites11.6%
Applied rewrites11.6%
Final simplification11.6%
herbie shell --seed 2024332
(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)))