
(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 (* (* 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) 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(yi \cdot \left(\sin t\_2 \cdot t\_1\right) + 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 99.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) 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 + 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(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 99.0%
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) (* 2.0 uy))))
(-
(+ (* yi (sin t_0)) (* xi (cos t_0)))
(* (* (* (- ux 1.0) maxCos) ux) zi))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{PI}\left(\right) \cdot \left(2 \cdot uy\right)\\
\left(yi \cdot \sin t\_0 + xi \cdot \cos t\_0\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
\end{array}
Initial program 99.0%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3232.1
Applied rewrites31.9%
Applied rewrites98.7%
Final simplification98.7%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (* (- ux 1.0) maxCos) ux) zi)))
(if (<= (* 2.0 uy) 0.11500000208616257)
(- (+ (* (* (* yi (PI)) uy) 2.0) xi) t_0)
(- (* (cos (* (* (PI) uy) 2.0)) xi) t_0))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{if}\;2 \cdot uy \leq 0.11500000208616257:\\
\;\;\;\;\left(\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2 + xi\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot 2\right) \cdot xi - t\_0\\
\end{array}
\end{array}
if (*.f32 uy #s(literal 2 binary32)) < 0.115000002Initial program 99.2%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3235.1
Applied rewrites35.1%
Taylor expanded in uy around 0
Applied rewrites55.7%
Applied rewrites89.6%
if 0.115000002 < (*.f32 uy #s(literal 2 binary32)) Initial program 97.5%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f327.7
Applied rewrites7.7%
Taylor expanded in uy around 0
Applied rewrites17.7%
Taylor expanded in xi around inf
Applied rewrites58.3%
Final simplification85.9%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (* (- ux 1.0) maxCos) ux) zi))
(t_1 (- (* (* (* yi (PI)) uy) 2.0) t_0)))
(if (<= yi -1.0000000036274937e-15)
t_1
(if (<= yi 8.00000002901995e-15)
(- (fma (* (* (PI) uy) yi) 2.0 xi) t_0)
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
t_1 := \left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2 - t\_0\\
\mathbf{if}\;yi \leq -1.0000000036274937 \cdot 10^{-15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;yi \leq 8.00000002901995 \cdot 10^{-15}:\\
\;\;\;\;\mathsf{fma}\left(\left(\mathsf{PI}\left(\right) \cdot uy\right) \cdot yi, 2, xi\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if yi < -1e-15 or 8.00000003e-15 < yi Initial program 98.5%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3246.3
Applied rewrites46.3%
Taylor expanded in uy around 0
Applied rewrites25.7%
Taylor expanded in xi around 0
Applied rewrites54.7%
if -1e-15 < yi < 8.00000003e-15Initial program 99.4%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3220.0
Applied rewrites20.0%
Taylor expanded in uy around 0
Applied rewrites72.0%
Applied rewrites72.0%
Final simplification64.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* (* (- ux 1.0) maxCos) ux) zi))
(t_1 (- (* (* (* yi (PI)) uy) 2.0) t_0)))
(if (<= yi -1.0000000036274937e-15)
t_1
(if (<= yi 8.00000002901995e-15)
(- (fma (* yi 2.0) (* (PI) uy) xi) t_0)
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
t_1 := \left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2 - t\_0\\
\mathbf{if}\;yi \leq -1.0000000036274937 \cdot 10^{-15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;yi \leq 8.00000002901995 \cdot 10^{-15}:\\
\;\;\;\;\mathsf{fma}\left(yi \cdot 2, \mathsf{PI}\left(\right) \cdot uy, xi\right) - t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if yi < -1e-15 or 8.00000003e-15 < yi Initial program 98.5%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3246.3
Applied rewrites46.9%
Taylor expanded in uy around 0
Applied rewrites25.7%
Taylor expanded in xi around 0
Applied rewrites54.7%
if -1e-15 < yi < 8.00000003e-15Initial program 99.4%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3220.0
Applied rewrites20.0%
Taylor expanded in uy around 0
Applied rewrites72.0%
Applied rewrites72.0%
Final simplification64.5%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* yi (PI)) uy))
(t_1 (fma t_0 2.0 xi))
(t_2 (* maxCos (- 1.0 ux))))
(if (<= xi -5.000000229068525e-19)
(fma (* zi t_2) ux t_1)
(if (<= xi 6.000000233523199e-16)
(- (* t_0 2.0) (* (* (* (- ux 1.0) maxCos) ux) zi))
(fma (* zi ux) t_2 t_1)))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
t_1 := \mathsf{fma}\left(t\_0, 2, xi\right)\\
t_2 := maxCos \cdot \left(1 - ux\right)\\
\mathbf{if}\;xi \leq -5.000000229068525 \cdot 10^{-19}:\\
\;\;\;\;\mathsf{fma}\left(zi \cdot t\_2, ux, t\_1\right)\\
\mathbf{elif}\;xi \leq 6.000000233523199 \cdot 10^{-16}:\\
\;\;\;\;t\_0 \cdot 2 - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(zi \cdot ux, t\_2, t\_1\right)\\
\end{array}
\end{array}
if xi < -5.00000023e-19Initial program 99.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3212.9
Applied rewrites12.9%
Taylor expanded in uy around 0
Applied rewrites69.5%
lift-+.f32N/A
+-commutativeN/A
Applied rewrites67.1%
if -5.00000023e-19 < xi < 6.0000002e-16Initial program 98.9%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3251.2
Applied rewrites51.2%
Taylor expanded in uy around 0
Applied rewrites36.6%
Taylor expanded in xi around 0
Applied rewrites61.2%
if 6.0000002e-16 < xi Initial program 99.1%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3217.6
Applied rewrites17.6%
Taylor expanded in uy around 0
Applied rewrites54.9%
lift-+.f32N/A
+-commutativeN/A
Applied rewrites54.6%
Final simplification62.1%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* yi (PI)) uy))
(t_1 (fma (* (* (- 1.0 ux) ux) maxCos) zi (* t_0 2.0))))
(if (<= yi -1.0000000036274937e-15)
t_1
(if (<= yi 8.00000002901995e-15)
(fma (* zi ux) (* maxCos (- 1.0 ux)) (fma t_0 2.0 xi))
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
t_1 := \mathsf{fma}\left(\left(\left(1 - ux\right) \cdot ux\right) \cdot maxCos, zi, t\_0 \cdot 2\right)\\
\mathbf{if}\;yi \leq -1.0000000036274937 \cdot 10^{-15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;yi \leq 8.00000002901995 \cdot 10^{-15}:\\
\;\;\;\;\mathsf{fma}\left(zi \cdot ux, maxCos \cdot \left(1 - ux\right), \mathsf{fma}\left(t\_0, 2, xi\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if yi < -1e-15 or 8.00000003e-15 < yi Initial program 98.5%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3246.3
Applied rewrites46.3%
Taylor expanded in uy around 0
Applied rewrites25.7%
lift-+.f32N/A
+-commutativeN/A
Applied rewrites25.6%
Taylor expanded in xi around 0
Applied rewrites53.9%
if -1e-15 < yi < 8.00000003e-15Initial program 99.4%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3220.0
Applied rewrites20.0%
Taylor expanded in uy around 0
Applied rewrites72.0%
lift-+.f32N/A
+-commutativeN/A
Applied rewrites61.3%
Final simplification58.6%
(FPCore (xi yi zi ux uy maxCos)
:precision binary32
(let* ((t_0 (* (* yi (PI)) uy))
(t_1 (fma (* (* (- 1.0 ux) ux) maxCos) zi (* t_0 2.0))))
(if (<= yi -1.0000000036274937e-15)
t_1
(if (<= yi 8.00000002901995e-15)
(fma (* maxCos ux) zi (fma t_0 2.0 xi))
t_1))))\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\\
t_1 := \mathsf{fma}\left(\left(\left(1 - ux\right) \cdot ux\right) \cdot maxCos, zi, t\_0 \cdot 2\right)\\
\mathbf{if}\;yi \leq -1.0000000036274937 \cdot 10^{-15}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;yi \leq 8.00000002901995 \cdot 10^{-15}:\\
\;\;\;\;\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(t\_0, 2, xi\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if yi < -1e-15 or 8.00000003e-15 < yi Initial program 98.5%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3246.3
Applied rewrites46.3%
Taylor expanded in uy around 0
Applied rewrites25.6%
lift-+.f32N/A
+-commutativeN/A
Applied rewrites25.6%
Taylor expanded in xi around 0
Applied rewrites54.7%
if -1e-15 < yi < 8.00000003e-15Initial program 99.4%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3220.0
Applied rewrites20.0%
Taylor expanded in uy around 0
Applied rewrites72.6%
lift-+.f32N/A
+-commutativeN/A
Applied rewrites61.3%
Taylor expanded in ux around 0
lower-*.f3261.8
Applied rewrites61.8%
Final simplification58.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (- (+ (* (* (* yi (PI)) uy) 2.0) xi) (* (* (* (- ux 1.0) maxCos) ux) zi)))
\begin{array}{l}
\\
\left(\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2 + xi\right) - \left(\left(\left(ux - 1\right) \cdot maxCos\right) \cdot ux\right) \cdot zi
\end{array}
Initial program 99.0%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3231.9
Applied rewrites31.9%
Taylor expanded in uy around 0
Applied rewrites51.3%
Applied rewrites82.2%
Final simplification82.2%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* (* (- 1.0 ux) ux) maxCos) zi (+ (* (* (* yi (PI)) uy) 2.0) xi)))
\begin{array}{l}
\\
\mathsf{fma}\left(\left(\left(1 - ux\right) \cdot ux\right) \cdot maxCos, zi, \left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy\right) \cdot 2 + xi\right)
\end{array}
Initial program 99.0%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3231.9
Applied rewrites31.9%
Taylor expanded in uy around 0
Applied rewrites51.3%
lift-+.f32N/A
+-commutativeN/A
Applied rewrites45.4%
Applied rewrites75.2%
Final simplification75.6%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (fma (* maxCos ux) zi (fma (* (* yi (PI)) uy) 2.0 xi)))
\begin{array}{l}
\\
\mathsf{fma}\left(maxCos \cdot ux, zi, \mathsf{fma}\left(\left(yi \cdot \mathsf{PI}\left(\right)\right) \cdot uy, 2, xi\right)\right)
\end{array}
Initial program 99.0%
Taylor expanded in ux around 0
*-commutativeN/A
lower-fma.f32N/A
lower-cos.f32N/A
*-commutativeN/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.f3231.9
Applied rewrites31.9%
Taylor expanded in uy around 0
Applied rewrites51.3%
lift-+.f32N/A
+-commutativeN/A
Applied rewrites45.4%
Taylor expanded in ux around 0
lower-*.f3245.4
Applied rewrites45.4%
(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 99.0%
Taylor expanded in zi around inf
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
*-commutativeN/A
lower-*.f32N/A
lower--.f3213.0
Applied rewrites13.0%
Taylor expanded in ux around 0
Applied rewrites13.0%
(FPCore (xi yi zi ux uy maxCos) :precision binary32 (* (* (* zi (- 1.0 ux)) maxCos) ux))
float code(float xi, float yi, float zi, float ux, float uy, float maxCos) {
return ((zi * (1.0f - ux)) * 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 * (1.0e0 - ux)) * maxcos) * ux
end function
function code(xi, yi, zi, ux, uy, maxCos) return Float32(Float32(Float32(zi * Float32(Float32(1.0) - ux)) * maxCos) * ux) end
function tmp = code(xi, yi, zi, ux, uy, maxCos) tmp = ((zi * (single(1.0) - ux)) * maxCos) * ux; end
\begin{array}{l}
\\
\left(\left(zi \cdot \left(1 - ux\right)\right) \cdot maxCos\right) \cdot ux
\end{array}
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--.f3213.0
Applied rewrites13.0%
Applied rewrites13.0%
Final simplification13.0%
(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
*-commutativeN/A
lower-*.f32N/A
lower--.f3213.0
Applied rewrites13.0%
Taylor expanded in ux around 0
Applied rewrites12.1%
herbie shell --seed 2024285
(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)))